Keep composer multi-item selection only when Shift is pressed during click

- Fixes issues where Shift was still registered as pressed when shift click happened outside of view (due to lingering keyboard focus)
This commit is contained in:
Larry Shaffer 2013-03-06 19:47:32 -07:00
parent 4a36cbdda8
commit 2fe847c9cf
3 changed files with 1 additions and 18 deletions

View File

@ -67,7 +67,6 @@ class QgsComposerView: QGraphicsView
void mouseDoubleClickEvent( QMouseEvent* e ); void mouseDoubleClickEvent( QMouseEvent* e );
void keyPressEvent( QKeyEvent * e ); void keyPressEvent( QKeyEvent * e );
void keyReleaseEvent( QKeyEvent * e );
void wheelEvent( QWheelEvent* event ); void wheelEvent( QWheelEvent* event );

View File

@ -39,7 +39,6 @@
QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags f ) QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags f )
: QGraphicsView( parent ) : QGraphicsView( parent )
, mShiftKeyPressed( false )
, mRubberBandItem( 0 ) , mRubberBandItem( 0 )
, mRubberBandLineItem( 0 ) , mRubberBandLineItem( 0 )
, mMoveContentItem( 0 ) , mMoveContentItem( 0 )
@ -84,7 +83,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
//select/deselect items and pass mouse event further //select/deselect items and pass mouse event further
case Select: case Select:
{ {
if ( !mShiftKeyPressed ) //keep selection if shift key pressed if ( !( e->modifiers() & Qt::ShiftModifier ) ) //keep selection if shift key pressed
{ {
composition()->clearSelection(); composition()->clearSelection();
} }
@ -449,10 +448,6 @@ void QgsComposerView::mouseDoubleClickEvent( QMouseEvent* e )
void QgsComposerView::keyPressEvent( QKeyEvent * e ) void QgsComposerView::keyPressEvent( QKeyEvent * e )
{ {
//TODO : those should be actions (so we could also display menu items and/or toolbar items) //TODO : those should be actions (so we could also display menu items and/or toolbar items)
if ( e->key() == Qt::Key_Shift )
{
mShiftKeyPressed = true;
}
if ( !composition() ) if ( !composition() )
{ {
@ -562,14 +557,6 @@ void QgsComposerView::keyPressEvent( QKeyEvent * e )
} }
} }
void QgsComposerView::keyReleaseEvent( QKeyEvent * e )
{
if ( e->key() == Qt::Key_Shift )
{
mShiftKeyPressed = false;
}
}
void QgsComposerView::wheelEvent( QWheelEvent* event ) void QgsComposerView::wheelEvent( QWheelEvent* event )
{ {
QPointF scenePoint = mapToScene( event->pos() ); QPointF scenePoint = mapToScene( event->pos() );

View File

@ -96,7 +96,6 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void mouseDoubleClickEvent( QMouseEvent* e ); void mouseDoubleClickEvent( QMouseEvent* e );
void keyPressEvent( QKeyEvent * e ); void keyPressEvent( QKeyEvent * e );
void keyReleaseEvent( QKeyEvent * e );
void wheelEvent( QWheelEvent* event ); void wheelEvent( QWheelEvent* event );
@ -106,8 +105,6 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void showEvent( QShowEvent* e ); void showEvent( QShowEvent* e );
private: private:
/**Status of shift key (used for multiple selection)*/
bool mShiftKeyPressed;
/**Current composer tool*/ /**Current composer tool*/
QgsComposerView::Tool mCurrentTool; QgsComposerView::Tool mCurrentTool;
/**Rubber band item*/ /**Rubber band item*/