From 5cbac39558de17b7a1abda19e86f3f7625b9779e Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 21 Nov 2018 17:25:33 +0300 Subject: [PATCH] Optimize updating of the tree --- src/XGUI/XGUI_DataModel.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 4980dd198..4e29b2723 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -139,20 +139,20 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess rebuildDataTree(); } else { + QTreeNodesList aParents; foreach(ObjectPtr aObj, aCreated) { ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj); if (aNode) { if (aNode->parent()) - aNode->parent()->update(); - else - aNode->update(); - rebuildDataTree(); - QModelIndex aFirstIdx = getIndex(aNode, 0); - QModelIndex aLastIdx = getIndex(aNode, 2); - - dataChanged(aFirstIdx, aLastIdx); + aNode = aNode->parent(); + if (!aParents.contains(aNode)) + aParents.append(aNode); } } + foreach(ModuleBase_ITreeNode* aNode, aParents) { + aNode->update(); + } + rebuildDataTree(); } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) { -- 2.39.2