From b0631f90f807fd37d2d2e507157aedf6c826ba20 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 10 Dec 2018 16:40:32 +0100 Subject: [PATCH] qt history: fix slowness arghhhhh finalllllllllllly figured it out... --- electrum/gui/qt/history_list.py | 5 ++--- electrum/gui/qt/util.py | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index 5c5b9223f..3b3a6fa2b 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -96,9 +96,8 @@ class HistoryModel(QAbstractItemModel, PrintError): return self.createIndex(row, column) def data(self, index: QModelIndex, role: Qt.ItemDataRole): - # requires PyQt5 5.11 - # indexIsValid = QAbstractItemModel.CheckIndexOptions(QAbstractItemModel.CheckIndexOption.IndexIsValid.value) - # assert self.checkIndex(index, indexIsValid) + # note: this method is performance-critical. + # it is called a lot, and so must run extremely fast. assert index.isValid() col = index.column() tx_item = self.transactions.value_from_pos(index.row()) diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index f71243ed0..409cbc8ab 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -444,6 +444,13 @@ class MyTreeView(QTreeView): self.setRootIsDecorated(False) # remove left margin self.toolbar_shown = False + # When figuring out the size of columns, Qt by default looks at + # the first 1000 rows (at least if resize mode is QHeaderView.ResizeToContents). + # This would be REALLY SLOW, and it's not perfect anyway. + # So to speed the UI up considerably, set it to + # only look at as many rows as currently visible. + self.header().setResizeContentsPrecision(0) + def set_editability(self, items): for idx, i in enumerate(items): i.setEditable(idx in self.editable_columns)