From: rnv Date: Thu, 11 Dec 2008 12:53:14 +0000 (+0000) Subject: Fix some observations. X-Git-Tag: TG_DumpPython_Extension_4~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e05028a8802de70cb5e8e0286f66e2928c92680;p=modules%2Fgui.git Fix some observations. --- diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 412967f83..574f271b4 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -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( 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; +} + diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 6ae8220e0..47cd2badb 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -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 diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx index 0deb518fc..dc9ce5587 100644 --- a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx @@ -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( 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 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( aList[ anIndex - 1 ] ); + else if(anIndex == 0 && aList.count() > 1) + app = dynamic_cast( aList[ 1 ] ); if( !app ) return; @@ -1021,8 +1040,9 @@ void SalomeApp_NoteBookDlg::clearStudy() app->onNewDoc(); app = dynamic_cast( SUIT_Session::session()->activeApplication() ); - if( anIndex > 0 && app ) { + if( changeDesktop && app ) { setParent( app->desktop(), Qt::Dialog ); - show(); + app->setNoteBook(this); } + show(); } diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.h b/src/SalomeApp/SalomeApp_NoteBookDlg.h index 6afd66de5..c4a7994af 100644 --- a/src/SalomeApp/SalomeApp_NoteBookDlg.h +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.h @@ -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();