qt history: fix slowness

arghhhhh finalllllllllllly figured it out...
This commit is contained in:
SomberNight 2018-12-10 16:40:32 +01:00
parent e35ed17200
commit b0631f90f8
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
2 changed files with 9 additions and 3 deletions

View file

@ -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())

View file

@ -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)