Browse Source

qml: consistency camelcase public slots listmodels

master
Sander van Grieken 3 years ago
parent
commit
f0bbbe9955
  1. 4
      electrum/gui/qml/components/Addresses.qml
  2. 4
      electrum/gui/qml/components/ChannelDetails.qml
  3. 4
      electrum/gui/qml/components/Invoices.qml
  4. 2
      electrum/gui/qml/components/OpenChannelDialog.qml
  5. 4
      electrum/gui/qml/components/controls/HistoryItemDelegate.qml
  6. 6
      electrum/gui/qml/qeaddresslistmodel.py
  7. 10
      electrum/gui/qml/qechannellistmodel.py
  8. 4
      electrum/gui/qml/qeinvoicelistmodel.py
  9. 10
      electrum/gui/qml/qeserverlistmodel.py
  10. 46
      electrum/gui/qml/qetransactionlistmodel.py
  11. 12
      electrum/gui/qml/qewallet.py

4
electrum/gui/qml/components/Addresses.qml

@ -36,7 +36,7 @@ Pane {
var page = app.stack.push(Qt.resolvedUrl('AddressDetails.qml'), {'address': model.address})
page.addressDetailsChanged.connect(function() {
// update listmodel when details change
listview.model.update_address(model.address)
listview.model.updateAddress(model.address)
})
}
}
@ -74,6 +74,6 @@ Pane {
}
Component.onCompleted: {
Daemon.currentWallet.addressModel.init_model()
Daemon.currentWallet.addressModel.initModel()
}
}

4
electrum/gui/qml/components/ChannelDetails.qml

@ -290,8 +290,8 @@ Pane {
dialog.accepted.connect(function() {
channeldetails.deleteChannel()
app.stack.pop()
Daemon.currentWallet.historyModel.init_model(true) // needed here?
Daemon.currentWallet.channelModel.remove_channel(channelid)
Daemon.currentWallet.historyModel.initModel(true) // needed here?
Daemon.currentWallet.channelModel.removeChannel(channelid)
})
dialog.open()
}

4
electrum/gui/qml/components/Invoices.qml

