From 9549a264ff1d052e4a37499efd89a4069404260a Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Oct 2018 15:24:07 +0300 Subject: [PATCH] Issue #2726: Update a tree branch on creation of a Folder --- src/XGUI/XGUI_DataModel.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index ee7f93457..f2cfa898a 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -73,13 +73,21 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess ModuleBase_ITreeNode* aParent; int aRow = 0; QModelIndex aParentIndex1, aParentIndex2; + ObjectPtr aObj; foreach(ModuleBase_ITreeNode* aNode, aNodes) { + aObj = aNode->object(); aParent = aNode->parent(); - aRow = aParent->nodeRow(aNode); - aParentIndex1 = getParentIndex(aNode, 0); - aParentIndex2 = getParentIndex(aNode, 2); - insertRows(aRow, 1, aParentIndex1); - dataChanged(aParentIndex1, aParentIndex2); + if (aObj.get() && (aObj->groupName() == ModelAPI_Folder::group())) { + aParent->update(); + rebuildDataTree(); + } + else { + aRow = aParent->nodeRow(aNode); + aParentIndex1 = getParentIndex(aNode, 0); + aParentIndex2 = getParentIndex(aNode, 2); + insertRows(aRow, 1, aParentIndex1); + dataChanged(aParentIndex1, aParentIndex2); + } } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { -- 2.39.2