From: sln Date: Thu, 7 Jul 2011 09:52:04 +0000 (+0000) Subject: Now opertaion() method can create opertaion if it does not exist X-Git-Tag: DIAGRAM_1_0~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8bd673e1cb1ab429f0eb66a627d2eb6b0ce92b49;p=modules%2Fgui.git Now opertaion() method can create opertaion if it does not exist --- diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 25d3796b2..332e4a70a 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -628,11 +628,23 @@ void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* ) \brief Returns instance of operation by its id; if there is no operation corresponding to this id, null pointer is returned \param id - operation id + \param toCreate - specify whether operation has to be created if it dos not exist \return operation instance */ -LightApp_Operation* LightApp_Module::operation( const int id ) const +LightApp_Operation* LightApp_Module::operation( const int id, const bool toCreate ) const { - return myOperations.contains( id ) ? myOperations[id] : 0; + LightApp_Operation* op = 0; + + if ( myOperations.contains( id ) ) + op = myOperations[ id ]; + else if ( toCreate ) + { + op = createOperation( id ); + if ( op ) + ((LightApp_Module*)this)->myOperations.insert( id, op ); + } + + return op; } /*! diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index e7891b8d2..95206ec46 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -137,7 +137,7 @@ protected: virtual bool isSelectionCompatible(); - LightApp_Operation* operation( const int ) const; + LightApp_Operation* operation( const int, const bool toCreate = false ) const; private: typedef QMap MapOfOperation;