Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / XGUI / XGUI_DataModel.cpp
index cc80025fb8a98e5f59e6a9504c813ba226f625b1..724553906cfc994de3f6dd259bc77b00613b3411 100644 (file)
@@ -149,8 +149,10 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
               }
             }
           }
-        } else
+        } else {
           rebuildDataTree();
+          break;
+        }
       }
     }
     // Deleted object event ***********************
@@ -230,6 +232,9 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
               break;
             }
           }
+        } else {
+          rebuildDataTree();
+          break;
         }
       }
     }
@@ -255,29 +260,33 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) {
     std::shared_ptr<ModelAPI_OrderUpdatedMessage> aUpdMsg =
         std::dynamic_pointer_cast<ModelAPI_OrderUpdatedMessage>(theMessage);
-    DocumentPtr aDoc = aUpdMsg->reordered()->document();
-    std::string aGroup = aUpdMsg->reordered()->group();
-
-    QModelIndex aParent;
-    int aStartId = 0;
-    if (aDoc == aRootDoc) {
-      // Update a group under root
-      if (aGroup == myXMLReader->rootType()) // Update objects under root
-        aStartId = foldersCount();
-      else // Update objects in folder under root 
-        aParent = createIndex(folderId(aGroup), 0, -1);
+    if (aUpdMsg->reordered().get()) {
+      DocumentPtr aDoc = aUpdMsg->reordered()->document();
+      std::string aGroup = aUpdMsg->reordered()->group();
+
+      QModelIndex aParent;
+      int aStartId = 0;
+      if (aDoc == aRootDoc) {
+        // Update a group under root
+        if (aGroup == myXMLReader->rootType()) // Update objects under root
+          aStartId = foldersCount();
+        else // Update objects in folder under root 
+          aParent = createIndex(folderId(aGroup), 0, -1);
+      } else {
+        // Update a sub-document
+        if (aGroup == myXMLReader->subType()) {
+          // Update sub-document root
+          aParent = findDocumentRootIndex(aDoc.get());
+          aStartId = foldersCount(aDoc.get());
+        } else 
+          // update folder in sub-document
+          aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+      }
+      int aChildNb = rowCount(aParent);
+      rebuildBranch(aStartId, aChildNb - aStartId, aParent);
     } else {
-      // Update a sub-document
-      if (aGroup == myXMLReader->subType()) {
-        // Update sub-document root
-        aParent = findDocumentRootIndex(aDoc.get());
-        aStartId = foldersCount(aDoc.get());
-      } else 
-        // update folder in sub-document
-        aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+      rebuildDataTree();
     }
-    int aChildNb = rowCount(aParent);
-    rebuildBranch(aStartId, aChildNb - aStartId, aParent);
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
     DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
     if (aDoc != aRootDoc) {
@@ -430,7 +439,8 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const
         {
           if (aObj->groupName() == ModelAPI_ResultParameter::group()) {
             ModelAPI_ResultParameter* aParam = dynamic_cast<ModelAPI_ResultParameter*>(aObj);
-            AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
+            AttributeDoublePtr aValueAttribute = 
+              aParam->data()->real(ModelAPI_ResultParameter::VALUE());
             QString aVal = QString::number(aValueAttribute->value());
             QString aTitle = QString(aObj->data()->name().c_str());
             return aTitle + " = " + aVal;
@@ -590,11 +600,13 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
           }
         } else {
           // Check for composite object
-          ModelAPI_CompositeFeature* aCompFeature = dynamic_cast<ModelAPI_CompositeFeature*>(aParentObj);
+          ModelAPI_CompositeFeature* aCompFeature = 
+            dynamic_cast<ModelAPI_CompositeFeature*>(aParentObj);
           if (aCompFeature) {
             aIndex = objectIndex(aCompFeature->subFeature(theRow));
           } else {
-            ModelAPI_ResultCompSolid* aCompRes = dynamic_cast<ModelAPI_ResultCompSolid*>(aParentObj);
+            ModelAPI_ResultCompSolid* aCompRes = 
+              dynamic_cast<ModelAPI_ResultCompSolid*>(aParentObj);
             if (aCompRes) 
               aIndex = objectIndex(aCompRes->subResult(theRow));
           }