{
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it )
{
- if (!isModuleAccessible((*it).name)) {
+ if ( !isModuleAccessible( (*it).title ) ) {
continue;
}
CAM_Module* mod = loadModule( (*it).title );
return 0;
}
+ if ( !isModuleAccessible( modName ) ) {
+ qWarning( qPrintable( tr( "Module \"%1\" cannot be loaded in this application." ).arg( modName ) ) );
+ return 0;
+ }
+
QString libName = moduleLibrary( modName );
if ( libName.isEmpty() )
{
\brief Returns \c true if module is accessible for the current application.
Singleton module can be loaded only in one application object. In other application
objects this module will be unavailable.
+ \param title module title (user name)
+ \return \c true if module is accessible (can be loaded) or \c false otherwise
*/
-bool CAM_Application::isModuleAccessible( const QString& name ) const
+bool CAM_Application::isModuleAccessible( const QString& title ) const
{
bool found = false;
bool blocked = false;
- int aAppsNb = SUIT_Session::session()->applications().count();
+
+ QStringList somewhereLoaded;
+ QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
+ foreach( SUIT_Application* app, apps ) {
+ CAM_Application* camApp = dynamic_cast<CAM_Application*>( app );
+ if ( !camApp ) continue;
+ QStringList loaded;
+ camApp->modules( loaded, true );
+ foreach( QString lm, loaded ) {
+ if ( !somewhereLoaded.contains( lm ) ) somewhereLoaded << lm;
+ }
+ }
+
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && !found; ++it )
{
- found = (*it).name == name;
- if ( found ) blocked = (*it).isSingleton && (aAppsNb > 1);
+ found = (*it).title == title;
+ blocked = (*it).isSingleton && somewhereLoaded.contains((*it).title);
}
return found && !blocked;
}
QStringList modList;
modules( modList, false );
-
+
if ( modList.count() > 1 )
{
LightApp_ModuleAction* moduleAction =
QString modName = moduleName( *it );
- if (!isModuleAccessible(modName))
+ if ( !isModuleAccessible( *it ) )
continue;
QString iconName;
void LightApp_Application::updateModuleActions()
{
QString modName;
- if ( activeModule() )
+ if ( activeModule() ) {
modName = activeModule()->moduleName();
+ if ( !isModuleAccessible( modName ) ) {
+ QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
+ foreach( SUIT_Application* app, apps ) {
+ LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
+ if ( lapp && lapp != this )
+ lapp->removeModuleAction( modName );
+ }
+ }
+ }
LightApp_ModuleAction* moduleAction =
qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
moduleAction->setActiveModule( modName );
}
+void LightApp_Application::removeModuleAction( const QString& modName )
+{
+ LightApp_ModuleAction* moduleAction =
+ qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
+ if ( moduleAction )
+ moduleAction->removeModule( modName );
+}
+
/*!
Gets current windows.
\param winMap - output current windows map.