Skip to content
Permalink
Browse files

Respect events which has been set to ignore in QgsLayoutViewTools

If ignored, default handling occurs
  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent dc0425a commit 4b89f5e4746e37b8d31b1fd5e8d8f8ed05a1300b
@@ -80,8 +80,10 @@ void QgsLayoutView::mousePressEvent( QMouseEvent *event )
{
std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
mTool->layoutPressEvent( me.get() );
event->setAccepted( me->isAccepted() );
}
else

if ( !mTool || !event->isAccepted() )
QGraphicsView::mousePressEvent( event );
}

@@ -91,8 +93,10 @@ void QgsLayoutView::mouseReleaseEvent( QMouseEvent *event )
{
std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
mTool->layoutReleaseEvent( me.get() );
event->setAccepted( me->isAccepted() );
}
else

if ( !mTool || !event->isAccepted() )
QGraphicsView::mouseReleaseEvent( event );
}

@@ -102,8 +106,10 @@ void QgsLayoutView::mouseMoveEvent( QMouseEvent *event )
{
std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
mTool->layoutMoveEvent( me.get() );
event->setAccepted( me->isAccepted() );
}
else

if ( !mTool || !event->isAccepted() )
QGraphicsView::mouseMoveEvent( event );
}

@@ -113,8 +119,10 @@ void QgsLayoutView::mouseDoubleClickEvent( QMouseEvent *event )
{
std::unique_ptr<QgsLayoutViewMouseEvent> me( new QgsLayoutViewMouseEvent( this, event ) );
mTool->layoutDoubleClickEvent( me.get() );
event->setAccepted( me->isAccepted() );
}
else

if ( !mTool || !event->isAccepted() )
QGraphicsView::mouseDoubleClickEvent( event );
}

@@ -124,22 +132,29 @@ void QgsLayoutView::wheelEvent( QWheelEvent *event )
{
mTool->wheelEvent( event );
}
else

if ( !mTool || !event->isAccepted() )
QGraphicsView::wheelEvent( event );
}

void QgsLayoutView::keyPressEvent( QKeyEvent *event )
{
if ( mTool )
{
mTool->keyPressEvent( event );
else
}

if ( !mTool || !event->isAccepted() )
QGraphicsView::keyPressEvent( event );
}

void QgsLayoutView::keyReleaseEvent( QKeyEvent *event )
{
if ( mTool )
{
mTool->keyReleaseEvent( event );
else
}

if ( !mTool || !event->isAccepted() )
QGraphicsView::keyReleaseEvent( event );
}
@@ -43,6 +43,7 @@ void QgsLayoutViewToolAddItem::layoutPressEvent( QgsLayoutViewMouseEvent *event
{
if ( event->button() != Qt::LeftButton )
{
event->ignore();
return;
}

@@ -61,12 +62,17 @@ void QgsLayoutViewToolAddItem::layoutMoveEvent( QgsLayoutViewMouseEvent *event )
{
mRubberBand->update( event->layoutPoint(), event->modifiers() );
}
else
{
event->ignore();
}
}

void QgsLayoutViewToolAddItem::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
{
if ( event->button() != Qt::LeftButton || !mDrawing )
{
event->ignore();
return;
}
mDrawing = false;
@@ -28,6 +28,7 @@ void QgsLayoutViewToolPan::layoutPressEvent( QgsLayoutViewMouseEvent *event )
{
if ( event->button() != Qt::LeftButton )
{
event->ignore();
return;
}

@@ -39,7 +40,10 @@ void QgsLayoutViewToolPan::layoutPressEvent( QgsLayoutViewMouseEvent *event )
void QgsLayoutViewToolPan::layoutMoveEvent( QgsLayoutViewMouseEvent *event )
{
if ( !mIsPanning )
{
event->ignore();
return;
}

view()->horizontalScrollBar()->setValue( view()->horizontalScrollBar()->value() - ( event->x() - mLastMousePos.x() ) );
view()->verticalScrollBar()->setValue( view()->verticalScrollBar()->value() - ( event->y() - mLastMousePos.y() ) );
@@ -50,6 +54,7 @@ void QgsLayoutViewToolPan::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
{
if ( !mIsPanning || event->button() != Qt::LeftButton )
{
event->ignore();
return;
}

@@ -36,6 +36,7 @@ void QgsLayoutViewToolZoom::layoutPressEvent( QgsLayoutViewMouseEvent *event )
{
if ( event->button() != Qt::LeftButton )
{
event->ignore();
return;
}

@@ -64,7 +65,10 @@ void QgsLayoutViewToolZoom::layoutPressEvent( QgsLayoutViewMouseEvent *event )
void QgsLayoutViewToolZoom::layoutMoveEvent( QgsLayoutViewMouseEvent *event )
{
if ( !mMarqueeZoom )
{
event->ignore();
return;
}

mRubberBand->update( event->layoutPoint(), 0 );
}
@@ -73,6 +77,7 @@ void QgsLayoutViewToolZoom::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
{
if ( !mMarqueeZoom || event->button() != Qt::LeftButton )
{
event->ignore();
return;
}

@@ -99,7 +104,7 @@ void QgsLayoutViewToolZoom::layoutReleaseEvent( QgsLayoutViewMouseEvent *event )
void QgsLayoutViewToolZoom::keyPressEvent( QKeyEvent *event )
{
//respond to changes in the alt key status and update cursor accordingly
if ( ! event->isAutoRepeat() )
if ( !event->isAutoRepeat() )
{
QPixmap zoomQPixmap = QPixmap( ( const char ** )( ( event->modifiers() & Qt::AltModifier ) ? zoom_out : zoom_in ) );
QCursor zoomCursor = QCursor( zoomQPixmap, 7, 7 );

0 comments on commit 4b89f5e

Please sign in to comment.
You can’t perform that action at this time.