[ui] Node: fix slowness due to QML function calls with a lot of nodes

Instead of calling the duplicateList function for each node, at each modification, it is called only when we press the button.
This commit is contained in:
Julien-Haudegond 2020-08-13 11:45:52 +02:00
parent 02b9e34ba4
commit d838e7866a
2 changed files with 8 additions and 5 deletions

View file

@ -868,12 +868,12 @@ class BaseNode(BaseObject):
def updateDuplicates(self, nodesPerUid): def updateDuplicates(self, nodesPerUid):
""" Update the list of duplicate nodes (sharing the same uid). """ """ Update the list of duplicate nodes (sharing the same uid). """
if not nodesPerUid: uid = self._uids.get(0)
if not nodesPerUid or not uid:
self._duplicates.clear() self._duplicates.clear()
self.duplicatesChanged.emit() self.duplicatesChanged.emit()
return return
uid = self._uids.get(0)
self._duplicates.setObjectList([node for node in nodesPerUid.get(uid) if node != self]) self._duplicates.setObjectList([node for node in nodesPerUid.get(uid) if node != self])
self.duplicatesChanged.emit() self.duplicatesChanged.emit()

View file

@ -177,14 +177,17 @@ Item {
spacing: 2 spacing: 2
// Data sharing indicator // Data sharing indicator
MaterialLabel { MaterialToolButton {
visible: node.duplicates.count > 0 visible: node.duplicates.count > 0
text: MaterialIcons.layers text: MaterialIcons.layers
font.pointSize: 7 font.pointSize: 7
padding: 2 padding: 2
palette.text: Colors.sysPalette.text palette.text: Colors.sysPalette.text
ToolTip.text: visible ? generateDuplicateList() : "" ToolTip.text: visible ? "<b>Shares internal folder (data) with other node(s). Click for details.</b>" : ""
ToolTip.delay: 250
onPressed: ToolTip.text = visible ? generateDuplicateList() : ""
onReleased: ToolTip.text = visible ? "<b>Shares internal folder (data) with other node(s). Click for details.</b>" : ""
onCanceled: released()
} }
// Submitted externally indicator // Submitted externally indicator