-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
{
for ( ModuleInfoList::const_iterator it = myInfoList.begin();
it != myInfoList.end(); ++it )
- lst.append( (*it).title );
+ if ( (*it).status != stNoGui )
+ lst.append( (*it).title );
}
}
{
if ( !myModule->deactivateModule( activeStudy() ) )
{
- // ....
- }
+ // ???
+ }
+ moduleDeactivated( myModule );
}
myModule = mod;
- if ( myModule ){
+ if ( myModule )
+ {
// Connect the module to the active study
myModule->connectToStudy( dynamic_cast<CAM_Study*>( activeStudy() ) );
if ( !myModule->activateModule( activeStudy() ) )
{
}
+/*!
+ \brief Callback function, called when the module is just deactivated.
+
+ This virtual method can be re-implemented in the successors. Base implementation
+ does nothing.
+
+ \param mod module just deactivated
+*/
+void CAM_Application::moduleDeactivated( CAM_Module* /*mod*/ )
+{
+}
+
/*!
\brief Get module name by its title (user name).
\param title module title (user name)
/*!
\brief Get module icon name.
- \param name module name
+ \param name module name or title
\return module icon or null QString if module is not found
*/
QString CAM_Application::moduleIcon( const QString& name )
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it )
{
- if ( (*it).name == name )
+ if ( (*it).name == name || (*it).title == name )
res = (*it).icon;
}
return res;
}
+/*!
+ \brief Get module description.
+ \param name module name or title
+ \return module description or null QString if description is not provided in config file.
+*/
+QString CAM_Application::moduleDescription( const QString& name )
+{
+ QString res;
+ for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it )
+ {
+ if ( (*it).name == name || (*it).title == name )
+ res = tr((*it).description.toUtf8());
+ }
+ return res;
+}
+
/*!
\brief Get module library name by its title (user name).
- \param title module title (user name)
+ \param title module name or title
\param full if \c true, return full library name, otherwise return its internal name
\return module library name or null QString if module is not found
*/
-QString CAM_Application::moduleLibrary( const QString& title, const bool full )
+QString CAM_Application::moduleLibrary( const QString& name, const bool full )
{
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
{
- if ( (*it).title == title )
+ if ( (*it).name == name || (*it).title == name )
res = (*it).library;
}
if ( !res.isEmpty() && full )
return res;
}
+/*!
+ \brief Get displayer proxy for given module, by its title (user name).
+ \param name module name or title
+ \return name of module which provides displayer for requested module
+ */
+QString CAM_Application::moduleDisplayer( const QString& name )
+{
+ QString res;
+
+ if ( !name.isEmpty() )
+ {
+ for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
+ {
+ if ( (*it).title == name || (*it).name == name ) {
+ res = (*it).displayer;
+ if ( res.isEmpty() )
+ res = (*it).title;
+ }
+ }
+ }
+
+ return res;
+}
+
/*!
\brief Read modules information list
continue; // omit KERNEL and GUI modules
bool hasGui = resMgr->booleanValue( *it, "gui", true );
- if ( !hasGui )
- continue; // omit if module is explicitly declared as not having GUI
- QString modTitle = resMgr->stringValue( *it, "name", QString() );
- if ( modTitle.isEmpty() )
+ QString modTitle, modIcon, modLibrary, modDescription;
+
+ if ( hasGui )
{
- printf( "****************************************************************\n" );
- printf( " Warning: module %s is improperly configured!\n", qPrintable(*it) );
- printf( " Module %s will not be available in GUI mode!\n", qPrintable(*it) );
- printf( "****************************************************************\n" );
- continue;
- }
+ // if module has GUI, check that it is present
+ modTitle = resMgr->stringValue( *it, "name", QString() );
+ if ( modTitle.isEmpty() )
+ {
+ printf( "****************************************************************\n" );
+ printf( " Warning: module %s is improperly configured!\n", qPrintable(*it) );
+ printf( " Module %s will not be available in GUI mode!\n", qPrintable(*it) );
+ printf( "****************************************************************\n" );
+ continue;
+ }
- QString modIcon = resMgr->stringValue( *it, "icon", QString() );
+ modIcon = resMgr->stringValue( *it, "icon", QString() );
- QString modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed();
- if ( !modLibrary.isEmpty() )
- {
- modLibrary = SUIT_Tools::file( modLibrary.trimmed() );
+ modDescription = resMgr->stringValue( *it, "description", QString() );
+
+ modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed();
+ if ( !modLibrary.isEmpty() )
+ {
+ modLibrary = SUIT_Tools::file( modLibrary.trimmed() );
#if defined(WIN32)
- QString libExt = QString( "dll" );
+ QString libExt = QString( "dll" );
#elif defined(__APPLE__)
- QString libExt = QString( "dylib" );
+ QString libExt = QString( "dylib" );
#else
- QString libExt = QString( "so" );
+ QString libExt = QString( "so" );
#endif
- if ( SUIT_Tools::extension( modLibrary ).toLower() == libExt )
- modLibrary.truncate( modLibrary.length() - libExt.length() - 1 );
+ if ( SUIT_Tools::extension( modLibrary ).toLower() == libExt )
+ modLibrary.truncate( modLibrary.length() - libExt.length() - 1 );
#ifndef WIN32
- QString prefix = QString( "lib" );
- if ( modLibrary.startsWith( prefix ) )
- modLibrary.remove( 0, prefix.length() );
+ QString prefix = QString( "lib" );
+ if ( modLibrary.startsWith( prefix ) )
+ modLibrary.remove( 0, prefix.length() );
#endif
+ }
+ else
+ modLibrary = modName;
}
- else
- modLibrary = modName;
QString version = resMgr->stringValue( *it, "version", QString() );
+ QString modDisplayer = resMgr->stringValue( *it, "displayer", QString() );
+
ModuleInfo inf;
inf.name = modName;
inf.title = modTitle;
inf.status = hasGui ? stUnknown : stNoGui;
if ( hasGui ) inf.library = modLibrary;
inf.icon = modIcon;
+ inf.description = modDescription;
+ inf.displayer = modDisplayer;
inf.version = version;
myInfoList.append( inf );
}
for(int i = 0; i < myInfoList.size(); i++) {
ModuleShortInfo infoItem;
- infoItem.name = myInfoList.at(i).title;
+ infoItem.name = myInfoList.at(i).title.isEmpty() ? myInfoList.at(i).name : myInfoList.at(i).title;
infoItem.version = myInfoList.at(i).version;
info.append(infoItem);
}