From 2d2ae6aefef4d9ad31b08a0e8d94fb65e210f873 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 17 May 2007 14:18:51 +0000 Subject: [PATCH] Porting to Qt4 --- src/CAM/CAM.h | 16 +- src/CAM/CAM.pro | 42 ++ src/CAM/CAM_Application.cxx | 392 ++++++++++++------- src/CAM/CAM_Application.h | 39 +- src/CAM/CAM_DataModel.cxx | 154 +++++++- src/CAM/CAM_DataModel.h | 32 +- src/CAM/CAM_DataObject.cxx | 35 +- src/CAM/CAM_DataObject.h | 4 - src/CAM/CAM_Module.cxx | 743 +++++++++++++++++++++++++----------- src/CAM/CAM_Module.h | 55 +-- src/CAM/CAM_RootObject.cxx | 58 ++- src/CAM/CAM_RootObject.h | 8 - src/CAM/CAM_Study.cxx | 140 ++++--- src/CAM/CAM_Study.h | 22 +- src/CAM/Makefile.am | 4 +- 15 files changed, 1163 insertions(+), 581 deletions(-) create mode 100644 src/CAM/CAM.pro diff --git a/src/CAM/CAM.h b/src/CAM/CAM.h index 09cc3934d..1489c37b8 100755 --- a/src/CAM/CAM.h +++ b/src/CAM/CAM.h @@ -19,18 +19,14 @@ #ifndef CAM_H #define CAM_H -#if defined CAM_EXPORTS #if defined WIN32 -#define CAM_EXPORT __declspec( dllexport ) +# if defined CAM_EXPORTS +# define CAM_EXPORT __declspec( dllexport ) +# else +# define CAM_EXPORT __declspec( dllimport ) +# endif #else -#define CAM_EXPORT -#endif -#else -#if defined WIN32 -#define CAM_EXPORT __declspec( dllimport ) -#else -#define CAM_EXPORT -#endif +# define CAM_EXPORT #endif #if defined SOLARIS diff --git a/src/CAM/CAM.pro b/src/CAM/CAM.pro new file mode 100644 index 000000000..634461537 --- /dev/null +++ b/src/CAM/CAM.pro @@ -0,0 +1,42 @@ +TEMPLATE = lib +TARGET = CAM +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH += ../../include ../Qtx ../SUIT ../STD +LIBS += -L../../lib -lqtx -lsuit -lstd + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += CAM_EXPORTS + +HEADERS = CAM.h +HEADERS += CAM_Application.h +HEADERS += CAM_DataModel.h +HEADERS += CAM_DataObject.h +HEADERS += CAM_Module.h +HEADERS += CAM_RootObject.h +HEADERS += CAM_Study.h + +SOURCES = CAM_Application.cxx +SOURCES += CAM_DataModel.cxx +SOURCES += CAM_DataObject.cxx +SOURCES += CAM_Module.cxx +SOURCES += CAM_RootObject.cxx +SOURCES += CAM_Study.cxx + +TRANSLATIONS = resources/CAM_images.ts \ + resources/CAM_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm resources/*.xml resources/*.ini +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index cc2d1f703..db7bb1740 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -16,22 +16,20 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include "CAM_Application.h" #include "CAM_Study.h" #include "CAM_Module.h" #include +#include #include #include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #ifdef WIN32 #include @@ -39,31 +37,64 @@ #include #endif -/*!Create new instance of CAM_Application*/ +/*! + \brief Create new instance of CAM_Application. + \return new instance of CAM_Application class +*/ extern "C" CAM_EXPORT SUIT_Application* createApplication() { return new CAM_Application(); } -/*!Constructor. read module list. - * \param autoLoad - auto load flag. - */ +/*! + \class CAM_Application + \brief Introduces an application class which provides modular architecture. + + This class defines multi-modular application configuration and behaviour. + Each module (CAM_Module) can have own data model, document windows and + viewers, etc. + + An application provides all necessary functionality for modules management, + like + - loading of modules + - modules activation/deactivation + - etc +*/ + +/*! + \brief Constructor. + + Read modules list (from command line or from resource file). + If \a autoLoad parameter is \c true all the modules will be loaded + immediately after application starting, otherwise each module will + be loaded by demand (with activateModule()). + + \param autoLoad auto loading flag +*/ CAM_Application::CAM_Application( const bool autoLoad ) : STD_Application(), -myModule( 0 ), -myAutoLoad( autoLoad ) + myModule( 0 ), + myAutoLoad( autoLoad ) { readModuleList(); } -/*!Destructor. Do nothing.*/ +/*! + \brief Destructor. + + Does nothing currently. +*/ CAM_Application::~CAM_Application() { } -/*! Load modules, if \a myAutoLoad flag is true.\n - * Start application - call start() method from parent class. - */ +/*! + \brief Start an application. + + Load all modules, if "auto loading" flag has been set to \c true. + + \sa CAM_Application() +*/ void CAM_Application::start() { if ( myAutoLoad ) @@ -72,65 +103,87 @@ void CAM_Application::start() STD_Application::start(); } -/*!Get active module. - * \retval CAM_Module - active module. - */ +/*! + \brief Get active module. + \return active module or 0 if there are no any +*/ CAM_Module* CAM_Application::activeModule() const { return myModule; } -/*!Get module with name \a modName from modules list. - * \retval CAM_Module pointer - module. - */ +/*! + \brief Get the module with specified name. + \return module or 0 if not found +*/ CAM_Module* CAM_Application::module( const QString& modName ) const { CAM_Module* mod = 0; - for ( ModuleListIterator it( myModules ); it.current() && !mod; ++it ) - if ( it.current()->moduleName() == modName ) - mod = it.current(); + for ( QList::const_iterator it = myModules.begin(); + it != myModules.end() && !mod; ++it ) + if ( (*it)->moduleName() == modName ) + mod = *it; return mod; } -/*!Gets modules iterator.*/ -CAM_Application::ModuleListIterator CAM_Application::modules() const +/*! + \brief Get all loaded modules. + \return list of modules +*/ +CAM_Application::ModuleList CAM_Application::modules() const { - return ModuleListIterator( myModules ); + return myModules; } -/*!Gets modules list. - * \param out - output list of modules. - */ +/*! + \brief Get all loaded modules. + \param returning list of modules +*/ void CAM_Application::modules( CAM_Application::ModuleList& out ) const { - out.setAutoDelete( false ); out.clear(); - for ( ModuleListIterator it( myModules ); it.current(); ++it ) - out.append( it.current() ); + for ( QList::const_iterator it = myModules.begin(); + it != myModules.end(); ++it ) + out.append( *it ); } -/*!Gets list of names for modules.\n - * Get loaded modules names, if \a loaded is true, else \n - * get names from information list. - * \param lst - output list of names. - * \param loaded - boolean flag. - */ +/*! + \brief Get names of all modules. + + Get loaded modules names if \a loaded is \c true, + otherwise get all avaiable modules names. + + \param lst output list of modules names + \param loaded boolean flag, defines what modules names to return +*/ void CAM_Application::modules( QStringList& lst, const bool loaded ) const { lst.clear(); if ( loaded ) - for ( ModuleListIterator it( myModules ); it.current(); ++it ) - lst.append( it.current()->moduleName() ); + { + for ( QList::const_iterator it = myModules.begin(); + it != myModules.end(); ++it ) + lst.append( (*it)->moduleName() ); + } else - for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) + { + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); + it != myInfoList.end(); ++it ) lst.append( (*it).title ); + } } -/*!Adding module \a mod to list. - *\param mod - module. - */ +/*! + \brief Add module \a mod to the modules list. + + Performes module initialization. Does nothing if the module + is already added. + + \param mod module being added + \sa initialize() +*/ void CAM_Application::addModule( CAM_Module* mod ) { if ( !mod || myModules.contains( mod ) ) @@ -141,7 +194,8 @@ void CAM_Application::addModule( CAM_Module* mod ) QMap map; ModuleList newList; - for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); + it != myInfoList.end(); ++it ) { if ( (*it).title == mod->moduleName() ) newList.append( mod ); @@ -151,17 +205,16 @@ void CAM_Application::addModule( CAM_Module* mod ) if ( curMod ) newList.append( curMod ); } - if ( !newList.isEmpty() ) - map.insert( newList.getLast(), 0 ); } - for ( ModuleListIterator itr( myModules ); itr.current(); ++itr ) + for ( QList::const_iterator it = myModules.begin(); + it != myModules.end(); ++it ) { - if ( !map.contains( itr.current() ) ) - newList.append( itr.current() ); + if ( !newList.contains( *it ) ) + newList.append( *it ); } - if ( !map.contains( mod ) ) + if ( !newList.contains( mod ) ) newList.append( mod ); myModules = newList; @@ -169,9 +222,10 @@ void CAM_Application::addModule( CAM_Module* mod ) moduleAdded( mod ); } -/*!Load modules from information list. - * \warning If some of modules not loaded, error message appear on desktop. - */ +/*! + \brief Load modules from the modules information list. + \warning If some module can not be loaded, an error message is shown. +*/ void CAM_Application::loadModules() { for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) @@ -180,33 +234,38 @@ void CAM_Application::loadModules() if ( mod ) addModule( mod ); else { - if ( desktop() && desktop()->isShown() ) + if ( desktop() && desktop()->isVisible() ) SUIT_MessageBox::error1( desktop(), tr( "Loading modules" ), tr( "Can not load module %1" ).arg( (*it).title ), tr( "Ok" ) ); else - qWarning( tr( "Can not load module %1" ).arg( (*it).title ).latin1() ); + qWarning( tr( "Can not load module %1" ).arg( (*it).title ).toLatin1().data() ); } } } -/*!Load module with name \a modName. - *\param modName - module name for loading. - *\warning If information list is empty. - *\warning If module library (for module with \a modName) is empty. - *\warning If module library is not loaded. - */ +/*! + \brief Load module \a modName. + + The function prints warning message if: + - modules information list is empty + - modules information list does not include specified module info + - module library can not be loaded by some reason + + \param modName module name + \return module object pointer or 0 if module could not be loaded +*/ CAM_Module* CAM_Application::loadModule( const QString& modName ) { if ( myInfoList.isEmpty() ) { - qWarning( tr( "Modules configuration is not defined." ) ); + qWarning( tr( "Modules configuration is not defined." ).toLatin1().data() ); return 0; } QString libName = moduleLibrary( modName ); if ( libName.isEmpty() ) { - qWarning( tr( "Information about module \"%1\" doesn't exist." ).arg( modName ) ); + qWarning( tr( "Information about module \"%1\" doesn't exist." ).arg( modName ).toLatin1().data() ); return 0; } @@ -236,7 +295,7 @@ CAM_Module* CAM_Application::loadModule( const QString& modName ) } } #else - void* modLib = dlopen( (char*)libName.latin1(), RTLD_LAZY ); + void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY ); if ( !modLib ) err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() ); else @@ -255,21 +314,20 @@ CAM_Module* CAM_Application::loadModule( const QString& modName ) } if ( !err.isEmpty() ) { - if ( desktop() && desktop()->isShown() ) + if ( desktop() && desktop()->isVisible() ) SUIT_MessageBox::warn1( desktop(), tr( "Error" ), err, tr( "Ok" ) ); else - qWarning( err.latin1() ); + qWarning( err.toLatin1().data() ); } return module; } -/*! @name Activate module group. */ -//@{ -/*!Activate module with name \a modName. - *\param modName - module name. - *\ratval true, if module loaded and activated successful, else false. - */ +/*! + \brief Activate module \a modName. + \param modName module name + \return \c true, if module is loaded and activated successfully and \c false otherwise +*/ bool CAM_Application::activateModule( const QString& modName ) { if ( !modName.isEmpty() && !activeStudy() ) @@ -294,11 +352,15 @@ bool CAM_Application::activateModule( const QString& modName ) return res; } -/*!Activate module \a mod - *\param mod - module for activation. - *\retval true - if all sucessful. - *\warning Error message if module not activated in active study. - */ +/* + \brief Activate module \a modName. + \overload + + Shows error message if module could not be activated in the current study. + + \param mod module object pointer + \return \c true, if module is loaded and activated successfully and \c false otherwise +*/ bool CAM_Application::activateModule( CAM_Module* mod ) { if ( mod && !activeStudy() ) @@ -323,10 +385,10 @@ bool CAM_Application::activateModule( CAM_Module* mod ) { myModule->setMenuShown( false ); myModule->setToolShown( false ); - if ( desktop() && desktop()->isShown() ) + if ( desktop() && desktop()->isVisible() ) SUIT_MessageBox::error1( desktop(), tr( "ERROR_TLT" ), tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ), tr( "BUT_OK" ) ); else - qWarning( tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ).latin1() ); + qWarning( tr( "ERROR_ACTIVATE_MODULE_MSG" ).arg( myModule->moduleName() ).toLatin1().data() ); myModule = 0; return false; } @@ -336,17 +398,19 @@ bool CAM_Application::activateModule( CAM_Module* mod ) return true; } -//@} -/*!Create new study for current application. - *\retval study pointer. - */ +/*! + \brief Create new study. + \return study object pointer +*/ SUIT_Study* CAM_Application::createNewStudy() { return new CAM_Study( this ); } -/*!Update commands status for parent class and for current class(if module is active)*/ +/*! + \brief Update menu commands status. +*/ void CAM_Application::updateCommandsStatus() { STD_Application::updateCommandsStatus(); @@ -355,37 +419,45 @@ void CAM_Application::updateCommandsStatus() activeModule()->updateCommandsStatus(); } -/*!Close all modules in study \a theDoc. - *\param theDoc - study - */ +/*! + \brief Prepare application to study closing. + + Closes all modules in study \a theDoc. + + \param theDoc study +*/ void CAM_Application::beforeCloseDoc( SUIT_Study* theDoc ) { - for ( ModuleListIterator it( myModules ); it.current(); ++it ) - it.current()->studyClosed( theDoc ); + for ( QList::iterator it = myModules.begin(); it != myModules.end(); ++it ) + (*it)->studyClosed( theDoc ); } -/*!Sets active study for parent class. - *\param study - study. - */ +/*! + \brief Set active study. + \param study study to be made active +*/ void CAM_Application::setActiveStudy( SUIT_Study* study ) { STD_Application::setActiveStudy( study ); } -/*!Do nothing.*/ +/*! + \brief Callback function, called when the module is added to the application. + + This virtual method can be re-implemented in the successors. Base implementation + does nothing. + + \param mod module being added +*/ void CAM_Application::moduleAdded( CAM_Module* mod ) { -// CAM_Study* study = dynamic_cast( activeStudy() ); -// if ( !study ) -// return; - -// study->insertDataModel( mod->dataModel() ); } -/*!Gets module name by title \a title - *\param title - title name - *\retval QString module name. - */ +/*! + \brief Get module name by its title (user name). + \param title module title (user name) + \return module name or null QString if module is not found +*/ QString CAM_Application::moduleName( const QString& title ) const { QString res; @@ -397,10 +469,11 @@ QString CAM_Application::moduleName( const QString& title ) const return res; } -/*!Gets module title by module name \a name - *\param name - module name - *\retval QString module title. - */ +/*! + \brief Get module title (user name) by its name. + \param name module name + \return module title (user name) or null QString if module is not found +*/ QString CAM_Application::moduleTitle( const QString& name ) const { QString res; @@ -412,10 +485,11 @@ QString CAM_Application::moduleTitle( const QString& name ) const return res; } -/*!Get library name for module with title \a title. - *\param title - module title name. - *\param full - boolean flag (if true - return full library name, else internal name) - *\retval QString - library name. +/*! + \brief Get module library name by its title (user name). + \param title module title (user name) + \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 ) const { @@ -430,7 +504,26 @@ QString CAM_Application::moduleLibrary( const QString& title, const bool full ) return res; } -/*!Read modules list*/ +/*! + \brief Read modules information list + + This function first tries to get the modules names list by parsing + the application command line arguments, looking for the + "--modules ( [:...] )" option. + List of modules is separated by colon symbol (":"). + + If "--modules" command line option is not used, the list of modules + is retrieved from the application resource file: parameter "modules" of + the section "launch". + + Then the information about each module (module title (user name), + library name) is retrieved from the corresponding section of resource + file with help of resources manager. + + Shows the warning message, if module information list is empty. + + \sa SUIT_ResourceMgr +*/ void CAM_Application::readModuleList() { if ( !myInfoList.isEmpty() ) @@ -440,55 +533,54 @@ void CAM_Application::readModuleList() QStringList modList; - QStringList args; - for (int i = 1; i < qApp->argc(); i++) - args.append( qApp->argv()[i] ); + QStringList args = QApplication::arguments(); QRegExp rx("--modules\\s+\\(\\s*(.*)\\s*\\)"); rx.setMinimal( true ); - if ( rx.search( args.join(" ") ) >= 0 && rx.capturedTexts().count() > 0 ) { - QString modules = rx.capturedTexts()[1]; - QStringList mods = QStringList::split(":",modules,false); + if ( rx.indexIn( args.join(" ") ) >= 0 && rx.numCaptures() > 0 ) { + QString modules = rx.cap(1); + QStringList mods = modules.split( ":", QString::SkipEmptyParts ); for ( uint i = 0; i < mods.count(); i++ ) { - if ( !mods[i].stripWhiteSpace().isEmpty() ) - modList.append( mods[i].stripWhiteSpace() ); + if ( !mods[i].trimmed().isEmpty() ) + modList.append( mods[i].trimmed() ); } } if ( modList.isEmpty() ) { QString mods = resMgr->stringValue( "launch", "modules", QString::null ); - modList = QStringList::split( ",", mods ); + modList = mods.split( ",", QString::SkipEmptyParts ); } for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it ) { - QString modName = (*it).stripWhiteSpace(); + QString modName = (*it).trimmed(); if ( modName.isEmpty() ) continue; - QString modTitle = resMgr->stringValue( *it, QString( "name" ), QString::null ); + QString modTitle = resMgr->stringValue( *it, "name", QString::null ); if ( modTitle.isEmpty() ) { printf( "****************************************************************\n" ); - printf( "* Warning: %s not found in resources.\n", (*it).latin1() ); + printf( "* Warning: %s not found in resources.\n", (*it).toLatin1().data() ); printf( "* Module will not be available\n" ); printf( "****************************************************************\n" ); continue; } - QString modLibrary = resMgr->stringValue( *it, QString( "library" ), QString::null ).stripWhiteSpace(); + QString modLibrary = resMgr->stringValue( *it, "library", QString::null ).trimmed(); if ( !modLibrary.isEmpty() ) { - QString libExt; - modLibrary = SUIT_Tools::file( modLibrary.stripWhiteSpace() ); - libExt = QString( "so" ); - if ( SUIT_Tools::extension( modLibrary ).lower() == libExt ) - modLibrary = modLibrary.mid( 0, modLibrary.length() - libExt.length() - 1 ); - libExt = QString( "dll" ); - if ( SUIT_Tools::extension( modLibrary ).lower() == libExt ) - modLibrary = modLibrary.mid( 0, modLibrary.length() - libExt.length() - 1 ); + modLibrary = SUIT_Tools::file( modLibrary.trimmed() ); +#ifdef WIN32 + QString libExt = QString( "dll" ); +#else + QString libExt = QString( "so" ); +#endif + if ( SUIT_Tools::extension( modLibrary ).toLower() == libExt ) + modLibrary.truncate( modLibrary.length() - libExt.length() - 1 ); #ifndef WIN32 - if ( modLibrary.startsWith( "lib" ) ) - modLibrary = modLibrary.mid( 3 ); + QString prefix = QString( "lib" ); + if ( modLibrary.startsWith( prefix ) ) + modLibrary.remove( 0, prefix.length() ); #endif } else @@ -502,7 +594,7 @@ void CAM_Application::readModuleList() } if ( myInfoList.isEmpty() ) { - if ( desktop() && desktop()->isShown() ) + if ( desktop() && desktop()->isVisible() ) SUIT_MessageBox::warn1( desktop(), tr( "Warning" ), tr( "Modules list is empty" ), tr( "&OK" ) ); else { @@ -513,19 +605,25 @@ void CAM_Application::readModuleList() } } -/*!Add common items for popup menu ( if they are exist ) - *\param type - type of popup menu - *\param thePopup - popup menu - *\param title - title of popup menu - */ -void CAM_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title ) +/*! + \brief Add common menu items to the popup menu. + + Menu items list is defined by the active module. + + \param type popup menu context + \param menu popup menu + \param title popup menu title, which can be set by the module if required +*/ +void CAM_Application::contextMenuPopup( const QString& type, QMenu* menu, QString& title ) { // to do : add common items for popup menu ( if they are exist ) if ( activeModule() ) - activeModule()->contextMenuPopup( type, thePopup, title ); + activeModule()->contextMenuPopup( type, menu, title ); } -/*!Create empty study.*/ +/*! + \brief Create new empty study. +*/ void CAM_Application::createEmptyStudy() { /*SUIT_Study* study = */activeStudy(); diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index c31e90523..c7b545877 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -19,32 +19,24 @@ #ifndef CAM_APPLICATION_H #define CAM_APPLICATION_H -#include "STD_Application.h" +#include "CAM.h" -#include "CAM_Module.h" +#include +#include -#include - -class QPopupMenu; +class QMenu; +class CAM_Module; #ifdef WIN32 #pragma warning( disable:4251 ) #endif -/*! - \class CAM_Application - Defines application configuration and behaviour for application with modules. - Every module has own data model, necessary windows and viewers, etc. - Application provides all necessary functionality for module management - (loading of modules/activation/deactivation, etc) -*/ class CAM_EXPORT CAM_Application : public STD_Application { Q_OBJECT public: - typedef QPtrList ModuleList; - typedef QPtrListIterator ModuleListIterator; + typedef QList ModuleList; public: CAM_Application( const bool = true ); @@ -53,14 +45,11 @@ public: virtual void start(); CAM_Module* activeModule() const; - CAM_Module* module( const QString& ) const; + CAM_Module* module( const QString& ) const; - /** @name Modules lists.*/ - //@{ - ModuleListIterator modules() const; + ModuleList modules() const; void modules( ModuleList& ) const; void modules( QStringList&, const bool loaded = true ) const; - //@} virtual void addModule( CAM_Module* ); @@ -69,7 +58,7 @@ public: virtual bool activateModule( const QString& ); - virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); QString moduleName( const QString& ) const; QString moduleTitle( const QString& ) const; @@ -93,13 +82,13 @@ private: private: typedef struct { QString name, title, internal; } ModuleInfo; - typedef QValueList ModuleInfoList; + typedef QList ModuleInfoList; private: - CAM_Module* myModule; - ModuleList myModules; - ModuleInfoList myInfoList; - bool myAutoLoad; + CAM_Module* myModule; //!< active module + ModuleList myModules; //!< loaded modules list + ModuleInfoList myInfoList; //!< modules info list + bool myAutoLoad; //!< auto loading flag }; #ifdef WIN32 diff --git a/src/CAM/CAM_DataModel.cxx b/src/CAM/CAM_DataModel.cxx index 559901279..6354bf2c7 100755 --- a/src/CAM/CAM_DataModel.cxx +++ b/src/CAM/CAM_DataModel.cxx @@ -19,40 +19,71 @@ #include "CAM_DataModel.h" #include "CAM_Module.h" -#include "CAM_RootObject.h" +#include "CAM_DataObject.h" -/*!Constructor. Initialise module by \a module.*/ +/*! + \class CAM_DataModel + \brief Base class for all data models used in CAM-based applications. + + Represents data model of the CAM module. Provides necessary interface + (default implementation is empty). +*/ + +/*! + \brief Constructor. + + Initialise data module by specified \a module. +*/ CAM_DataModel::CAM_DataModel( CAM_Module* module ) : myRoot( 0 ), -myModule( module ) + myModule( module ) { } -/*!Destructor. Do nothing.*/ +/*! + \brief Destructor. + + Does nothing. +*/ CAM_DataModel::~CAM_DataModel() { } /*! - Default implementation, does nothing. - Can be used for creation of root object. + \brief Initizize data model. + + This method should be re-implemented in the successor classes + and can be used for creation of root data object. + Default implementation does nothing. */ void CAM_DataModel::initialize() { } -/*!Get root object. - *\retval CAM_DataObject pointer - root object. - */ +/*! + \brief Get data model root object. + \return root object + \sa setRoot() +*/ CAM_DataObject* CAM_DataModel::root() const { return myRoot; } -/*!Sets root object to \a newRoot.\n - *Emit root changed, if it was. - *\param newRoot - new root object - */ +/*! + \brief Set data model root object. + + This method should be used to specify custom root object instance. + + Root object can be created in several ways, depending on application or module needs: + - in initialize() method + - while the data model is being loaded + - when the data model is updated and becomes non-empty + + If root object is changed, this method emits rootChanged() signal. + + \param newRoot new root object +*/ void CAM_DataModel::setRoot( const CAM_DataObject* newRoot ) { if ( myRoot == newRoot ) @@ -69,17 +100,106 @@ void CAM_DataModel::setRoot( const CAM_DataObject* newRoot ) emit rootChanged( this ); } -/*!Gets module. - *\retval CAM_Module pointer - module. - */ +/*! + \brief Get module. + \return module owning this data model +*/ CAM_Module* CAM_DataModel::module() const { return myModule; } -/*!Nullify root, if \a obj equal root.*/ +/*! + \brief Called when data object is destroyed. + + Nullifies the root object if it is detroyed to avoid crashes. + + \param obj object being destroyed +*/ void CAM_DataModel::onDestroyed( SUIT_DataObject* obj ) { if ( myRoot == obj ) myRoot = 0; } + +/*! + \brief Load data model. + + This method should be re-implemented in the successor classes. + Default implementation returns \c true. + + \param name study name + \param study study + \param files list of file names from which data should be loaded + \return \c true if data model is loaded successfully +*/ +bool CAM_DataModel::open( const QString& /*name*/, + CAM_Study* /*study*/, + QStringList /*files*/ ) +{ + return true; +} + +/*! + \brief Save data model. + + This method should be re-implemented in the successor classes. + Default implementation returns \c true. + + \param files list of file names to which data should be saved + \return \c true if data model is saved successfully +*/ +bool CAM_DataModel::save( QStringList& ) +{ + return true; +} + +/*! + \brief Save data to the new file. + + This method should be re-implemented in the successor classes. + Default implementation returns \c true. + + \param name study name + \param study study + \param files resulting list of file names to which data is saved + \return \c true if data model is saved successfully +*/ +bool CAM_DataModel::saveAs( const QString& /*name*/, + CAM_Study* /*study*/, + QStringList& /*files*/ ) +{ + return true; +} + +/*! + \brief Close data model. + + This method should be re-implemented in the successor classes. + Default implementation returns \c true. + + \return \c true if data model is closed successfully +*/ +bool CAM_DataModel::close() +{ + return true; +} + +/*! + \brief Create empty data model. + + This method should be re-implemented in the successor classes. + Default implementation returns \c true. + + \return \c true if data model is created successfully +*/ +bool CAM_DataModel::create( CAM_Study* ) +{ + return true; +} + +/*! + \fn void CAM_DataModel::rootChanged( const CAM_DataModel* root ); + \brief Emitted when the root data object is changed. + \param root new root data object +*/ diff --git a/src/CAM/CAM_DataModel.h b/src/CAM/CAM_DataModel.h index 4cbc8ab93..4fb200fea 100755 --- a/src/CAM/CAM_DataModel.h +++ b/src/CAM/CAM_DataModel.h @@ -21,19 +21,14 @@ #include "CAM.h" -#include -#include +#include +#include class CAM_Module; class CAM_DataObject; class CAM_Study; class SUIT_DataObject; -/*! - \class CAM_DataModel - Base class for all data models used in CAM-based applications. - Represents data model of CAM module. Provides necessary interface (default implementation is empty) -*/ class CAM_EXPORT CAM_DataModel : public QObject { Q_OBJECT @@ -47,22 +42,13 @@ public: CAM_DataObject* root() const; CAM_Module* module() const; - /** @name These methods should be redefined in successors.*/ - //@{ - virtual bool open( const QString&, CAM_Study*, QStringList ) { return true; }//!< return true - virtual bool save( QStringList& ) { return true; }; - virtual bool saveAs( const QString&, CAM_Study*, QStringList& ) { return true; }; - virtual bool close() { return true; }; - virtual bool create( CAM_Study* ) { return true; } - //@} + virtual bool open( const QString&, CAM_Study*, QStringList ); + virtual bool save( QStringList& ); + virtual bool saveAs( const QString&, CAM_Study*, QStringList& ); + virtual bool close(); + virtual bool create( CAM_Study* ); protected: - /*! setRoot() should be used to specify custom root object instance.\n - * Such an object can be created in several ways, depending on application or module needs:\n - * \li by initialize() - * \li while the model is being loaded - * \li when the model is updated and becomes non-empty - */ virtual void setRoot( const CAM_DataObject* ); private slots: @@ -72,8 +58,8 @@ signals: void rootChanged( const CAM_DataModel* ); private: - CAM_DataObject* myRoot; - CAM_Module* myModule; + CAM_DataObject* myRoot; //!< root data object + CAM_Module* myModule; //!< module }; #endif diff --git a/src/CAM/CAM_DataObject.cxx b/src/CAM/CAM_DataObject.cxx index 62a3d3b13..dc71af10a 100755 --- a/src/CAM/CAM_DataObject.cxx +++ b/src/CAM/CAM_DataObject.cxx @@ -21,20 +21,36 @@ #include "CAM_Module.h" #include "CAM_DataModel.h" -/*!Constructor. Sets parent object.*/ +/*! + \class CAM_DataObject + \brief CAM-based implementation of data object. + + In addition to base implementation provides integration + with CAM_DataModel. +*/ + +/*! + \brief Constructor. + \param parent parent data object +*/ CAM_DataObject::CAM_DataObject( SUIT_DataObject* parent ) : SUIT_DataObject( parent ) { } -/*!Destructor.Do nothing*/ +/*! + \brief Destructor. + + Does nothing. +*/ CAM_DataObject::~CAM_DataObject() { } -/*!Get module. - *\retval const CAM_Module pointer - module - */ +/*! + \brief Get CAM module. + \return parent module object pointer +*/ CAM_Module* CAM_DataObject::module() const { CAM_Module* mod = 0; @@ -46,10 +62,11 @@ CAM_Module* CAM_DataObject::module() const return mod; } -/*!Get data model. - *Return 0 - if no parent obbject. - *\retval const CAM_DataModel pointer - data model - */ +/*! + \brief Get CAM data model. + \return data model or 0 if it is not set + \sa CAM_RootObject class +*/ CAM_DataModel* CAM_DataObject::dataModel() const { CAM_DataObject* parentObj = dynamic_cast( parent() ); diff --git a/src/CAM/CAM_DataObject.h b/src/CAM/CAM_DataObject.h index 1e4e414b2..f0b4affa8 100755 --- a/src/CAM/CAM_DataObject.h +++ b/src/CAM/CAM_DataObject.h @@ -26,10 +26,6 @@ class CAM_Module; class CAM_DataModel; -/*! - \class CAM_DataObject - Provides only additional link to CAM_DataModel -*/ class CAM_EXPORT CAM_DataObject : public SUIT_DataObject { public: diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 511cad9e3..d921e93a8 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -26,10 +26,10 @@ #include #include +#include #include -#include -/*!Icon.*/ +/*! Default module icon data set */ static const char* ModuleIcon[] = { "20 20 2 1", " c None", @@ -55,35 +55,67 @@ static const char* ModuleIcon[] = { " .. .. .. .. .. .. ", " ... ... ... "}; +/*! Default module icon pixmap */ QPixmap MYPixmap( ModuleIcon ); -/*!Constructor.*/ +/*! + \class CAM_Module + \brief Base implementation of the module in the CAM application architecture. + + Provides support of menu/toolbars management. +*/ + +/*! + \brief Default constructor. + + Creates unnamed module. +*/ CAM_Module::CAM_Module() : QObject(), -myApp( 0 ), -myIcon( MYPixmap ), -myDataModel( 0 ) + myApp( 0 ), + myIcon( MYPixmap ), + myDataModel( 0 ) { } -/*!Constructor. initialize \a name.*/ +/*! + \brief Constructor. + + Creates module with the specified \a name. + + \param name module name +*/ CAM_Module::CAM_Module( const QString& name ) : QObject(), -myApp( 0 ), -myName( name ), -myIcon( MYPixmap ), -myDataModel( 0 ) + myApp( 0 ), + myName( name ), + myIcon( MYPixmap ), + myDataModel( 0 ) { } -/*!Destructor. Remove data model.*/ +/*! + \brief Destructor. + + Destroy data model. +*/ CAM_Module::~CAM_Module() { delete myDataModel; myDataModel = 0; } -/*!Initialize application.*/ +/*! + \brief Initialize module. + + This method is usually called when the module is created (for example, + on the module library loading). + Successor classes can use this method to create menu/toolbar actions + and perform other module initialization. + + \param app parent application object + \sa activateModule(), deactivateModule() +*/ void CAM_Module::initialize( CAM_Application* app ) { myApp = app; @@ -97,27 +129,58 @@ void CAM_Module::initialize( CAM_Application* app ) } } -/*!\retval Module icon.*/ +/*! + \brief Get module icon. + \return module icon pixmap + \sa setModuleIcon(), iconName() +*/ QPixmap CAM_Module::moduleIcon() const { return myIcon; } -/*!\retval Module icon name.*/ +/*! + \brief Get module icon's name. + + This function is used to get module icon's file name. + Default implementation returns empty string. + + \return module icon's name. + \sa moduleIcon(), setModuleIcon() +*/ QString CAM_Module::iconName() const { return ""; } -/*!\retval Module name.*/ +/*! + \brief Get module (internal) name + \return module name + \sa setName(), moduleName(), setModuleName() +*/ +QString CAM_Module::name() const +{ + return objectName(); +} + +/*! + \brief Get module title (user name) + \return module title + \sa setModuleName(), name(), setName() +*/ QString CAM_Module::moduleName() const { return myName; } -/*! \brief Return data model. - * Create data model, if it was't created before. - */ +/*! + \brief Get data model. + + Creates data model, if it is not yet created. + + \return data model pointer + \sa createDataModel() +*/ CAM_DataModel* CAM_Module::dataModel() const { if ( !myDataModel ) @@ -129,29 +192,56 @@ CAM_DataModel* CAM_Module::dataModel() const return myDataModel; } -/*!\retval CAM_Application pointer - application.*/ +/*! + \brief Get application. + \return application pointer +*/ CAM_Application* CAM_Module::application() const { return myApp; } -/*!Public slot - * \retval true. +/*! + \brief Activate module. + + This method is called when the user activates module. + Successor classes can use this method to customize module activation process, + for example, to show own menus, toolbars, etc. + + Default implementation always returns \c true. + + \return \c true if module is activated successfully. + \sa initialize(), deactivateModule() */ bool CAM_Module::activateModule( SUIT_Study* study ) { return true; } -/*!Public slot - * \retval true. +/*! + \brief Deactivate module. + + This method is called when the user deactivates module. + Successor classes can use this method to customize module deactivation process, + for example, to hide own menus, toolbars, etc. + + Default implementation always returns \c true. + + \return \c true if module is deactivated successfully. + \sa initialize(), activateModule() */ bool CAM_Module::deactivateModule( SUIT_Study* ) { return true; } -/*!Public slot, remove data model from \a study.*/ +/*! + \brief Called when study is closed. + + Removes data model from the \a study. + + \param study study being closed +*/ void CAM_Module::studyClosed( SUIT_Study* study ) { CAM_Study* camDoc = dynamic_cast( study ); @@ -165,21 +255,35 @@ void CAM_Module::studyClosed( SUIT_Study* study ) } } -/*!Public slot, do nothing.*/ -void CAM_Module::studyChanged( SUIT_Study* , SUIT_Study* ) +/* + \brief Called when study is changed (obsolete). + + Default implementation does nothing. + + \param oldStudy old study + \param newStudy new study +*/ +void CAM_Module::studyChanged( SUIT_Study* /*oldStudy*/, SUIT_Study* /*newStudy*/ ) { } -/*!Return true if module is active.*/ +/*! + \brief Check if the module is active. + \return \c true if module is active. +*/ bool CAM_Module::isActiveModule() const { return application() ? application()->activeModule() == this : false; } /*! - Put the message into the status bar of the desktop. Message will be displayed - during specified \amscec milliseconds. If parameter \amsec is negative then - message will be persistently displayed when module is active. + \brief Put the text message into the status bar of the application main window. + + If \a msec > 0, the message will be shown \a msec milliseconds. + If \a msec < 0, the message will be constantly displayed until module is active. + + \param msg text message + \param msec message displaying duration in milliseconds */ void CAM_Module::putInfo( const QString& msg, const int msec ) { @@ -191,8 +295,12 @@ void CAM_Module::putInfo( const QString& msg, const int msec ) } /*! - Restore persistently displayed info string when previos information status string erasing - if module is active. + \brief Restore message info. + + Restores constant text message when previous information status message is removed. + + \param txt previous message (being removed) + \sa putInfo() */ void CAM_Module::onInfoChanged( QString txt ) { @@ -200,40 +308,62 @@ void CAM_Module::onInfoChanged( QString txt ) application()->putInfo( myInfo ); } +/*! + \brief Called when application is closed. + Nullify application pointer if the application is being closed. -/*!Public slot, nullify application pointer if the application was closed.*/ + \param theApp application +*/ void CAM_Module::onApplicationClosed( SUIT_Application* theApp ) { if (myApp == theApp) myApp = NULL; } -/*!Create and return new instance of CAM_DataModel.*/ +/*! + \brief Create data model. + \return created data model object or 0 if it could not be created +*/ CAM_DataModel* CAM_Module::createDataModel() { return new CAM_DataModel( this ); } -/*!Sets module name to \a name. - * \param name - new name for module. +/*! + \brief Set module (internal) name + \param name new module name + \sa name(), moduleName(), setModuleName() + */ +void CAM_Module::setName( const QString& name ) +{ + setObjectName( name ); +} + +/*! + \brief Set module title (user name) + \param name new module title + \sa moduleName(), name(), setName() */ void CAM_Module::setModuleName( const QString& name ) { myName = name; } -/*!Sets module icon to \a icon. - * \param icon - new icon for module. - */ +/*! + \brief Set module icon. + \param icon new module icon + \sa moduleIcon(), iconName() +*/ void CAM_Module::setModuleIcon( const QPixmap& icon ) { myIcon = icon; } -/*! Return menu manager pointer. - * \retval QtxActionMenuMgr pointer - menu manager. - */ +/*! + \brief Get menu manager. + \return menu manager pointer +*/ QtxActionMenuMgr* CAM_Module::menuMgr() const { QtxActionMenuMgr* mgr = 0; @@ -242,9 +372,10 @@ QtxActionMenuMgr* CAM_Module::menuMgr() const return mgr; } -/*! Return tool manager pointer. - * \retval QtxActionToolMgr pointer - tool manager. - */ +/*! + \brief Get toolbar manager. + \return toolbar manager pointer +*/ QtxActionToolMgr* CAM_Module::toolMgr() const { QtxActionToolMgr* mgr = 0; @@ -253,9 +384,14 @@ QtxActionToolMgr* CAM_Module::toolMgr() const return mgr; } -/*! Create tool bar with name \a name, if it was't created before. - * \retval -1 - if tool manager was't be created. - */ +/*! + \brief Create toolbar with speicifed \a name. + + If the toolbar has been already created, its ID is just returned. + + \param name toolbar name + \return toolbar ID or -1 if toolbar could not be created +*/ int CAM_Module::createTool( const QString& name ) { if ( !toolMgr() ) @@ -264,15 +400,25 @@ int CAM_Module::createTool( const QString& name ) return toolMgr()->createToolBar( name ); } -/*! Create tool. Register action \a a with id \a id. - * Insert QAction to tool manager. - *\param a - QAction - *\param tBar - integer - *\param id - integer - *\param idx - integer - *\retval integer id of new action in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Add toolbar item. + + Insert action \a to the toolbar manager and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + If \a id < 0, the action ID is generated automatically. + + If \a idx < 0, the action is added to the end of the toolbar. + + \param a action + \param tBar toolbar ID + \param id requested action ID + \param idx action index (desired position in the toolbar) + \return action ID or -1 if toolbar item could not be added +*/ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int idx ) { if ( !toolMgr() ) @@ -283,15 +429,25 @@ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int return intId != -1 ? regId : -1; } -/*! Create tool. Register action \a a with id \a id. - * Insert QAction to tool manager. - *\param a - QAction - *\param tBar - QString& - *\param id - integer - *\param idx - integer - *\retval integer id of new action in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Add toolbar item. + + Insert action \a to the toolbar manager and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + If \a id < 0, the action ID is generated automatically. + + If \a idx < 0, the action is added to the end of the toolbar. + + \param a action + \param tBar toolbar name + \param id requested action ID + \param idx action index (desired position in the toolbar) + \return action ID or -1 if toolbar item could not be added +*/ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const int idx ) { if ( !toolMgr() ) @@ -302,14 +458,24 @@ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const return intId != -1 ? regId : -1; } -/*! Create tool. - * Insert QAction with id \a id from action map(myActionMap) to tool manager. - *\param id - integer - *\param tBar - integer - *\param idx - integer - *\retval integer id of new action in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Add toolbar item. + + Insert action with \a id identifier to the toolbar manager. + It is assumed that action has been already registered. + + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + If \a idx < 0, the action is added to the end of the toolbar. + + \param id action ID + \param tBar toolbar ID + \param idx action index (desired position in the toolbar) + \return action ID or -1 if toolbar item could not be added +*/ int CAM_Module::createTool( const int id, const int tBar, const int idx ) { if ( !toolMgr() ) @@ -319,14 +485,24 @@ int CAM_Module::createTool( const int id, const int tBar, const int idx ) return intId != -1 ? id : -1; } -/*! Create tool. - * Insert QAction with id \a id from action map(myActionMap) to tool manager. - *\param id - integer - *\param tBar - QString& - *\param idx - integer - *\retval integer id of new action in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Add toolbar item. + + Insert action with \a id identifier to the toolbar manager. + It is assumed that action has been already registered. + + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + If \a idx < 0, the action is added to the end of the toolbar. + + \param id action ID + \param tBar toolbar name + \param idx action index (desired position in the toolbar) + \return action ID or -1 if toolbar item could not be added +*/ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) { if ( !toolMgr() ) @@ -336,126 +512,211 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) return intId != -1 ? id : -1; } -/*! Create menu. - * Insert submenu \a subMenu to menu manager. - *\param subMenu - QString& - *\param menu - integer - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Create menu or submenu. + + Create main menu or popup submenu and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If \a id < 0, the menu ID is generated automatically. + If menu has been already created previously, its ID is just returned. + + The \a menu parameter represents the menu name - it could be a sequence + of strings, separated by '|' symbol. For example, "File|Edit" means + File->Edit submenu. If menu doesn't exist, it is created automatically. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the menu/submenu is added to the + end of the menu group. + + \param subMenu subMenu name + \param menu parent menu ID + \param id requested menu ID + \param group menu group ID + \param idx menu item index (desired position in the menu group) + \return menu item ID or -1 if menu item could not be added +*/ int CAM_Module::createMenu( const QString& subMenu, const int menu, - const int id, const int group, const int index, - const bool enableEmpty ) + const int id, const int group, const int idx ) { if ( !menuMgr() ) return -1; - return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty ); + return menuMgr()->insert( subMenu, menu, group, id, idx ); } -/*! Create menu. - * Insert submenu \a subMenu to menu manager. - *\param subMenu - QString& - *\param menu - QString& - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ +/*! + \brief Create menu or submenu. + + Create main menu or popup submenu and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If \a id < 0, the menu ID is generated automatically. + If menu has been already created previously, its ID is just returned. + + The \a menu parameter represents the menu name - it could be a sequence + of strings, separated by '|' symbol. For example, "File|Edit" means + File->Edit submenu. If menu doesn't exist, it is created automatically. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the menu/submenu is added to the + end of the menu group. + + \param subMenu subMenu name + \param menu parent menu name(s) + \param id requested menu ID + \param group menu group ID + \param idx menu item index (desired position in the menu group) + \return menu item ID or -1 if menu item could not be added +*/ int CAM_Module::createMenu( const QString& subMenu, const QString& menu, - const int id, const int group, const int index, - const bool enableEmpty ) + const int id, const int group, const int idx ) { if ( !menuMgr() ) return -1; - return menuMgr()->insert( subMenu, menu, group, id, index, enableEmpty ); + return menuMgr()->insert( subMenu, menu, group, id, idx ); } +/*! + \brief Add menu item. + + Insert action \a to the menu manager and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. -/*! Create menu. Register action \a a with id \a id. - * Insert QAction to menu manager. - *\param a - Qaction - *\param menu - integer - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ -int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int index ) + If \a id < 0, the action ID is generated automatically. + + If action has been already added previously, its ID is just returned. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the action is added to the + end of the menu group. + + \param a action + \param menu menu ID + \param id requested action ID + \param group menu group ID + \param idx action index (desired position in the menu group) + \return action ID or -1 if menu item could not be added +*/ +int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int group, const int idx ) { if ( !a || !menuMgr() ) return -1; int regId = registerAction( id, a ); - int intId = menuMgr()->insert( a, menu, group, index ); + int intId = menuMgr()->insert( a, menu, group, idx ); return intId != -1 ? regId : -1; } -/*! Create menu. Register action \a a with id \a id. - * Insert QAction to menu manager. - *\param a - Qaction - *\param menu - QString& - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ -int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int index ) +/*! + \brief Add menu item. + + Insert action \a to the menu manager and register it with specified \a id. + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If \a id < 0, the action ID is generated automatically. + + If action has been already added previously, its ID is just returned. + + The \a menu parameter represents the menu name - it could be a sequence + of strings, separated by '|' symbol. For example, "File|Edit" means + File->Edit submenu. If menu doesn't exist, it is created automatically. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the action is added to the + end of the menu group. + + \param a action + \param menu menu name(s) + \param id requested action ID + \param group menu group ID + \param idx action index (desired position in the menu group) + \return action ID or -1 if menu item could not be added +*/ +int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const int group, const int idx ) { if ( !a || !menuMgr() ) return -1; int regId = registerAction( id, a ); - int intId = menuMgr()->insert( a, menu, group, index ); + int intId = menuMgr()->insert( a, menu, group, idx ); return intId != -1 ? regId : -1; } -/*! Create menu. - * Insert QAction with id \a id from action map(myActionMap) to menu manager. - *\param menu - integer - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ -int CAM_Module::createMenu( const int id, const int menu, const int group, const int index ) +/*! + \brief Add menu item. + + Insert action with \a id identifier to the menu manager. + It is assumed that action has been already registered. + + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the action is added to the + end of the menu group. + + \param id action ID + \param menu menu ID + \param group menu group ID + \param idx action index (desired position in the menu group) + \return action ID or -1 if menu item could not be added +*/ +int CAM_Module::createMenu( const int id, const int menu, const int group, const int idx ) { if ( !menuMgr() ) return -1; - int intId = menuMgr()->insert( action( id ), menu, group, index ); + int intId = menuMgr()->insert( action( id ), menu, group, idx ); return intId != -1 ? id : -1; } -/*! Create menu. - * Insert QAction with id \a id from action map(myActionMap) to menu manager. - *\param menu - QString& - *\param id - integer - *\param group - integer - *\param index - integer - *\retval integer id of new menu in tool manager. - *\retval Return -1 if something wrong. - */ -int CAM_Module::createMenu( const int id, const QString& menu, const int group, const int index ) +/*! + \brief Add menu item. + + Insert action with \a id identifier to the menu manager. + It is assumed that action has been already registered. + + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If action has been already added previously, its ID is just returned. + + The \a menu parameter represents the menu name - it could be a sequence + of strings, separated by '|' symbol. For example, "File|Edit" means + File->Edit submenu. If menu doesn't exist, it is created automatically. + + Parameter \a idx defines the index of the menu item in the menu group which + is defined by the \a group. If \a idx < 0, the action is added to the + end of the menu group. + + \param id action ID + \param menu menu name(s) + \param group menu group ID + \param idx action index (desired position in the menu group) + \return action ID or -1 if menu item could not be added +*/ +int CAM_Module::createMenu( const int id, const QString& menu, const int group, const int idx ) { if ( !menuMgr() ) return -1; - int intId = menuMgr()->insert( action( id ), menu, group, index ); + int intId = menuMgr()->insert( action( id ), menu, group, idx ); return intId != -1 ? id : -1; } -/*!Sets menus shown to \a on floag. - *\param on - flag. - */ +/*! + \brief Show/hide all module's menus. + \param on if \c true, show menus, otherwise, hide all menus + \sa setToolShown() +*/ void CAM_Module::setMenuShown( const bool on ) { QtxActionMenuMgr* mMgr = menuMgr(); @@ -468,8 +729,8 @@ void CAM_Module::setMenuShown( const bool on ) QAction* sep = separator(); for ( QMap::Iterator it = myActionMap.begin(); it != myActionMap.end(); ++it ) { - if ( it.data() != sep ) - mMgr->setShown( mMgr->actionId( it.data() ), on ); + if ( it.value() != sep ) + mMgr->setShown( mMgr->actionId( it.value() ), on ); } mMgr->setUpdatesEnabled( upd ); @@ -477,28 +738,32 @@ void CAM_Module::setMenuShown( const bool on ) mMgr->update(); } -/*!Sets menu shown for QAction \a a to \a on flag. - * \param a - QAction - * \param on - flag - */ +/*! + \brief Show/hide specified menu item. + \param a action + \param on if \c true, show menu item, otherwise, hide it +*/ void CAM_Module::setMenuShown( QAction* a, const bool on ) { if ( menuMgr() ) menuMgr()->setShown( menuMgr()->actionId( a ), on ); } -/*!Sets menu shown for action with id=\a id to \a on flag. - * \param id - id of action - * \param on - flag - */ +/*! + \brief Show/hide specified menu item. + \param id menu item ID + \param on if \c true, show menu item, otherwise, hide it +*/ void CAM_Module::setMenuShown( const int id, const bool on ) { setMenuShown( action( id ), on ); } -/*!Set tools shown to \a on flag. - *\param on - boolean flag. - */ +/*! + \brief Show/hide all module's toolbars. + \param on if \c true, show toolbars, otherwise, hide all toolbars + \sa setMenuShown() +*/ void CAM_Module::setToolShown( const bool on ) { QtxActionToolMgr* tMgr = toolMgr(); @@ -511,8 +776,8 @@ void CAM_Module::setToolShown( const bool on ) QAction* sep = separator(); for ( QMap::Iterator it = myActionMap.begin(); it != myActionMap.end(); ++it ) { - if ( it.data() != sep ) - tMgr->setShown( tMgr->actionId( it.data() ), on ); + if ( it.value() != sep ) + tMgr->setShown( tMgr->actionId( it.value() ), on ); } tMgr->setUpdatesEnabled( upd ); @@ -520,29 +785,32 @@ void CAM_Module::setToolShown( const bool on ) tMgr->update(); } -/*!Set tools shown for QAction \a a to \a on flag. - * \param a - QAction - * \param on - boolean flag - */ +/*! + \brief Show/hide specified toolbar item. + \param a action + \param on if \c true, show toolbar item, otherwise, hide it +*/ void CAM_Module::setToolShown( QAction* a, const bool on ) { if ( toolMgr() ) toolMgr()->setShown( toolMgr()->actionId( a ), on ); } -/*!Set tools shown for action with id=\a id to \a on flag. - * \param id - integer action id - * \param on - boolean flag - */ +/*! + \brief Show/hide specified toolbar item. + \param id toolbar item ID + \param on if \c true, show toolbar item, otherwise, hide it +*/ void CAM_Module::setToolShown( const int id, const bool on ) { setToolShown( action( id ), on ); } -/*! Return action by id. - * \param id - id of action. - * \retval QAction. - */ +/*! + \brief Get action by specified \a id. + \param id action ID + \return action or 0 if not found +*/ QAction* CAM_Module::action( const int id ) const { QAction* a = 0; @@ -551,34 +819,42 @@ QAction* CAM_Module::action( const int id ) const return a; } -/*! Return id by action. - * \param a - QAction. - * \retval id of action. - */ +/*! + \brief Get action ID. + \param a action + \return action ID or -1 if not found +*/ int CAM_Module::actionId( const QAction* a ) const { int id = -1; for ( QMap::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && id == -1; ++it ) { - if ( it.data() == a ) + if ( it.value() == a ) id = it.key(); } return id; } -/*! Create new instance of QtxAction and register action with \a id. - * \param id - id for new action. - * \param text - parameter for creation QtxAction - * \param icon - parameter for creation QtxAction - * \param menu - parameter for creation QtxAction - * \param tip - tip status for QtxAction action. - * \param key - parameter for creation QtxAction - * \param parent - parent for action - * \param toggle - parameter for creation QtxAction - * \param reciever - - * \param member - - */ -QAction* CAM_Module::createAction( const int id, const QString& text, const QIconSet& icon, +/*! + \brief Create new instance of QtxAction and register action with specified \a id. + + Resulting action ID may differ from the requested one. This can happen if + requested ID is already in use. + + If \a id < 0, the action ID is generated automatically. + + \param id required action ID + \param text tooltip text + \param icon action icon + \param menu menu text + \param tip status bar tip + \param key keyboard accelerator + \param parent parent object + \param toggle if \c true, the action will be toggled + \param reciever action activation signal receiver object + \param member action activation signal receiver slot +*/ +QAction* CAM_Module::createAction( const int id, const QString& text, const QIcon& icon, const QString& menu, const QString& tip, const int key, QObject* parent, const bool toggle, QObject* reciever, const char* member ) { @@ -593,16 +869,21 @@ QAction* CAM_Module::createAction( const int id, const QString& text, const QIco return a; } -/*! Register action in action map. - * \param id - id for action. - * \param a - action - * \retval new id for action. - */ +/*! + \brief Register action in the internal action map. + + If action has been already added previously, its ID is just returned. + If \a id < 0, the action ID is generated automatically. + + \param id action required ID + \param a action + \return action ID +*/ int CAM_Module::registerAction( const int id, QAction* a ) { int ident = -1; for ( QMap::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && ident == -1; ++it ) - if ( it.data() == a ) + if ( it.value() == a ) ident = it.key(); if ( ident != -1 ) @@ -622,19 +903,23 @@ int CAM_Module::registerAction( const int id, QAction* a ) return ident; } -/*! Unregister an action. - * \param id - id for action. - * \retval true if succeded, false if action is used - */ +/*! + \brief Unregister action from the internal action map. + + \param id action ID + \return \c true on success or \c false if action is in use +*/ bool CAM_Module::unregisterAction( const int id ) { return unregisterAction( action( id ) ); } -/*! Unregister an action. - * \param a - action - * \retval true if succeded, false if action is used - */ +/*! + \brief Unregister action from the internal action map. + + \param a action + \return \c true on success or \c false if action is in use +*/ bool CAM_Module::unregisterAction( QAction* a ) { if ( !a ) @@ -656,13 +941,22 @@ bool CAM_Module::unregisterAction( QAction* a ) return true; } -/*! Return qt action manager separator.*/ +/*! + \brief Create separator action. + + Separator action can be used in menus or toolbars. + + \return new separator action +*/ QAction* CAM_Module::separator() { return QtxActionMgr::separator(); } -/*! Connect data model of module with active study */ +/*! + \brief Connect data model of the module to the active study + \param camStudy CAM study object +*/ void CAM_Module::connectToStudy( CAM_Study* camStudy ) { CAM_Application* app = camStudy ? dynamic_cast( camStudy->application() ) : 0; @@ -670,15 +964,16 @@ void CAM_Module::connectToStudy( CAM_Study* camStudy ) return; CAM_DataModel* prev = 0; - for( CAM_Application::ModuleListIterator it = app->modules(); it.current(); ++it ) + CAM_Application::ModuleList mods = app->modules(); + for( QList::const_iterator it = mods.begin(); it != mods.end(); ++it ) { - CAM_DataModel* dm = it.current()->dataModel(); - if( it.current() == this && !camStudy->containsDataModel( dm ) ) + CAM_DataModel* dm = (*it)->dataModel(); + if( (*it) == this && !camStudy->containsDataModel( dm ) ) { if ( prev ) - camStudy->insertDataModel( it.current()->dataModel(), prev ); + camStudy->insertDataModel( (*it)->dataModel(), prev ); else - camStudy->insertDataModel( it.current()->dataModel(), 0 ); + camStudy->insertDataModel( (*it)->dataModel(), 0 ); } prev = dm; } diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index df9282a41..1922955e1 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -21,27 +21,27 @@ #include "CAM.h" -#include -#include -#include -#include +#include +#include +#include +#include class QAction; +class QMenu; +class QIcon; + +class QtxActionMenuMgr; +class QtxActionToolMgr; class SUIT_Study; class SUIT_Application; class CAM_Study; class CAM_DataModel; class CAM_Application; -class QtxActionMenuMgr; -class QtxActionToolMgr; #ifdef WIN32 #pragma warning( disable: 4251 ) #endif -/*! - * Class provide support of tool and menu managers. - */ class CAM_EXPORT CAM_Module : public QObject { Q_OBJECT @@ -53,6 +53,7 @@ public: virtual void initialize( CAM_Application* ); + QString name() const; QString moduleName() const; QPixmap moduleIcon() const; @@ -61,26 +62,20 @@ public: virtual QString iconName() const; - virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {}; + virtual void contextMenuPopup( const QString&, QMenu*, QString& title ) {}; virtual void updateCommandsStatus() {}; virtual void putInfo( const QString&, const int = -1 ); bool isActiveModule() const; - /** @name Set Menu Shown*/ - //@{ virtual void setMenuShown( const bool ); void setMenuShown( QAction*, const bool ); void setMenuShown( const int, const bool ); - //@} - /** @name Set Tool Shown*/ - //@{ virtual void setToolShown( const bool ); void setToolShown( QAction*, const bool ); void setToolShown( const int, const bool ); - //@} public slots: virtual bool activateModule( SUIT_Study* ); @@ -99,53 +94,45 @@ private slots: protected: virtual CAM_DataModel* createDataModel(); + void setName( const QString& ); virtual void setModuleName( const QString& ); virtual void setModuleIcon( const QPixmap& ); QtxActionMenuMgr* menuMgr() const; QtxActionToolMgr* toolMgr() const; - /** @name Create tool methods.*/ - //@{ int createTool( const QString& ); int createTool( const int, const int, const int = -1 ); int createTool( const int, const QString&, const int = -1 ); int createTool( QAction*, const int, const int = -1, const int = -1 ); int createTool( QAction*, const QString&, const int = -1, const int = -1 ); - //@} - /** @name Create menu methods.*/ - //@{ - int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false ); - int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false ); + int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 ); + int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 ); int createMenu( const int, const int, const int = -1, const int = -1 ); int createMenu( const int, const QString&, const int = -1, const int = -1 ); int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 ); int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 ); - //@} static QAction* separator(); - /**Action ids methods.*/ - //@{ QAction* action( const int ) const; int actionId( const QAction* ) const; - //@} int registerAction( const int, QAction* ); bool unregisterAction( const int ); bool unregisterAction( QAction* ); - QAction* createAction( const int, const QString&, const QIconSet&, const QString&, + QAction* createAction( const int, const QString&, const QIcon&, const QString&, const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0 ); private: - CAM_Application* myApp; - QString myName; - QPixmap myIcon; - QString myInfo; - CAM_DataModel* myDataModel; - QMap myActionMap; + CAM_Application* myApp; //!< parent application object + QString myName; //!< module title (user name) + QPixmap myIcon; //!< module icon + QString myInfo; //!< latest info message + CAM_DataModel* myDataModel; //!< data model + QMap myActionMap; //!< menu actions friend class CAM_Application; }; diff --git a/src/CAM/CAM_RootObject.cxx b/src/CAM/CAM_RootObject.cxx index e1d9771e3..46b77e49f 100755 --- a/src/CAM/CAM_RootObject.cxx +++ b/src/CAM/CAM_RootObject.cxx @@ -21,32 +21,54 @@ #include "CAM_DataModel.h" #include "CAM_Module.h" -/*!Constructor. Initialize by \a parent. - * Set data model to 0. - */ +/*! + \class CAM_RootObject + + This class is intended for optimized access to CAM_DataModel instance + from CAM_DataObject instances. + + To take advantage of this class in a specific application, + custom data model root object class should be derived from both CAM_RootObject + and application-specific DataObject implementation using virtual inheritance. +*/ + +/*! + \brief Constructor. + \param parent parent data object +*/ CAM_RootObject::CAM_RootObject( SUIT_DataObject* parent ) : CAM_DataObject( parent ), -myDataModel( 0 ) + myDataModel( 0 ) { } -/*!Constructor. Initialize by \a parent and \a data - data object - *\param data - data object - *\param parent - parent data object - */ +/*! + \brief Constructor. + \param data data model + \param parent parent data object +*/ CAM_RootObject::CAM_RootObject( CAM_DataModel* data, SUIT_DataObject* parent ) : CAM_DataObject( parent ), -myDataModel( data ) + myDataModel( data ) { } -/*!Destructor. Do nothing.*/ +/*! + \brief Destructor. + + Does nothing. +*/ CAM_RootObject::~CAM_RootObject() { } /*! - Returns module name + \brief Get root object name. + + If the data model is set, this method returns module name. + Otherwise returns empty string. + + \return root object name */ QString CAM_RootObject::name() const { @@ -56,17 +78,19 @@ QString CAM_RootObject::name() const return aName; } -/*!Get data model - *\retval const CAM_DataModel pointer to data model. - */ +/*! + \brief Get data model. + \return data model pointer or 0 if it is not set +*/ CAM_DataModel* CAM_RootObject::dataModel() const { return myDataModel; } -/*!Set data model. - *\param dm - data model to set. - */ +/*! + \brief Set data model. + \param dm data model +*/ void CAM_RootObject::setDataModel( CAM_DataModel* dm ) { myDataModel = dm; diff --git a/src/CAM/CAM_RootObject.h b/src/CAM/CAM_RootObject.h index 8456e7628..fd633b812 100755 --- a/src/CAM/CAM_RootObject.h +++ b/src/CAM/CAM_RootObject.h @@ -21,14 +21,6 @@ #include "CAM_DataObject.h" -/*! - CAM_RootObject - class intended for optimized access to CAM_DataModel instance - from CAM_DataObject instances. - - To take advantage of this class in a specific application, - custom data model root object class should be derived from both CAM_RootObject - and application-specific DataObject implementation using virtual inheritance. - */ class CAM_EXPORT CAM_RootObject : public virtual CAM_DataObject { public: diff --git a/src/CAM/CAM_Study.cxx b/src/CAM/CAM_Study.cxx index 65ded0325..da1c304dd 100755 --- a/src/CAM/CAM_Study.cxx +++ b/src/CAM/CAM_Study.cxx @@ -23,58 +23,85 @@ #include "CAM_RootObject.h" #include "CAM_Module.h" -/*!Constructor.*/ +/*! + \class CAM_Study + \brief Represents document object in the CAM application architecture. + + For each loaded module study contains the data model instance reference. + Provides all necessary functionality for data models management. +*/ + +/*! + \brief Constructor. + \param app parent application +*/ CAM_Study::CAM_Study( SUIT_Application* app ) : SUIT_Study( app ) { } -/*!Destructor*/ +/*! + \brief Destructor. +*/ CAM_Study::~CAM_Study() { } -/*!Closing all data models and close document permanently(if \a permanently = true.) - * \param permanently - flag - */ -void CAM_Study::closeDocument(bool permanently) +/*! + \brief Called when study is closed. + + Closes all data models. + + \param permanently if \c true close study permanently (not used in the base implemetation) +*/ +void CAM_Study::closeDocument( bool permanently ) { - for ( ModelListIterator it( myDataModels ); it.current(); ++it ) - it.current()->close(); + for( QList::const_iterator it = myDataModels.begin(); + it != myDataModels.end(); ++it ) + (*it)->close(); - SUIT_Study::closeDocument(permanently); + SUIT_Study::closeDocument( permanently ); } -/*!Append data model to list. - * \param dm - data model for adding - */ +/*! + \brief Append data model to the study. + \param dm data model being added + \return \c true on success and \c false on error +*/ bool CAM_Study::appendDataModel( const CAM_DataModel* dm ) { return insertDataModel( dm, myDataModels.count() ); } -/*!Insert data model \a dm after \a other - * \param dm - data model for adding - * \param other - previus data model for \a dm - */ +/*! + \brief Insert data model \a dm after data model \a other + + If \a other is 0, the data model is added to the end of list. + + \param dm data model being added + \param other data model to be previous in the list + \return \c true on success and \c false on error +*/ bool CAM_Study::insertDataModel( const CAM_DataModel* dm, const CAM_DataModel* other ) { - int idx = myDataModels.findRef( other ); + int idx = myDataModels.indexOf( (CAM_DataModel*)other ); return insertDataModel( dm, idx < 0 ? idx : idx + 1 ); } -/*!Insert data model with index \a idx. \n - * \param dm - data model - * \param idx - index for inserting(must be no less zero) - * \retval true - if model added successful, else false. - */ +/*! + \brief Insert data model \a dm with index \a idx. + + \param dm data model being added + \param idx data model required index + \return \c true on success and \c false on error +*/ bool CAM_Study::insertDataModel( const CAM_DataModel* dm, const int idx ) { - if ( !dm || myDataModels.findRef( dm ) != -1 ) + if ( !dm || myDataModels.indexOf( (CAM_DataModel*)dm ) != -1 ) return false; int pos = idx < 0 ? myDataModels.count() : idx; - myDataModels.insert( QMIN( pos, (int)myDataModels.count() ), dm ); + myDataModels.insert( qMin( pos, (int)myDataModels.count() ), (CAM_DataModel*)dm ); connect( dm, SIGNAL( rootChanged( const CAM_DataModel* ) ), SLOT( updateModelRoot( const CAM_DataModel* ) ) ); @@ -83,10 +110,11 @@ bool CAM_Study::insertDataModel( const CAM_DataModel* dm, const int idx ) return true; } -/*! Remove data model from list - * \param dm data model - * \retval true - if all ok, else false. - */ +/*! + \brief Remove data model from the study. + \param dm data model being removed + \return \c true on success and \c false on error +*/ bool CAM_Study::removeDataModel( const CAM_DataModel* dm ) { if ( !dm ) @@ -96,29 +124,38 @@ bool CAM_Study::removeDataModel( const CAM_DataModel* dm ) if ( aModelRoot ) aModelRoot->setDataModel( 0 ); - return myDataModels.remove( dm ); + return myDataModels.removeAll( (CAM_DataModel*)dm ); } -/*!Check data model contains in list. - * \param dm - data model - * \retval true - if data model in list, else false. - */ +/*! + \brief Check if data model is contained in the list. + \param dm data model + \return \c true if data model is in the list and \c false otherwise. +*/ bool CAM_Study::containsDataModel( const CAM_DataModel* dm ) const { - return myDataModels.contains( dm ); + return myDataModels.contains( (CAM_DataModel*)dm ); } -/*!Gets list of all data models. - * \param lst - output data model list. - */ +/*! + \brief Get all data models. + \param lst returning list of data model. +*/ void CAM_Study::dataModels( ModelList& lst ) const { lst.clear(); - for ( ModelListIterator it( myDataModels ); it.current(); ++it ) - lst.append( it.current() ); + for( QList::const_iterator it = myDataModels.begin(); + it != myDataModels.end(); ++it ) + lst.append( *it ); } -/*! Open data model \a dModel, if it saved*/ +/*! + \brief Called when data model is inserted in the study. + + Open data model \a dModel, if it is saved and update data tree. + + \param dModel data model +*/ void CAM_Study::dataModelInserted( const CAM_DataModel* dModel ) { CAM_DataModel* dm = (CAM_DataModel*)dModel; @@ -131,19 +168,34 @@ void CAM_Study::dataModelInserted( const CAM_DataModel* dModel ) updateModelRoot( dm ); } -/*! \retval false*/ +/*! + \brief Called when data model is opened. + + Base implementation does nothing and returns \c false. + + \return \c true on success and \c false on error +*/ bool CAM_Study::openDataModel( const QString&, CAM_DataModel* ) { return false; } -/*! \retval false*/ +/*! + \brief Called when data model is saved. + + Base implementation does nothing and returns \c false. + + \return \c true on success and \c false on error +*/ bool CAM_Study::saveDataModel( const QString&, CAM_DataModel* ) { return false; } -/*! Public slot. Update model root.*/ +/*! + \brief Update data model root object. + \param dm data model being updated. +*/ void CAM_Study::updateModelRoot( const CAM_DataModel* dm ) { if ( !root() ) @@ -168,7 +220,7 @@ void CAM_Study::updateModelRoot( const CAM_DataModel* dm ) if ( curRoot ) root()->replaceChild( curRoot, dm->root(), true ); else { - int idx = myDataModels.findRef( dm ); + int idx = myDataModels.indexOf( (CAM_DataModel*)dm ); if ( idx != -1 ) root()->insertChild( dm->root(), idx ); } diff --git a/src/CAM/CAM_Study.h b/src/CAM/CAM_Study.h index 18839617a..5d520d39a 100755 --- a/src/CAM/CAM_Study.h +++ b/src/CAM/CAM_Study.h @@ -21,42 +21,31 @@ #include "CAM.h" -#include "CAM_DataModel.h" - #include +#include -#include +class CAM_DataModel; #ifdef WIN32 #pragma warning( disable:4251 ) #endif -/*! - \class CAM_Study - Represents study for using in CAM, contains list of - data model references from all modules. Provides - necessary functionality for data models management. -*/ class CAM_EXPORT CAM_Study : public SUIT_Study { Q_OBJECT public: - typedef QPtrList ModelList; - typedef QPtrListIterator ModelListIterator; + typedef QList ModelList; public: CAM_Study( SUIT_Application* ); virtual ~CAM_Study(); - virtual void closeDocument(bool permanently = true); + virtual void closeDocument( bool permanently = true ); - /** @name Insert data model methods.*/ - //@{ bool appendDataModel( const CAM_DataModel* ); virtual bool insertDataModel( const CAM_DataModel*, const int = -1 ); bool insertDataModel( const CAM_DataModel*, const CAM_DataModel* ); - //@} virtual bool removeDataModel( const CAM_DataModel* ); @@ -73,8 +62,7 @@ protected slots: virtual void updateModelRoot( const CAM_DataModel* ); private: - //! Data model list - ModelList myDataModels; + ModelList myDataModels; //!< data models list }; #ifdef WIN32 diff --git a/src/CAM/Makefile.am b/src/CAM/Makefile.am index 4e0a1e5f3..8c0b727a0 100755 --- a/src/CAM/Makefile.am +++ b/src/CAM/Makefile.am @@ -26,10 +26,10 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libCAM.la salomeinclude_HEADERS= \ + CAM.h \ CAM_Application.h \ CAM_DataModel.h \ CAM_DataObject.h \ - CAM.h \ CAM_Module.h \ CAM_Study.h \ CAM_RootObject.h @@ -53,7 +53,7 @@ nodist_salomeres_DATA=CAM_msg_en.qm libCAM_la_CPPFLAGS=$(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../STD -I$(srcdir)/../Qtx libCAM_la_LDFLAGS=$(QT_MT_LIBS) -libCAM_la_LIBS=../SUIT/libsuit.la ../STD/libstd.la +libCAM_la_LIBADD=../Qtx/libqtx.la ../SUIT/libsuit.la ../STD/libstd.la # what is that? #LDFLAGSFORBIN= -lSUITApp -- 2.39.2