]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[CEA] Automatically expand tree in Object Browser 40645_AutoExpandOB 42/head
authorEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Thu, 1 Feb 2024 11:36:35 +0000 (11:36 +0000)
committerEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Mon, 26 Feb 2024 09:02:39 +0000 (09:02 +0000)
src/SHAPERGUI/SHAPERGUI.cpp
src/XGUI/XGUI_DataModel.cpp

index 93883f60436b55fcd5253ad15f82a6eae570b062..c615673a7d83b711bdc3d7ba972ab7829b3b238f 100644 (file)
@@ -28,6 +28,7 @@
 #include <XGUI_ContextMenuMgr.h>
 #include <XGUI_ObjectsBrowser.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_DataModel.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_MenuMgr.h>
 #include <XGUI_FacesPanel.h>
@@ -39,6 +40,7 @@
 #include <ModuleBase_Preferences.h>
 #include <ModuleBase_ActionInfo.h>
 #include <ModuleBase_IModule.h>
+#include <ModuleBase_ITreeNode.h>
 
 #include <ModelAPI_Tools.h>
 
@@ -99,6 +101,7 @@ SHAPERGUI_EXPORT char* getModuleVersion()
 
 static const QString ToolbarsSection("SHAPER_Toolbars");
 static const QString FreeCommandsParam("OutOFToolbars");
+static const std::string PARTROOT_NODE_NAME = "PartRoot";
 
 
 /**
@@ -329,7 +332,26 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
       myIsOpened = false;
     }
     else
+    {
       myWorkshop->updateCommandStatus();
+    }
+
+    //bos #40645 [CEA] Automatically expand tree in Object Browser
+    XGUI_DataTree* aTreeView = myWorkshop->objectBrowser()->treeView();
+    XGUI_DataModel* aDataModel = myWorkshop->objectBrowser()->dataModel();
+    QModelIndex aRootIdx = aDataModel->documentRootIndex(ModelAPI_Session::get()->moduleDocument());
+    int aNbChild = aDataModel->rowCount(aRootIdx);
+    for (int i = 0; i < aNbChild; i++)
+    {
+      QModelIndex aIdx = aDataModel->index(i, 0, aRootIdx);
+      ModuleBase_ITreeNode* aNode = (ModuleBase_ITreeNode*)aIdx.internalPointer();
+      std::string aType = aNode->type();
+      if(aType == PARTROOT_NODE_NAME)
+      {
+        if(!aTreeView->isExpanded(aIdx))
+          aTreeView->setExpanded(aIdx, true);
+      }
+    }
   }
   myIsEditEnabled = getApp()->isEditEnabled();
   getApp()->setEditEnabled(false);
index 16b4997ff20e4d244250620147419016f4d0ee97..7f110ccd2c98e27c8ef5721551a0c883540ab243 100644 (file)
@@ -366,6 +366,16 @@ bool XGUI_DataModel::insertRows(int theRow, int theCount, const QModelIndex& the
 {
   beginInsertRows(theParent, theRow, theRow + theCount - 1);
   endInsertRows();
+  
+  //bos #40645 [CEA] Automatically expand tree in Object Browser
+  if (myWorkshop->objectBrowser()) 
+  {
+    XGUI_DataTree* aTreeView = myWorkshop->objectBrowser()->treeView();
+    if(!aTreeView->isExpanded(theParent))
+    {
+      aTreeView->setExpanded(theParent, true);
+    }
+  }
   return true;
 }