From: Ekaterina Sukhareva Date: Thu, 1 Feb 2024 11:36:35 +0000 (+0000) Subject: [CEA] Automatically expand tree in Object Browser X-Git-Tag: V9_13_0a1~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2F40645_AutoExpandOB;p=modules%2Fshaper.git [CEA] Automatically expand tree in Object Browser --- diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 93883f604..c615673a7 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include #include @@ -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); diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 16b4997ff..7f110ccd2 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -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; }