Salome HOME
[CEA] Automatically expand tree in Object Browser 40645_AutoExpandOB 19/head
authorEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Thu, 1 Feb 2024 17:08:54 +0000 (17:08 +0000)
committerEkaterina Sukhareva <ekaterina.sukhareva@opencascade.com>
Wed, 7 Feb 2024 10:00:23 +0000 (10:00 +0000)
src/LightApp/LightApp_Application.cxx

index b1cb7e3bb7700699c931795ffa780757d9cd333a..d72e414f5a293eca0416426cc5a2a28f8b0bf946 100644 (file)
@@ -599,6 +599,25 @@ bool LightApp_Application::activateModule( const QString& modName )
     if ( objectBrowser()->root() != activeStudy()->root() )
       objectBrowser()->setRoot( activeStudy()->root() );
     updateObjectBrowser( true );
+
+    // expand SHAPERSTUDY data after leaving Shaper module
+    // bos #40645 [CEA] Automatically expand tree in Object Browser
+    if (actName == "Shaper") {
+      SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>(objectBrowser()->model());
+      LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
+      if (aModel && aStudy) {
+        DataObjectList aComps;
+        aStudy->root()->children(aComps);
+        for(auto aCompSUIT : aComps){
+          LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( aCompSUIT );
+          if ( aComp && aComp->componentDataType() == "SHAPERSTUDY") {
+            QModelIndex anIndex = aModel->index(aComp);
+            objectBrowser()->treeView()->expand(anIndex);
+            break;
+          }
+        }
+      }
+    }
   }
 
   if ( activeModule() ) activeModule()->updateModuleVisibilityState();