#include <SalomeApp_Application.h>
#include <SalomeApp_Operation.h>
#include <SalomeApp_SelectionMgr.h>
+#include <SalomeApp_Dialog.h>
#include <SUIT_Desktop.h>
// 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 )
{
}
return myModule;
}
+//=======================================================================
+// name : setModule
+// Purpose :
+//=======================================================================
void SalomeApp_Operation::setModule( SalomeApp_Module* theModule )
{
myModule = theModule;
+ setApplication( myModule ? myModule->application() : 0 );
}
//=======================================================================
//=======================================================================
void SalomeApp_Operation::resumeOperation()
{
- if ( dlg() )
- dlg()->removeEventFilter( this );
- activateSelection();
+ setDialogActive( true );
}
//=======================================================================
//=======================================================================
void SalomeApp_Operation::suspendOperation()
{
- if ( dlg() )
- dlg()->installEventFilter( this );
+ setDialogActive( false );
}
//=======================================================================
//=======================================================================
void SalomeApp_Operation::abortOperation()
{
+ setDialogActive( true );
if ( dlg() )
- {
- dlg()->removeEventFilter( this );
dlg()->hide();
- }
if( selectionMgr() )
disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
//=======================================================================
void SalomeApp_Operation::commitOperation()
{
+ setDialogActive( true );
if ( dlg() )
- {
- dlg()->removeEventFilter( this );
dlg()->hide();
- }
if( selectionMgr() )
disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
{
}
-//=======================================================================
-// name : isActive
-// Purpose : Verify whether operator is active one
-//=======================================================================
-bool SalomeApp_Operation::isActive() const
-{
- return activeOperation() == this;
-}
-
//=======================================================================
// name : activeOperation
// Purpose : Get active operation
//=======================================================================
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 )
{
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
#define SalomeApp_Operation_H
#include <SUIT_Operation.h>
-#include <SalomeApp_Dialog.h>
class SalomeApp_Module;
class SalomeApp_Application;
class SalomeApp_Operation;
class SalomeApp_SelectionMgr;
+class SalomeApp_Dialog;
class SUIT_Desktop;
/*
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;
// 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)
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
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
// Block mouse and key events if operator is not active one
private:
-
SalomeApp_Module* myModule;
+ bool myIsAutoResumed;
};
#endif