Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_DocumentDataModel.cpp
index 7962105ca1f2221b7b8e33474741e29ae6259ed6..2c4470cce95b8d88c0fb3c7dc4d5758499bbbd33 100644 (file)
@@ -92,12 +92,12 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
       if (aUpdMsg->group().compare(PARTS_GROUP) == 0) { // Updsate only Parts group
         int aStart = myPartModels.size();
         removeSubModel(myPartModels.size() - 1);
-        removeRow(aStart - 1, partFolderNode());
+        removeRow(aStart, partFolderNode());
       } else { // Update top groups (other except parts
         QModelIndex aIndex = myModel->findGroup(aUpdMsg->group());
         int aStart = myModel->rowCount(aIndex);
         aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
-        removeRow(aStart - 1, aIndex);
+        removeRow(aStart, aIndex);
       }
     } else {
       XGUI_PartModel* aPartModel = 0;
@@ -112,7 +112,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
         QModelIndex aIndex = aPartModel->findGroup(aUpdMsg->group());
         int aStart = aPartModel->rowCount(aIndex);
         aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
-        removeRow(aStart - 1, aIndex);
+        removeRow(aStart, aIndex);
       }
     }
 
@@ -431,7 +431,15 @@ bool XGUI_DocumentDataModel::activatedIndex(const QModelIndex& theIndex)
     // if this is root node (Part item index)
     if (!aIndex->parent().isValid()) {
       if (myActivePart) myActivePart->setItemsColor(PASSIVE_COLOR);
-      myActivePart = (myActivePart == aModel)? 0 : (XGUI_PartModel*)aModel;
+
+      if (myActivePart == aModel) {
+        myActivePart = 0;
+        myActivePartIndex = QModelIndex();
+      } else {
+        myActivePart = (XGUI_PartModel*)aModel;
+        myActivePartIndex = theIndex;
+      }
+
       if (myActivePart) {
         myActivePart->setItemsColor(ACTIVE_COLOR);
         myModel->setItemsColor(PASSIVE_COLOR);
@@ -448,4 +456,12 @@ FeaturePtr XGUI_DocumentDataModel::activePart() const
   if (myActivePart) 
     return myActivePart->part();
   return FeaturePtr();
-}
\ No newline at end of file
+}
+
+void XGUI_DocumentDataModel::deactivatePart() 
+{ 
+  if (myActivePart) 
+    myActivePart->setItemsColor(PASSIVE_COLOR);
+  myActivePart = 0;
+  myModel->setItemsColor(ACTIVE_COLOR);
+}