@@ -47,6 +47,7 @@ QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags
47
47
, mPaintingEnabled( true )
48
48
, mHorizontalRuler( 0 )
49
49
, mVerticalRuler( 0 )
50
+ , mPanning( false )
50
51
{
51
52
Q_UNUSED ( f );
52
53
Q_UNUSED ( name );
@@ -82,6 +83,15 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
82
83
}
83
84
return ;
84
85
}
86
+ else if ( e->button () == Qt::MidButton )
87
+ {
88
+ // pan composer with middle button
89
+ mPanning = true ;
90
+ mMouseLastXY = e->pos ();
91
+ setCursor ( Qt::ClosedHandCursor );
92
+ e->accept ();
93
+ return ;
94
+ }
85
95
86
96
switch ( mCurrentTool )
87
97
{
@@ -279,6 +289,15 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
279
289
280
290
QPointF scenePoint = mapToScene ( e->pos () );
281
291
292
+ if ( mPanning )
293
+ {
294
+ // panning with middle button
295
+ mPanning = false ;
296
+ setCursor ( Qt::ArrowCursor );
297
+ e->accept ();
298
+ return ;
299
+ }
300
+
282
301
switch ( mCurrentTool )
283
302
{
284
303
case Select:
@@ -399,6 +418,15 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
399
418
QGraphicsView::mouseMoveEvent ( e );
400
419
}
401
420
}
421
+ else if ( mPanning )
422
+ {
423
+ // panning with middle mouse button, scroll view
424
+ horizontalScrollBar ()->setValue ( horizontalScrollBar ()->value () - ( e->x () - mMouseLastXY .x () ) );
425
+ verticalScrollBar ()->setValue ( verticalScrollBar ()->value () - ( e->y () - mMouseLastXY .y () ) );
426
+ mMouseLastXY = e->pos ();
427
+ e->accept ();
428
+ return ;
429
+ }
402
430
else
403
431
{
404
432
QPointF scenePoint = mapToScene ( e->pos () );
@@ -627,16 +655,47 @@ void QgsComposerView::wheelEvent( QWheelEvent* event )
627
655
{
628
656
QPointF scenePoint = mapToScene ( event->pos () );
629
657
630
- // select topmost item at position of event
631
- QgsComposerItem* theItem = composition ()->composerItemAt ( scenePoint );
632
- if ( theItem )
658
+ if ( currentTool () == MoveItemContent )
633
659
{
634
- if ( theItem->isSelected () )
660
+ // move item content tool, so scroll events get handled by the composer item
661
+
662
+ // select topmost item at position of event
663
+ QgsComposerItem* theItem = composition ()->composerItemAt ( scenePoint );
664
+ if ( theItem )
635
665
{
636
- QPointF itemPoint = theItem->mapFromScene ( scenePoint );
637
- theItem->beginCommand ( tr ( " Zoom item content" ) );
638
- theItem->zoomContent ( event->delta (), itemPoint.x (), itemPoint.y () );
639
- theItem->endCommand ();
666
+ if ( theItem->isSelected () )
667
+ {
668
+ QPointF itemPoint = theItem->mapFromScene ( scenePoint );
669
+ theItem->beginCommand ( tr ( " Zoom item content" ) );
670
+ theItem->zoomContent ( event->delta (), itemPoint.x (), itemPoint.y () );
671
+ theItem->endCommand ();
672
+ }
673
+ }
674
+ }
675
+ else
676
+ {
677
+ // zoom whole composition
678
+ if ( event->delta () > 0 )
679
+ {
680
+ scale ( 2 , 2 );
681
+ }
682
+ else
683
+ {
684
+ scale ( 0.5 , 0.5 );
685
+ }
686
+
687
+ updateRulers ();
688
+ update ();
689
+ // redraw cached map items
690
+ QList<QGraphicsItem *> itemList = composition ()->items ();
691
+ QList<QGraphicsItem *>::iterator itemIt = itemList.begin ();
692
+ for ( ; itemIt != itemList.end (); ++itemIt )
693
+ {
694
+ QgsComposerMap* mypItem = dynamic_cast <QgsComposerMap *>( *itemIt );
695
+ if (( mypItem ) && ( mypItem->previewMode () == QgsComposerMap::Render ) )
696
+ {
697
+ mypItem->updateCachedImage ();
698
+ }
640
699
}
641
700
}
642
701
}
0 commit comments