]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Improvements related with creation of "Gui states" object. Now it will always be...
authorasv <asv@opencascade.com>
Fri, 10 Mar 2006 09:28:44 +0000 (09:28 +0000)
committerasv <asv@opencascade.com>
Fri, 10 Mar 2006 09:28:44 +0000 (09:28 +0000)
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_Study.cxx
src/SalomeApp/SalomeApp_Study.h

index a1502a093fc29fdffbe367bcf6f2a0436314582a..9d17c32e6698289e45101a2b21f39c04f07036c6 100644 (file)
@@ -582,11 +582,12 @@ void SalomeApp_Application::onLoadScript( )
 /*!Private SLOT. On save GUI state.*/
 void SalomeApp_Application::onSaveGUIState()
 {
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
-  if ( !appStudy ) return;
-
-  SalomeApp_VisualState( this ).storeState();
-  updateObjectBrowser( false );
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if ( study ) {
+    SalomeApp_VisualState( this ).storeState();
+    updateSavePointDataObjects( study );
+    objectBrowser()->updateTree( study->root() );
+  }
 }
 
 /*!Gets file filter.
@@ -1000,6 +1001,23 @@ void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
   }
 }
 
+/*! utility function.  returns true if list view item that correspond to given SUIT_DataObject is open.
+ only first level items are traversed */
+bool isListViewItemOpen( QListView* lv, const SUIT_DataObject* dobj )
+{
+  if ( !lv || !dobj )
+    return false;
+
+  QListViewItem* item = lv->firstChild();
+  while ( item ) {
+    OB_ListItem* ob_item = dynamic_cast<OB_ListItem*>( item );
+    if ( ob_item && ob_item->dataObject() == dobj )
+      return ob_item->isOpen();
+    item = item->nextSibling();
+  }
+  return false;
+}
+
 /*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/
 void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
 {
@@ -1034,12 +1052,12 @@ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
   // case 4: everything already exists.. here may be a problem: we want "GUI states" root object
   // to be always the last one in the tree.  Here we check - if it is not the last one - remove and
   // re-create it.
-  //  if ( guiRootObj->nextBrother() ) {
-  //    bool isOpen = guiRootObj->isOpen();
-  //    delete guiRootObj;
-  //    guiRootObj = new SalomeApp_SavePointRootObject( study->root() );
-  //    guiRootObj->setOpen( isOpen );
-  //  }
+  bool isOpen( false );
+  if ( guiRootObj->nextBrother() ) {
+    isOpen = isListViewItemOpen( ob->listView(), guiRootObj );
+    delete guiRootObj;
+    guiRootObj = new SalomeApp_SavePointRootObject( study->root() );
+  }
 
   // store data objects in a map id-to-DataObject
   QMap<int,SalomeApp_SavePointObject*> mapDO;
@@ -1063,5 +1081,8 @@ void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
   // delete DataObjects that are still in the map -- their IDs were not found in data model
   for ( QMap<int,SalomeApp_SavePointObject*>::Iterator it = mapDO.begin(); it != mapDO.end(); ++it )
     delete it.data();
+
+  if ( isOpen ) // set open if we recreated guiRootObj and it was previously open..
+    guiRootObj->setOpen( true );
 }
 
index 36960f24938f6f07e88cfdf08ce08e747499b4b4..e8ba1d4b40ac4b172d0f1a2b1c17c1b789c911af 100644 (file)
@@ -69,6 +69,7 @@ public:
   static QString                      defaultEngineIOR();
 
   SUIT_ViewManager*                   newViewManager(const QString&);
+  void                                updateSavePointDataObjects( SalomeApp_Study* );
 
 public slots:
   virtual bool                        onOpenDoc( const QString& );
@@ -91,7 +92,6 @@ protected:
 
   virtual void                        createPreferences( LightApp_Preferences* );
   virtual void                        updateDesktopTitle();
-  void                                updateSavePointDataObjects( SalomeApp_Study* );
 
 private slots:
   void                                onDeleteInvalidReferences();
index 3a41ac01a8d2a16f9333ef55ae886d03b9846caf..be3e37d1160b975e9deceee2ed022a48bbb8aa01 100644 (file)
@@ -736,3 +736,15 @@ std::string SalomeApp_Study::getVisualComponentName()
   return "Interface Applicative";
 }
 
+//================================================================
+// Function : updateModelRoot
+/*! Purpose : slot called on change of a root of a data model. redefined from CAM_Study*/
+//================================================================
+void SalomeApp_Study::updateModelRoot( const CAM_DataModel* dm )
+{
+  LightApp_Study::updateModelRoot( dm );
+
+  // calling updateSavePointDataObjects in order to set correct order of "Gui states" object
+  // it must always be the last one.
+  ((SalomeApp_Application*)application())->updateSavePointDataObjects( this );
+}
index b3edd25641592bdad3a84fef09b761eec294f5e2..9034b13338165c4baa06da46ec3840e8c231b574 100644 (file)
@@ -89,6 +89,9 @@ protected:
   virtual bool        openDataModel( const QString&, CAM_DataModel* );
   void                setStudyDS(const _PTR(Study)& s );
 
+protected slots:
+  virtual void        updateModelRoot( const CAM_DataModel* );
+
 private:
   QString             newStudyName() const;