From: ouv Date: Mon, 6 Dec 2010 09:51:20 +0000 (+0000) Subject: Introducing "ImmediateSelectionEnabled" flag. It allows, when the right mouse button... X-Git-Tag: DIAGRAM_0_1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ffc56ffb343cd0d157329b1b56a9877f03af381d;p=modules%2Fgui.git Introducing "ImmediateSelectionEnabled" flag. It allows, when the right mouse button clicked on a non-selected object, to pre-select this object first, before a context menu is displayed. --- diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index 105d7fcb2..faa4ff7f2 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -44,7 +44,8 @@ GraphicsView_Viewer::GraphicsView_Viewer( const QString& title ) : SUIT_ViewModel(), mySelector( 0 ), myTransformer( 0 ), - myIsInitialized( false ) + myIsInitialized( false ), + myIsImmediateSelectionEnabled( false ) { } @@ -178,6 +179,15 @@ void GraphicsView_Viewer::setIsInitialized( bool theFlag ) myIsInitialized = theFlag; } +//================================================================ +// Function : setIsImmediateSelectionEnabled +// Purpose : +//================================================================ +void GraphicsView_Viewer::setIsImmediateSelectionEnabled( bool theFlag ) +{ + myIsImmediateSelectionEnabled = theFlag; +} + //================================================================ // Function : createTransformer // Purpose : @@ -270,6 +280,11 @@ void GraphicsView_Viewer::handleMousePress( QGraphicsSceneMouseEvent* e ) else if ( bs == GraphicsView_ViewTransformer::panButton() ) activateTransform( Pan ); } + else if ( e->button() == Qt::RightButton && isImmediateSelectionEnabled() ) + { + bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() ); + getSelector()->select( QRectF(), append ); + } else // checking for other operations before selection in release event startOperations( e ); } diff --git a/src/GraphicsView/GraphicsView_Viewer.h b/src/GraphicsView/GraphicsView_Viewer.h index 225a7d708..f6d70147e 100644 --- a/src/GraphicsView/GraphicsView_Viewer.h +++ b/src/GraphicsView/GraphicsView_Viewer.h @@ -75,6 +75,9 @@ public: bool isInitialized() const { return myIsInitialized; } void setIsInitialized( bool ); + bool isImmediateSelectionEnabled() const { return myIsImmediateSelectionEnabled; } + void setIsImmediateSelectionEnabled( bool ); + signals: void selectionChanged( GV_SelectionChangeStatus ); @@ -109,6 +112,7 @@ protected: GraphicsView_ViewTransformer* myTransformer; bool myIsInitialized; + bool myIsImmediateSelectionEnabled; }; #endif