qml: make listmodel item count a property for channels and transactions
This commit is contained in:
@@ -123,12 +123,12 @@ Pane {
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
|
||||
Label {
|
||||
visible: Daemon.currentWallet.channelModel.rowCount() == 0
|
||||
visible: Daemon.currentWallet.channelModel.count == 0
|
||||
anchors.centerIn: parent
|
||||
width: listview.width * 4/5
|
||||
font.pixelSize: constants.fontSizeXXLarge
|
||||
color: constants.mutedForeground
|
||||
text: qsTr('You have no Lightning channels yet in this wallet')
|
||||
text: qsTr('No Lightning channels yet in this wallet')
|
||||
wrapMode: Text.Wrap
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ Pane {
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
|
||||
Label {
|
||||
visible: Daemon.currentWallet.historyModel.rowCount() == 0
|
||||
visible: Daemon.currentWallet.historyModel.count == 0
|
||||
anchors.centerIn: parent
|
||||
width: listview.width * 4/5
|
||||
font.pixelSize: constants.fontSizeXXLarge
|
||||
|
||||
@@ -46,6 +46,12 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
def rowCount(self, index):
|
||||
return len(self.channels)
|
||||
|
||||
# also expose rowCount as a property
|
||||
countChanged = pyqtSignal()
|
||||
@pyqtProperty(int, notify=countChanged)
|
||||
def count(self):
|
||||
return len(self.channels)
|
||||
|
||||
def roleNames(self):
|
||||
return self._ROLE_MAP
|
||||
|
||||
@@ -113,6 +119,8 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
self.channels = channels
|
||||
self.endInsertRows()
|
||||
|
||||
self.countChanged.emit()
|
||||
|
||||
def on_channel_updated(self, channel):
|
||||
i = 0
|
||||
for c in self.channels:
|
||||
@@ -141,6 +149,8 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
self.beginInsertRows(QModelIndex(), 0, 0)
|
||||
self.channels.insert(0,item)
|
||||
self.endInsertRows()
|
||||
self.countChanged.emit()
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
def remove_channel(self, cid):
|
||||
@@ -152,5 +162,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
self.beginRemoveRows(QModelIndex(), i, i)
|
||||
self.channels.remove(channel)
|
||||
self.endRemoveRows()
|
||||
self.countChanged.emit()
|
||||
return
|
||||
i = i + 1
|
||||
|
||||
@@ -46,6 +46,12 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
||||
def rowCount(self, index):
|
||||
return len(self.tx_history)
|
||||
|
||||
# also expose rowCount as a property
|
||||
countChanged = pyqtSignal()
|
||||
@pyqtProperty(int, notify=countChanged)
|
||||
def count(self):
|
||||
return len(self.tx_history)
|
||||
|
||||
def roleNames(self):
|
||||
return self._ROLE_MAP
|
||||
|
||||
@@ -147,6 +153,8 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
||||
self.tx_history.reverse()
|
||||
self.endInsertRows()
|
||||
|
||||
self.countChanged.emit()
|
||||
|
||||
def on_tx_verified(self, txid, info):
|
||||
i = 0
|
||||
for tx in self.tx_history:
|
||||
|
||||
Reference in New Issue
Block a user