qt history list: optimise update_item (tx mined status)

This commit is contained in:
SomberNight 2018-12-08 04:27:44 +01:00
parent b1e15751d6
commit 696db310a5
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
2 changed files with 11 additions and 4 deletions

View file

@ -247,8 +247,15 @@ class HistoryModel(QAbstractItemModel, PrintError):
tx_item.update(fiat_fields)
self.dataChanged.emit(idx, idx, [Qt.DisplayRole, Qt.ForegroundRole])
def update_item(self, *args):
self.refresh('update_item')
def update_tx_mined_status(self, tx_hash: str, tx_mined_info: TxMinedInfo):
self.tx_status_cache[tx_hash] = self.parent.wallet.get_tx_status(tx_hash, tx_mined_info)
try:
row = self.transactions.pos_from_key(tx_hash)
except KeyError:
return
topLeft = self.createIndex(row, 0)
bottomRight = self.createIndex(row, self.NUM_COLUMNS-1)
self.dataChanged.emit(topLeft, bottomRight)
def headerData(self, section: int, orientation: Qt.Orientation, role: Qt.ItemDataRole):
assert orientation == Qt.Horizontal

View file

@ -346,8 +346,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.console.showMessage(args[0])
elif event == 'verified':
wallet, tx_hash, tx_mined_status = args
if wallet == self.wallet and wallet.up_to_date:
self.history_model.update_item(tx_hash, tx_mined_status)
if wallet == self.wallet:
self.history_model.update_tx_mined_status(tx_hash, tx_mined_status)
elif event == 'fee':
if self.config.is_dynfee():
self.fee_slider.update()