1
0

make qt HistoryList.on_update() faster by caching icons

This commit is contained in:
SomberNight
2018-04-04 15:47:11 +02:00
parent eb4463063f
commit 2f408e5d07
4 changed files with 20 additions and 7 deletions

View File

@@ -393,6 +393,8 @@ class MyTreeWidget(QTreeWidget):
self.addChild = self.addTopLevelItem
self.insertChild = self.insertTopLevelItem
self.icon_cache = IconCache()
# Control which columns are editable
self.editor = None
self.pending_update = False
@@ -779,6 +781,17 @@ class SortableTreeWidgetItem(QTreeWidgetItem):
return self.text(column) < other.text(column)
class IconCache:
def __init__(self):
self.__cache = {}
def get(self, file_name):
if file_name not in self.__cache:
self.__cache[file_name] = QIcon(file_name)
return self.__cache[file_name]
if __name__ == "__main__":
app = QApplication([])
t = WaitingDialog(None, 'testing ...', lambda: [time.sleep(1)], lambda x: QMessageBox.information(None, 'done', "done"))