From 8e6c087698b0924a7b4b4f515141e52f80520ac2 Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 2 Apr 2010 08:55:41 +0000 Subject: [PATCH] GUITHARE DIAGRAMS: LignApp application with two light modules. Problem: Object browser is empty after opening existing document Decision: 1) --autoload parameter is added. If it is specified myAutoLoad of CAM_Application is equal to TRUE and all modules are loaded when application is created. 2) LightApp_Application::onStudyOpened() method is modified. aModule->connectToStudy() is called for each module if myAutoLoad is true. This allow updating object browser by each module --- src/CAM/CAM_Application.cxx | 16 ++++++++++++++-- src/CAM/CAM_Application.h | 2 ++ src/LightApp/LightApp_Application.cxx | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 7eef172f8..72bcad18a 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -512,8 +512,9 @@ QString CAM_Application::moduleLibrary( const QString& title, const bool full ) QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) { - if ( (*it).title == title ) - res = (*it).internal; + ModuleInfo anInfo = *it; + if ( anInfo.title == title ) + res = anInfo.internal; } if ( !res.isEmpty() && full ) res = SUIT_Tools::library( res ); @@ -576,6 +577,9 @@ void CAM_Application::readModuleList() break; } + if ( args.indexOf( "--autoload" ) != -1 ) + myAutoLoad = true; + modList.clear(); QStringList mods = modules.split( QRegExp( "[:|,\\s]" ), QString::SkipEmptyParts ); for ( int i = 0; i < mods.count(); i++ ) { @@ -675,3 +679,11 @@ void CAM_Application::createEmptyStudy() /*SUIT_Study* study = */activeStudy(); STD_Application::createEmptyStudy(); } + +/*! + \brief Gets value of myAutoLoad flag +*/ +bool CAM_Application::autoLoad() const +{ + return myAutoLoad; +} diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index b79be8c38..53aa04ccc 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -78,6 +78,8 @@ protected: QString moduleLibrary( const QString&, const bool = true ) const; + bool autoLoad() const; + private: void readModuleList(); diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index bbeb04063..757449bc3 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1419,7 +1419,22 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) if ( objectBrowser() ) objectBrowser()->setRoot( aRoot ); - activateModule( defaultModule() ); + QString aDefModule = defaultModule(); + + if ( autoLoad() ) + { + LightApp_Application* anApp = this; + CAM_Application::ModuleList aModules = anApp->modules(); + CAM_Application::ModuleList::iterator anIter; + for ( anIter = aModules.begin(); anIter != aModules.end(); ++anIter ) + { + CAM_Module* aModule = *anIter; + if ( aModule && aModule->name() != aDefModule ) + aModule->connectToStudy( (LightApp_Study*)theStudy ); + } + } + + activateModule( aDefModule ); if ( objectBrowser() ) objectBrowser()->openLevels(); -- 2.39.2