@@ -48,6 +48,7 @@ QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags
48
48
, mPaintingEnabled( true )
49
49
, mHorizontalRuler( 0 )
50
50
, mVerticalRuler( 0 )
51
+ , mPanning( false )
51
52
{
52
53
Q_UNUSED ( f );
53
54
Q_UNUSED ( name );
@@ -83,6 +84,15 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
83
84
}
84
85
return ;
85
86
}
87
+ else if ( e->button () == Qt::MidButton )
88
+ {
89
+ // pan composer with middle button
90
+ mPanning = true ;
91
+ mMouseLastXY = e->pos ();
92
+ setCursor ( Qt::ClosedHandCursor );
93
+ e->accept ();
94
+ return ;
95
+ }
86
96
87
97
switch ( mCurrentTool )
88
98
{
@@ -310,6 +320,15 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
310
320
311
321
QPointF scenePoint = mapToScene ( e->pos () );
312
322
323
+ if ( mPanning )
324
+ {
325
+ // panning with middle button
326
+ mPanning = false ;
327
+ setCursor ( Qt::ArrowCursor );
328
+ e->accept ();
329
+ return ;
330
+ }
331
+
313
332
switch ( mCurrentTool )
314
333
{
315
334
case Select:
@@ -430,6 +449,15 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
430
449
QGraphicsView::mouseMoveEvent ( e );
431
450
}
432
451
}
452
+ else if ( mPanning )
453
+ {
454
+ // panning with middle mouse button, scroll view
455
+ horizontalScrollBar ()->setValue ( horizontalScrollBar ()->value () - ( e->x () - mMouseLastXY .x () ) );
456
+ verticalScrollBar ()->setValue ( verticalScrollBar ()->value () - ( e->y () - mMouseLastXY .y () ) );
457
+ mMouseLastXY = e->pos ();
458
+ e->accept ();
459
+ return ;
460
+ }
433
461
else
434
462
{
435
463
QPointF scenePoint = mapToScene ( e->pos () );
@@ -757,16 +785,47 @@ void QgsComposerView::wheelEvent( QWheelEvent* event )
757
785
{
758
786
QPointF scenePoint = mapToScene ( event->pos () );
759
787
760
- // select topmost item at position of event
761
- QgsComposerItem* theItem = composition ()->composerItemAt ( scenePoint );
762
- if ( theItem )
788
+ if ( currentTool () == MoveItemContent )
763
789
{
764
- if ( theItem->isSelected () )
790
+ // move item content tool, so scroll events get handled by the composer item
791
+
792
+ // select topmost item at position of event
793
+ QgsComposerItem* theItem = composition ()->composerItemAt ( scenePoint );
794
+ if ( theItem )
765
795
{
766
- QPointF itemPoint = theItem->mapFromScene ( scenePoint );
767
- theItem->beginCommand ( tr ( " Zoom item content" ) );
768
- theItem->zoomContent ( event->delta (), itemPoint.x (), itemPoint.y () );
769
- theItem->endCommand ();
796
+ if ( theItem->isSelected () )
797
+ {
798
+ QPointF itemPoint = theItem->mapFromScene ( scenePoint );
799
+ theItem->beginCommand ( tr ( " Zoom item content" ) );
800
+ theItem->zoomContent ( event->delta (), itemPoint.x (), itemPoint.y () );
801
+ theItem->endCommand ();
802
+ }
803
+ }
804
+ }
805
+ else
806
+ {
807
+ // zoom whole composition
808
+ if ( event->delta () > 0 )
809
+ {
810
+ scale ( 2 , 2 );
811
+ }
812
+ else
813
+ {
814
+ scale ( 0.5 , 0.5 );
815
+ }
816
+
817
+ updateRulers ();
818
+ update ();
819
+ // redraw cached map items
820
+ QList<QGraphicsItem *> itemList = composition ()->items ();
821
+ QList<QGraphicsItem *>::iterator itemIt = itemList.begin ();
822
+ for ( ; itemIt != itemList.end (); ++itemIt )
823
+ {
824
+ QgsComposerMap* mypItem = dynamic_cast <QgsComposerMap *>( *itemIt );
825
+ if (( mypItem ) && ( mypItem->previewMode () == QgsComposerMap::Render ) )
826
+ {
827
+ mypItem->updateCachedImage ();
828
+ }
770
829
}
771
830
}
772
831
}
0 commit comments