]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2690: Full update tree on deletion of a folder
authorvsv <vsv@opencascade.com>
Tue, 16 Oct 2018 12:32:00 +0000 (15:32 +0300)
committervsv <vsv@opencascade.com>
Tue, 16 Oct 2018 12:32:00 +0000 (15:32 +0300)
src/ModuleBase/ModuleBase_ITreeNode.h
src/XGUI/XGUI_DataModel.cpp

index c188dd97edad6a9d70deed276e20747decc60dd1..cef49758a23bc02fe4bc26c59943d222f697c483 100644 (file)
@@ -185,12 +185,13 @@ protected:
       int aIdx;
       int aCount = 0;
       int aSize = myChildren.size();
+      int aShift = 0;
       while (i < aSize) {
         aCount++;
         aNode = myChildren.at(i);
         aObject = aNode->object();
         if (aObject.get()) {
-          aIdx = aObject->document()->index(aObject, true);
+          aIdx = aObject->document()->index(aObject, true) + aShift;
           if (aIdx != i) {
             myChildren.removeAll(aNode);
             myChildren.insert(aIdx, aNode);
@@ -198,6 +199,8 @@ protected:
             continue;
           }
         }
+        else
+          aShift++;
         i++;
         // To avoid unlimited cycling
         if (aCount > aSize * aSize)
index 45354a917da4d425f7fd9600eb4ab2d3f2e8ba36..4ead852d1f57abf8763d666650c7ab24da804529 100644 (file)
@@ -88,8 +88,14 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
     const std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>& aMsgGroups =
       aUpdMsg->groups();
     std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator aIt;
-    for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++)
+    bool isRebuildTree = false;
+    for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++) {
+      if (aIt->second == ModelAPI_Folder::group())
+        isRebuildTree = true;
       QTreeNodesList aList = myRoot->objectsDeleted(aIt->first, aIt->second.c_str());
+    }
+    if (isRebuildTree)
+      myRoot->update();
     rebuildDataTree();
   }
   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {