From: asl Date: Thu, 7 Jul 2005 08:51:24 +0000 (+0000) Subject: 1) SalomeApp_Application* was removed from constructor of operation. It will be set... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3aefdf44599a2b7569664881d4b68d9ea6a6066;p=modules%2Fgui.git 1) SalomeApp_Application* was removed from constructor of operation. It will be set by method setModule 2) Operation has "autoResumed" state. If it is true, the operation will be resume automatically, when according dialog become active. If not, somebody must call resume manually. --- diff --git a/src/SalomeApp/SalomeApp_Operation.cxx b/src/SalomeApp/SalomeApp_Operation.cxx index 7592d3716..1bfaeefca 100755 --- a/src/SalomeApp/SalomeApp_Operation.cxx +++ b/src/SalomeApp/SalomeApp_Operation.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -25,9 +26,10 @@ // name : SalomeApp_Operation // Purpose : Constructor //======================================================================= -SalomeApp_Operation::SalomeApp_Operation( SalomeApp_Application* theApp ) -: SUIT_Operation( theApp ), - myModule( 0 ) +SalomeApp_Operation::SalomeApp_Operation() +: SUIT_Operation( 0 ), + myModule( 0 ), + myIsAutoResumed( false ) { } @@ -46,9 +48,14 @@ SalomeApp_Module* SalomeApp_Operation::module() const return myModule; } +//======================================================================= +// name : setModule +// Purpose : +//======================================================================= void SalomeApp_Operation::setModule( SalomeApp_Module* theModule ) { myModule = theModule; + setApplication( myModule ? myModule->application() : 0 ); } //======================================================================= @@ -67,9 +74,7 @@ SUIT_Desktop* SalomeApp_Operation::desktop() const //======================================================================= void SalomeApp_Operation::resumeOperation() { - if ( dlg() ) - dlg()->removeEventFilter( this ); - activateSelection(); + setDialogActive( true ); } //======================================================================= @@ -88,8 +93,7 @@ void SalomeApp_Operation::startOperation() //======================================================================= void SalomeApp_Operation::suspendOperation() { - if ( dlg() ) - dlg()->installEventFilter( this ); + setDialogActive( false ); } //======================================================================= @@ -98,11 +102,9 @@ void SalomeApp_Operation::suspendOperation() //======================================================================= void SalomeApp_Operation::abortOperation() { + setDialogActive( true ); if ( dlg() ) - { - dlg()->removeEventFilter( this ); dlg()->hide(); - } if( selectionMgr() ) disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) ); @@ -114,11 +116,9 @@ void SalomeApp_Operation::abortOperation() //======================================================================= void SalomeApp_Operation::commitOperation() { + setDialogActive( true ); if ( dlg() ) - { - dlg()->removeEventFilter( this ); dlg()->hide(); - } if( selectionMgr() ) disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) ); @@ -155,15 +155,6 @@ void SalomeApp_Operation::selectionDone() { } -//======================================================================= -// name : isActive -// Purpose : Verify whether operator is active one -//======================================================================= -bool SalomeApp_Operation::isActive() const -{ - return activeOperation() == this; -} - //======================================================================= // name : activeOperation // Purpose : Get active operation @@ -201,13 +192,29 @@ void SalomeApp_Operation::onSelectionDone() //======================================================================= bool SalomeApp_Operation::eventFilter( QObject* obj, QEvent* e ) { - // to do + if( e ) + { + if( isAutoResumed() && + ( e->type()==QEvent::Enter || + e->type()==QEvent::WindowActivate || + e->type()==QEvent::MouseButtonPress || + e->type()==QEvent::MouseButtonDblClick ) ) + resume(); + + else if( e->type()==QEvent::MouseButtonRelease || + e->type()==QEvent::MouseButtonDblClick || + e->type()==QEvent::MouseMove || + e->type()==QEvent::KeyPress || + e->type()==QEvent::KeyRelease ) + return true; + } + return SUIT_Operation::eventFilter( obj, e ); } //======================================================================= -// name : eventFilter -// Purpose : Block mouse and key events if operator is not active one +// name : update +// Purpose : //======================================================================= void SalomeApp_Operation::update( const int flags ) { @@ -215,3 +222,38 @@ void SalomeApp_Operation::update( const int flags ) myModule->update( flags ); } +//======================================================================= +// name : update +// Purpose : +//======================================================================= +void SalomeApp_Operation::setDialogActive( const bool active ) +{ + if( dlg() ) + if( active ) + { + dlg()->removeEventFilter( this ); + activateSelection(); + } + else + dlg()->installEventFilter( this ); +} + +//======================================================================= +// name : update +// Purpose : +//======================================================================= +bool SalomeApp_Operation::isAutoResumed() const +{ + return myIsAutoResumed; +} + +//======================================================================= +// name : update +// Purpose : +//======================================================================= +void SalomeApp_Operation::setAutoResumed( const bool on ) +{ + myIsAutoResumed = on; +} + + \ No newline at end of file diff --git a/src/SalomeApp/SalomeApp_Operation.h b/src/SalomeApp/SalomeApp_Operation.h index 82b8176b2..e5138c000 100755 --- a/src/SalomeApp/SalomeApp_Operation.h +++ b/src/SalomeApp/SalomeApp_Operation.h @@ -13,12 +13,12 @@ #define SalomeApp_Operation_H #include -#include class SalomeApp_Module; class SalomeApp_Application; class SalomeApp_Operation; class SalomeApp_SelectionMgr; +class SalomeApp_Dialog; class SUIT_Desktop; /* @@ -31,15 +31,23 @@ class SalomeApp_Operation : public SUIT_Operation Q_OBJECT public: - - SalomeApp_Operation( SalomeApp_Application* theApp ); + SalomeApp_Operation(); virtual ~SalomeApp_Operation(); - void setModule( SalomeApp_Module* ); + virtual void setModule( SalomeApp_Module* ); // Set module + SalomeApp_Module* module() const; + // Get module + + //! Check if operation will be resumed automatically when mouse enter the dialog + bool isAutoResumed() const; + protected: + //! Set auto resumed state + void setAutoResumed( const bool ); + // Important virtual methods (should be redefined in the derived classes) virtual SalomeApp_Dialog* dlg() const; @@ -50,6 +58,9 @@ protected: // 2. activated in resumeOperation method // 3. hidden in abortOperation and commitOperation methods + virtual void setDialogActive( const bool ); + // Change the active state of dialog (given by dlg()) + virtual void activateSelection(); // Activate selection. This method should be redefined in derived // classes if they use own selection modes (different from default) @@ -64,7 +75,7 @@ protected: virtual void suspendOperation(); // Disable dialog for mouse and key events - + virtual void resumeOperation(); // Enable dialog if it was deactivated (in suspend method) and activate selection @@ -73,13 +84,7 @@ protected: virtual void commitOperation(); // Hide dialog box (if it is exists) - - bool isActive() const; - // Verify whether operator is active one - - SalomeApp_Module* module() const; - // Get module - + SUIT_Desktop* desktop() const; // Get desktop @@ -103,8 +108,8 @@ private: // Block mouse and key events if operator is not active one private: - SalomeApp_Module* myModule; + bool myIsAutoResumed; }; #endif