#include "SalomeApp_Application.h"
#include "SalomeApp_Preferences.h"
#include "SalomeApp_UpdateFlags.h"
+#include "SalomeApp_Operation.h"
#include <OB_Browser.h>
{
}
+void SalomeApp_Module::startOperation( const int id )
+{
+ SalomeApp_Operation* op = 0;
+ if( myOperations.contains( id ) )
+ op = myOperations[ id ];
+ else
+ {
+ op = createOperation( id );
+ if( op )
+ {
+ myOperations.insert( id, op );
+ op->setModule( this );
+ connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
+ connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
+ }
+ }
+ if( op )
+ op->start();
+}
+SalomeApp_Operation* SalomeApp_Module::createOperation( const int ) const
+{
+ return 0;
+}
+void SalomeApp_Module::onOperationStopped( SUIT_Operation* )
+{
+}
-
-
-
-
-
-
-
-
-
-
-
-
+void SalomeApp_Module::onOperationDestroyed()
+{
+ const QObject* s = sender();
+ if( s && s->inherits( "SalomeApp_Operation" ) )
+ {
+ const SalomeApp_Operation* op = ( SalomeApp_Operation* )s;
+ MapOfOperation::const_iterator anIt = myOperations.begin(),
+ aLast = myOperations.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data()==op )
+ {
+ myOperations.remove( anIt.key() );
+ break;
+ }
+ }
+}
class SalomeApp_Application;
class SalomeApp_Preferences;
class SalomeApp_SelectionManager;
+class SalomeApp_Operation;
/*
Class : SalomeApp_Module
virtual void onModelSaved();
virtual void onModelOpened();
virtual void onModelClosed();
+ virtual void onOperationStopped( SUIT_Operation* );
+ virtual void onOperationDestroyed();
protected:
QtxPopupMgr* popupMgr();
virtual SalomeApp_Selection* createSelection() const;
virtual void updateControls();
+ /*! Module stores operations in map. This method starts operation by id.
+ * If operation isn't in map, then it will be created by createOperation method
+ * and will be inserted to map
+ */
+ void startOperation( const int );
+
+ /*! Create operation by its id. You must not call this method, it will be called automatically
+ * by startOperation. Please redefine this method in current module
+ */
+ virtual SalomeApp_Operation* createOperation( const int ) const;
+
int addPreference( const QString& label );
int addPreference( const QString& label, const int pId, const int = -1,
const QString& section = QString::null,
void setPreferenceProperty( const int, const QString&, const QVariant& );
private:
- QtxPopupMgr* myPopupMgr;
+ typedef QMap<int,SalomeApp_Operation*> MapOfOperation;
+
+private:
+ QtxPopupMgr* myPopupMgr;
+ MapOfOperation myOperations;
};
#endif