]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix some observations.
authorrnv <rnv@opencascade.com>
Thu, 11 Dec 2008 12:53:14 +0000 (12:53 +0000)
committerrnv <rnv@opencascade.com>
Thu, 11 Dec 2008 12:53:14 +0000 (12:53 +0000)
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_NoteBookDlg.cxx
src/SalomeApp/SalomeApp_NoteBookDlg.h

index 412967f839012b43a653b75930cafcbf3efaf74f..574f271b417cf583a7dfe53d9c798d4a4b5145cc 100644 (file)
@@ -136,10 +136,11 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
 
 /*!Constructor.*/
 SalomeApp_Application::SalomeApp_Application()
-: LightApp_Application()
+  : LightApp_Application()
 {
   connect( desktop(), SIGNAL( message( const QString& ) ),
           this,      SLOT( onDesktopMessage( const QString& ) ) );
+  setNoteBook(0);
 }
 
 /*!Destructor.
@@ -473,8 +474,9 @@ void SalomeApp_Application::onCloseDoc( bool ask )
 
     }
   }
-
   LightApp_Application::onCloseDoc( ask );
+  if(myNoteBook && myNoteBook->isVisible())
+     myNoteBook->hide();
 }
 
 /*!Sets enable or disable some actions on selection changed.*/
@@ -720,8 +722,13 @@ void SalomeApp_Application::onNoteBook()
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
   if ( appStudy ) {
     _PTR(Study) aStudy = appStudy->studyDS();
-    SalomeApp_NoteBookDlg *aDlg = new SalomeApp_NoteBookDlg(desktop(),aStudy);
-    aDlg->show();
+    if(!myNoteBook) {
+      myNoteBook = new SalomeApp_NoteBookDlg(desktop(),aStudy);
+    }
+    else if(!myNoteBook->isVisible()){
+      myNoteBook->Init(aStudy);
+    }
+    myNoteBook->show();
   }
 }
 
@@ -1448,3 +1455,15 @@ void SalomeApp_Application::objectBrowserColumnsVisibility()
                                                                                   QString().sprintf( "visibility_column_%d", i-1 ), 
                                                                                   true )) );
 }
+
+/*! Set SalomeApp_NoteBookDlg pointer */
+void SalomeApp_Application::setNoteBook(SalomeApp_NoteBookDlg* theNoteBook){
+  myNoteBook = theNoteBook;
+}
+
+/*! Return SalomeApp_NoteBookDlg pointer */
+SalomeApp_NoteBookDlg* SalomeApp_Application::getNoteBook() const
+{
+  return myNoteBook;
+}
+
index 6ae8220e0dd2958887769fbcb2624efc2fe97ba0..47cd2badb0d076fe2ebf33ba2a828ba174ec11b8 100644 (file)
@@ -41,6 +41,7 @@
 
 class LightApp_Preferences;
 class SalomeApp_Study;
+class SalomeApp_NoteBookDlg;
 class SUIT_DataObject;
 
 class SALOME_LifeCycleCORBA;
@@ -95,6 +96,9 @@ public:
   virtual bool                        isPossibleToClose( bool& );
 
   virtual bool                        useStudy( const QString& );
+  
+  virtual void                        setNoteBook(SalomeApp_NoteBookDlg* theNoteBook);
+  virtual SalomeApp_NoteBookDlg*      getNoteBook() const;
 
 public slots:
   virtual void                        onLoadDoc();
@@ -149,6 +153,9 @@ private slots:
   void                                onCatalogGen();
   void                                onRegDisplay();
   void                                onOpenWith();
+
+ private:
+  SalomeApp_NoteBookDlg*             myNoteBook;
 };
 
 #ifdef WIN32
index 0deb518fc1207d4d6d48a11f4d80cbe458e49379..dc9ce5587ca1dbcfc98febb04c20fa81c62b15b8 100644 (file)
@@ -674,7 +674,6 @@ SalomeApp_NoteBookDlg::SalomeApp_NoteBookDlg(QWidget * parent, _PTR(Study) theSt
   myStudy(theStudy)
 {
   setModal(false);
-  setAttribute( Qt::WA_DeleteOnClose);
   setObjectName("SalomeApp_NoteBookDlg");
   setWindowTitle(tr("NOTEBOOK_TITLE"));
   QGridLayout* aLayout = new QGridLayout(this);
@@ -749,6 +748,18 @@ SalomeApp_NoteBookDlg::SalomeApp_NoteBookDlg(QWidget * parent, _PTR(Study) theSt
 SalomeApp_NoteBookDlg::~SalomeApp_NoteBookDlg(){}
 
 
+//============================================================================
+/*! Function : Init()
+ *  Purpose  : init variable table
+ */
+//============================================================================
+void SalomeApp_NoteBookDlg::Init(_PTR(Study) theStudy){
+  if(myStudy!= theStudy)
+    myStudy = theStudy;
+  myTable->Init(myStudy);
+}
+
+
 //============================================================================
 /*! Function : onOK
  *  Purpose  : [slot]
@@ -982,7 +993,7 @@ bool SalomeApp_NoteBookDlg::updateStudy()
   if( SalomeApp_Study* newStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
   {
     myStudy = newStudy->studyDS();
-    myTable->Init( myStudy );
+    myTable->Init(myStudy);
     if(isStudySaved) {
       newStudy->markAsSavedIn(aStudyName);
     }
@@ -1007,13 +1018,21 @@ void SalomeApp_NoteBookDlg::clearStudy()
   QList<SUIT_Application*> aList = SUIT_Session::session()->applications();
   int anIndex = aList.indexOf( app );
 
-  if( anIndex > 0 )
+
+  // Disconnect dialog from application desktop in case if:
+  // 1) Application is not the first application in the session        
+  // 2) Application is the first application in session but not the only.
+  bool changeDesktop = ((anIndex > 0) || (anIndex == 0 && aList.count() > 1));
+
+  if( changeDesktop )
     setParent( 0 );
 
   app->onCloseDoc( false );
-
+  
   if( anIndex > 0 && anIndex < aList.count() )
     app = dynamic_cast<SalomeApp_Application*>( aList[ anIndex - 1 ] );
+  else if(anIndex == 0 && aList.count() > 1)
+    app = dynamic_cast<SalomeApp_Application*>( aList[ 1 ] );
 
   if( !app )
     return;
@@ -1021,8 +1040,9 @@ void SalomeApp_NoteBookDlg::clearStudy()
   app->onNewDoc();
 
   app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
-  if( anIndex > 0 && app ) {
+  if( changeDesktop && app ) {
     setParent( app->desktop(), Qt::Dialog );
-    show();
+    app->setNoteBook(this);
   }
+  show();
 }
index 6afd66de5e23e76d7c900d73ebc4b52d2bcad06f..c4a7994af1e3dc7baf9b91415a1f5356bd9f7475 100644 (file)
@@ -140,6 +140,8 @@ class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog
  public:
   SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy);
   virtual ~SalomeApp_NoteBookDlg();
+
+  void Init(_PTR(Study) theStudy);
   
  public slots:
    void onOK();