From: vsr Date: Thu, 15 Mar 2012 09:19:04 +0000 (+0000) Subject: Move onDesktopMessage() function to the LightApp level to be available in "light... X-Git-Tag: V6_5_0a1~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7cdca26be62d8bed15b1ee85c71e2b0001706576;p=modules%2Fgui.git Move onDesktopMessage() function to the LightApp level to be available in "light" modules. Add notification function message() to the LightApp_Module class. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4e5c0e46c..79ed95e1f 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -3384,6 +3384,19 @@ void LightApp_Application::createEmptyStudy() } } +/*!Set desktop:*/ +void LightApp_Application::setDesktop( SUIT_Desktop* desk ) +{ + SUIT_Desktop* prev = desktop(); + + CAM_Application::setDesktop( desk ); + + if ( desk ) { + connect( desk, SIGNAL( message( const QString& ) ), + this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection ); + } +} + /*! Activates module \param mod - module to be activated @@ -3917,3 +3930,43 @@ bool LightApp_Application::renameAllowed( const QString& /*entry*/) const { bool LightApp_Application::renameObject( const QString& entry, const QString& ) { return false; } + +/*! Process standard messages from desktop */ +void LightApp_Application::onDesktopMessage( const QString& message ) +{ + const QString sectionSeparator = "/"; + + if ( message.toLower() == "updateobjectbrowser" || + message.toLower() == "updateobjbrowser" ) { + // update object browser + updateObjectBrowser(); + } + else { + QStringList data = message.split( sectionSeparator ); + if ( data.count() > 1 ) { + QString msgType = data[0].trimmed(); + LightApp_Module* sMod = 0; + CAM_Module* mod = module( msgType ); + if ( !mod ) + mod = module( moduleTitle( msgType ) ); + if ( mod && mod->inherits( "LightApp_Module" ) ) + sMod = (LightApp_Module*)mod; + + if ( msgType.toLower() == "preferences" ) { + // requested preferences change: should be given as "preferences/
//" + // for example "preferences/Study/multi_file_dump/true" + if ( data.count() > 3 ) { + QString section = data[1].trimmed(); + QString param = data[2].trimmed(); + QString value = QStringList( data.mid(3) ).join( sectionSeparator ); + resourceMgr()->setValue( section, param, value ); + } + } + else if ( sMod ) { + // received message for the module + QString msg = QStringList( data.mid(1) ).join( sectionSeparator ); + sMod->message( msg ); + } + } + } +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 1d552f406..bafc75f3a 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -142,6 +142,8 @@ public: virtual void createEmptyStudy(); + virtual void setDesktop( SUIT_Desktop* ); + SUIT_Accel* accel() const; void setDefaultStudyName( const QString& theName ); @@ -234,6 +236,8 @@ protected slots: void onStylePreferences(); void onFullScreen(); + virtual void onDesktopMessage( const QString& ); + private slots: void onSelection(); void onRefresh(); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 28cbe5c36..c83d1fa49 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -298,6 +298,11 @@ void LightApp_Module::preferencesChanged( const QString&, const QString& ) { } +/*!NOT IMPLEMENTED*/ +void LightApp_Module::message( const QString& ) +{ +} + /*!Gets application.*/ LightApp_Application* LightApp_Module::getApp() const { diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 5372fccd8..3e9659ee6 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -87,6 +87,7 @@ public: virtual void selectionChanged(); virtual void preferencesChanged( const QString&, const QString& ); + virtual void message( const QString& ); virtual void studyActivated() {}; diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 361baba3b..df0bf8452 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -159,10 +159,8 @@ extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication() SalomeApp_Application::SalomeApp_Application() : LightApp_Application() { - connect( desktop(), SIGNAL( message( const QString& ) ), - this, SLOT( onDesktopMessage( const QString& ) ) ); connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), - this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); + this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); setNoteBook(0); } @@ -354,15 +352,10 @@ void SalomeApp_Application::createActions() void SalomeApp_Application::setDesktop( SUIT_Desktop* desk ) { SUIT_Desktop* prev = desktop(); - if ( prev == desk ) - return; LightApp_Application::setDesktop( desk ); - if ( desk != 0 ) { - connect( desk, SIGNAL( message( const QString& ) ), - this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection); - + if ( desk ) { connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); } @@ -1594,24 +1587,6 @@ bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj) return false; } -/*! Process standard messages from desktop */ -void SalomeApp_Application::onDesktopMessage( const QString& message ) -{ - if ( message.toLower() == "updateobjectbrowser" || - message.toLower() == "updateobjbrowser" ) { - // update object browser - updateObjectBrowser(); - } - if ( message.toLower().startsWith( "preferences" ) ) { - // preferences changed: should be given as "preferences:
::", - // for example "preferences:Study:multi_file_dump:true" - QStringList data = message.split( ":" ); - if ( data.count() > 3 ) { - resourceMgr()->setValue( data[1], data[2], data[3] ); - } - } -} - /*! Opens other study into active Study. If Study is empty - creates it. \param theName - name of study @@ -1744,7 +1719,8 @@ void SalomeApp_Application::onExtAction() /*! * Called when window activated */ -void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) { +void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) +{ SUIT_DataBrowser* anOB = objectBrowser(); if( !anOB ) return; @@ -1764,7 +1740,8 @@ void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow ) Update visibility state of given objects */ void SalomeApp_Application::updateVisibilityState( DataObjectList& theList, - SUIT_ViewModel* theViewModel ) { + SUIT_ViewModel* theViewModel ) +{ LightApp_Study* aStudy = dynamic_cast(activeStudy()); if(!theViewModel) @@ -1802,7 +1779,8 @@ void SalomeApp_Application::updateVisibilityState( DataObjectList& theList, /*! Called then view manager removed */ -void SalomeApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) { +void SalomeApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) +{ ViewManagerList lst; viewManagers(lst); if( lst.count() == 1) { // in case if closed last view window @@ -1817,7 +1795,8 @@ void SalomeApp_Application::onViewManagerRemoved( SUIT_ViewManager* ) { \param entry entry of the object \brief Return \c true if object can be renamed */ -bool SalomeApp_Application::renameAllowed( const QString& entry) const { +bool SalomeApp_Application::renameAllowed( const QString& entry) const +{ return entry.startsWith( tr( "SAVE_POINT_DEF_NAME") ); } @@ -1827,8 +1806,8 @@ bool SalomeApp_Application::renameAllowed( const QString& entry) const { \param name new name of the object \brief Return \c true if rename operation finished successfully, \c false otherwise. */ -bool SalomeApp_Application::renameObject( const QString& entry, const QString& name ) { - +bool SalomeApp_Application::renameObject( const QString& entry, const QString& name ) +{ SalomeApp_Study* aStudy = dynamic_cast( activeStudy() ); int savePoint = ::getSelectedSavePoint( selectionMgr() ); diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 711333875..71ae9dbfb 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -130,7 +130,6 @@ protected slots: void onStudyCreated( SUIT_Study* ); void onStudySaved( SUIT_Study* ); void onStudyOpened( SUIT_Study* ); - void onDesktopMessage( const QString& ); void onStudyClosed( SUIT_Study* ); void onViewManagerRemoved( SUIT_ViewManager* );