@ -52,7 +52,7 @@ Pane {
onClicked: {
var dialog = app.stack.getRoot().openInvoice(model.key)
dialog.invoiceAmountChanged.connect(function () {
Daemon.currentWallet.invoiceModel.init_model()
Daemon.currentWallet.invoiceModel.initModel()
})
listview.currentIndex = -1
}
@ -106,7 +106,7 @@ Pane {
onClicked: {
var dialog = app.stack.getRoot().openInvoice(listview.currentItem.getKey())
dialog.invoiceAmountChanged.connect(function () {
Daemon.currentWallet.invoiceModel.init_model()
Daemon.currentWallet.invoiceModel.initModel()
})
}
}

2
electrum/gui/qml/components/OpenChannelDialog.qml

@ -252,7 +252,7 @@ ElDialog {
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
if (!tx_complete) {
message = message + '\n\n' + qsTr('Please sign and broadcast the funding transaction.')
channelopener.wallet.historyModel.init_model(true) // local tx doesn't trigger model update
channelopener.wallet.historyModel.initModel(true) // local tx doesn't trigger model update
}
app.channelOpenProgressDialog.state = 'success'
app.channelOpenProgressDialog.info = message

4
electrum/gui/qml/components/controls/HistoryItemDelegate.qml

@ -27,13 +27,13 @@ Item {
var page = app.stack.push(Qt.resolvedUrl('../LightningPaymentDetails.qml'), {'key': model.key})
page.detailsChanged.connect(function() {
// update listmodel when details change
visualModel.model.update_tx_label(model.key, page.label)
visualModel.model.updateTxLabel(model.key, page.label)
})
} else {
var page = app.stack.push(Qt.resolvedUrl('../TxDetails.qml'), {'txid': model.key})
page.detailsChanged.connect(function() {
// update listmodel when details change
visualModel.model.update_tx_label(model.key, page.label)
visualModel.model.updateTxLabel(model.key, page.label)
})
}
}

6
electrum/gui/qml/qeaddresslistmodel.py

@ -25,7 +25,7 @@ class QEAddressListModel(QAbstractListModel):
super().__init__(parent)
self.wallet = wallet
self.setDirty()
self.init_model()
self.initModel()
def rowCount(self, index):
return len(self.receive_addresses) + len(self.change_addresses)
@ -68,7 +68,7 @@ class QEAddressListModel(QAbstractListModel):
# initial model data
@pyqtSlot()
def init_model(self):
def initModel(self):
if not self._dirty:
return
@ -97,7 +97,7 @@ class QEAddressListModel(QAbstractListModel):
self._dirty = False
@pyqtSlot(str)
def update_address(self, address):
def updateAddress(self, address):
for i, a in enumerate(itertools.chain(self.receive_addresses, self.change_addresses)):
if a['address'] == address:
self.do_update(i,a)

10
electrum/gui/qml/qechannellistmodel.py

@ -27,7 +27,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
def __init__(self, wallet, parent=None):
super().__init__(parent)
self.wallet = wallet
self.init_model()
self.initModel()
# To avoid leaking references to "self" that prevent the
# window from being GC-ed when closed, callbacks should be
@ -44,7 +44,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
@qt_event_listener
def on_event_channels_updated(self, wallet):
if wallet == self.wallet:
self.init_model()
self.initModel()
def on_destroy(self):
self.unregister_callbacks()
@ -108,7 +108,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
return sum([1 if x['state_code'] == ChannelState.OPEN else 0 for x in self.channels])
@pyqtSlot()
def init_model(self):
def initModel(self):
self._logger.debug('init_model')
if not self.wallet.lnworker:
self._logger.warning('lnworker should be defined')
@ -149,7 +149,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
self.numOpenChannelsChanged.emit()
@pyqtSlot(str)
def new_channel(self, cid):
def newChannel(self, cid):
self._logger.debug('new channel with cid %s' % cid)
lnchannels = self.wallet.lnworker.channels
for channel in lnchannels.values():
@ -163,7 +163,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
return
@pyqtSlot(str)
def remove_channel(self, cid):
def removeChannel(self, cid):
self._logger.debug('remove channel with cid %s' % cid)
for i, channel in enumerate(self.channels):
if cid == channel['cid']:

4
electrum/gui/qml/qeinvoicelistmodel.py

@ -35,7 +35,7 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
self._timer.timeout.connect(self.updateStatusStrings)
try:
self.init_model()
self.initModel()
except Exception as e:
self._logger.error(f'{repr(e)}')
raise e
@ -63,7 +63,7 @@ class QEAbstractInvoiceListModel(QAbstractListModel):
self.endResetModel()
@pyqtSlot()
def init_model(self):
def initModel(self):
invoices = []
for invoice in self.get_invoice_list():
item = self.invoice_to_model(invoice)

10
electrum/gui/qml/qeserverlistmodel.py

@ -26,24 +26,24 @@ class QEServerListModel(QAbstractListModel, QtEventListener):
self._chaintips = 0
self.network = network
self.init_model()
self.initModel()
self.register_callbacks()
self.destroyed.connect(lambda: self.unregister_callbacks())
@qt_event_listener
def on_event_network_updated(self):
self._logger.info(f'network updated')
self.init_model()
self.initModel()
@qt_event_listener
def on_event_blockchain_updated(self):
self._logger.info(f'blockchain updated')
self.init_model()
self.initModel()
@qt_event_listener
def on_event_default_server_changed(self):
self._logger.info(f'default server changed')
self.init_model()
self.initModel()
def rowCount(self, index):
return len(self.servers)
@ -81,7 +81,7 @@ class QEServerListModel(QAbstractListModel, QtEventListener):
return chains
@pyqtSlot()
def init_model(self):
def initModel(self):
self.clear()
servers = []

46
electrum/gui/qml/qetransactionlistmodel.py

@ -36,10 +36,10 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
self.register_callbacks()
self.destroyed.connect(lambda: self.on_destroy())
self.requestRefresh.connect(lambda: self.init_model())
self.requestRefresh.connect(lambda: self.initModel())
self.setDirty()
self.init_model()
self.initModel()
def on_destroy(self):
self.unregister_callbacks()
@ -60,6 +60,25 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
self._update_future_txitem(i)
return
@qt_event_listener
def on_event_fee_histogram(self, histogram):
self._logger.debug(f'fee histogram updated')
for i, tx_item in enumerate(self.tx_history):
if 'height' not in tx_item: # filter to on-chain
continue
if tx_item['confirmations'] > 0: # filter out already mined
continue
txid = tx_item['txid']
tx = self.wallet.db.get_transaction(txid)
if not tx:
continue
txinfo = self.wallet.get_tx_info(tx)
status, status_str = self.wallet.get_tx_status(txid, txinfo.tx_mined_status)
tx_item['date'] = status_str
index = self.index(i, 0)
roles = [self._ROLE_RMAP['date']]
self.dataChanged.emit(index, index, roles)
def rowCount(self, index):
return len(self.tx_history)
@ -180,7 +199,7 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
# initial model data
@pyqtSlot()
@pyqtSlot(bool)
def init_model(self, force: bool = False):
def initModel(self, force: bool = False):
# only (re)construct if dirty or forced
if not self._dirty and not force:
return
@ -237,7 +256,7 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
self.dataChanged.emit(index, index, roles)
@pyqtSlot(str, str)
def update_tx_label(self, key, label):
def updateTxLabel(self, key, label):
for i, tx in enumerate(self.tx_history):
if tx['key'] == key:
tx['label'] = label
@ -257,22 +276,3 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
self.dataChanged.emit(index, index, roles)
elif tx_item['height'] in (TX_HEIGHT_FUTURE, TX_HEIGHT_LOCAL):
self._update_future_txitem(i)
@qt_event_listener
def on_event_fee_histogram(self, histogram):
self._logger.debug(f'fee histogram updated')
for i, tx_item in enumerate(self.tx_history):
if 'height' not in tx_item: # filter to on-chain
continue
if tx_item['confirmations'] > 0: # filter out already mined
continue
txid = tx_item['txid']
tx = self.wallet.db.get_transaction(txid)
if not tx:
continue
txinfo = self.wallet.get_tx_info(tx)
status, status_str = self.wallet.get_tx_status(txid, txinfo.tx_mined_status)
tx_item['date'] = status_str
index = self.index(i, 0)
roles = [self._ROLE_RMAP['date']]
self.dataChanged.emit(index, index, roles)

12
electrum/gui/qml/qewallet.py

@ -168,7 +168,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
# TODO: only update if it was paid over lightning,
# and even then, we can probably just add the payment instead
# of recreating the whole history (expensive)
self.historyModel.init_model(True)
self.historyModel.initModel(True)
@event_listener
def on_event_invoice_status(self, wallet, key, status):
@ -196,7 +196,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
if wallet == self.wallet:
self._logger.info(f'removed transaction {tx.txid()}')
self.addressModel.setDirty()
self.historyModel.init_model(True) #setDirty()
self.historyModel.initModel(True) #setDirty()
self.balanceChanged.emit()
@qt_event_listener
@ -206,7 +206,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
self.balanceChanged.emit()
self.synchronizing = not wallet.is_up_to_date()
if not self.synchronizing:
self.historyModel.init_model() # refresh if dirty
self.historyModel.initModel() # refresh if dirty
@event_listener
def on_event_channel(self, wallet, channel):
@ -224,7 +224,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
def on_event_payment_succeeded(self, wallet, key):
if wallet == self.wallet:
self.paymentSucceeded.emit(key)
self.historyModel.init_model(True) # TODO: be less dramatic
self.historyModel.initModel(True) # TODO: be less dramatic
@event_listener
def on_event_payment_failed(self, wallet, key, reason):
@ -527,7 +527,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
self.broadcast(tx)
else:
# not broadcasted, so refresh history here
self.historyModel.init_model(True)
self.historyModel.initModel(True)
return True
@ -589,7 +589,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
return
self.wallet.save_db()
self.saveTxSuccess.emit(tx.txid())
self.historyModel.init_model(True)
self.historyModel.initModel(True)
return True
except AddTransactionException as e:
self.saveTxError.emit(tx.txid(), 'error', str(e))

Loading…
Cancel
Save