out.clear();
for ( QList<CAM_Module*>::const_iterator it = myModules.begin();
- it != myModules.end(); ++it )
+ it != myModules.end(); ++it )
out.append( *it );
}
if ( loaded )
{
for ( QList<CAM_Module*>::const_iterator it = myModules.begin();
- it != myModules.end(); ++it )
- lst.append( (*it)->moduleName() );
+ it != myModules.end(); ++it )
+ lst.append( (*it)->moduleName() );
}
else
{
for ( ModuleInfoList::const_iterator it = myInfoList.begin();
- it != myInfoList.end(); ++it )
- lst.append( (*it).title );
+ it != myInfoList.end(); ++it )
+ lst.append( (*it).title );
}
}
moduleAdded( mod );
}
+/*!
+ \brief returns true if module is accessible for the current application.
+ If module is a singleton and current session has more then one application
+ then this module can't be accessible in this one.
+ */
+bool CAM_Application::isModuleAccessible(const QString& theModName) const
+{
+ for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
+ {
+ if ((*it).name == theModName) {
+ return isModuleAccessible(it);
+ }
+ }
+ return true;
+}
+bool CAM_Application::isModuleAccessible(const ModuleInfoList::const_iterator& theIt) const
+{
+ int aAppsNb = SUIT_Session::session()->applications().size();
+ if ((*theIt).isSingleton && (aAppsNb > 1))
+ return false;
+ return true;
+}
+
/*!
\brief Load modules from the modules information list.
{
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
{
+ if (!isModuleAccessible((*it).name)) {
+ continue;
+ }
CAM_Module* mod = loadModule( (*it).title );
if ( mod )
addModule( mod );
else {
QString wrn = tr( "Can not load module %1" ).arg( (*it).title );
if ( desktop() && desktop()->isVisible() )
- SUIT_MessageBox::critical( desktop(), tr( "Loading modules" ), wrn );
+ SUIT_MessageBox::critical( desktop(), tr( "Loading modules" ), wrn );
else
- qWarning( qPrintable( wrn ) );
+ qWarning( qPrintable( wrn ) );
}
}
}
else
modLibrary = modName;
+ bool aIsSingleton = resMgr->booleanValue(*it, "singleton", false);
+
ModuleInfo inf;
inf.name = modName;
inf.title = modTitle;
inf.internal = modLibrary;
inf.icon = modIcon;
+ inf.isSingleton = aIsSingleton;
myInfoList.append( inf );
}
virtual void createEmptyStudy();
+ virtual bool isModuleAccessible(const QString&) const;
+
protected:
virtual SUIT_Study* createNewStudy();
virtual void updateCommandsStatus();
QString moduleLibrary( const QString&, const bool = true ) const;
private:
- void readModuleList();
+ typedef struct { QString name, title, internal, icon; bool isSingleton; } ModuleInfo;
+ typedef QList<ModuleInfo> ModuleInfoList;
private:
- typedef struct { QString name, title, internal, icon; } ModuleInfo;
- typedef QList<ModuleInfo> ModuleInfoList;
+ void readModuleList();
+ bool isModuleAccessible(const ModuleInfoList::const_iterator&) const;
private:
CAM_Module* myModule; //!< active module
static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
registerAction( MRUId, mru );
-
+
// default icon for neutral point ('SALOME' module)
QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
if ( defIcon.isNull() )
defIcon = QPixmap( imageEmptyIcon );
-
+
//! default icon for any module
QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
-
+
QStringList modList;
modules( modList, false );
-
+
if ( modList.count() > 1 )
- {
- LightApp_ModuleAction* moduleAction =
- new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
-
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
-
- const int iconSize = 20;
-
- QStringList::Iterator it;
- for ( it = modList.begin(); it != modList.end(); ++it )
{
- if ( !isLibExists( *it ) )
- continue;
-
- QString iconName;
- if ( iconMap.contains( *it ) )
- iconName = iconMap[*it];
-
- QString modName = moduleName( *it );
-
- QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
- if ( icon.isNull() )
- {
- icon = modIcon;
- INFOS ( "****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData() << " not found. Using the default one." << std::endl
- << "****************************************************************" << std::endl );
- }
-
- icon = Qtx::scaleIcon( icon, iconSize );
-
- moduleAction->insertModule( *it, icon );
+ LightApp_ModuleAction* moduleAction =
+ new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
+
+ QMap<QString, QString> iconMap;
+ moduleIconNames( iconMap );
+
+ const int iconSize = 20;
+
+ QStringList::Iterator it;
+ for ( it = modList.begin(); it != modList.end(); ++it )
+ {
+ if ( !isLibExists( *it ) )
+ continue;
+ QString modName = moduleName( *it );
+
+ if (!isModuleAccessible(modName))
+ continue;
+
+ QString iconName;
+ if ( iconMap.contains( *it ) )
+ iconName = iconMap[*it];
+
+ QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
+ if ( icon.isNull() )
+ {
+ icon = modIcon;
+ INFOS ( "****************************************************************" << std::endl
+ << "* Icon for " << (*it).toLatin1().constData()
+ << " not found. Using the default one." << std::endl
+ << "****************************************************************" << std::endl );
+ }
+
+ icon = Qtx::scaleIcon( icon, iconSize );
+
+ moduleAction->insertModule( *it, icon );
+ }
+
+
+ connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
+ this, SLOT( onModuleActivation( const QString& ) ) );
+ registerAction( ModulesListId, moduleAction );
}
-
- connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ), this, SLOT( onModuleActivation( const QString& ) ) );
- registerAction( ModulesListId, moduleAction );
- }
-
// New window
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );