Exemple #1
0
void QgsComposerView::wheelEvent( QWheelEvent* event )
{
  if ( currentTool() == MoveItemContent )
  {
    //move item content tool, so scroll events get handled by the selected composer item

    QPointF scenePoint = mapToScene( event->pos() );
    //select topmost item at position of event
    QgsComposerItem* theItem = composition()->composerItemAt( scenePoint );
    if ( theItem )
    {
      if ( theItem->isSelected() )
      {
        QPointF itemPoint = theItem->mapFromScene( scenePoint );
        theItem->beginCommand( tr( "Zoom item content" ) );
        theItem->zoomContent( event->delta(), itemPoint.x(), itemPoint.y() );
        theItem->endCommand();
      }
    }
  }
  else
  {
    //not using move item content tool, so zoom whole composition
    wheelZoom( event );
  }
}
void QgsComposerView::wheelEvent( QWheelEvent* event )
{
  QPointF scenePoint = mapToScene( event->pos() );

  //select topmost item at position of event
  QgsComposerItem* theItem = composition()->composerItemAt( scenePoint );
  if ( theItem )
  {
    if ( theItem->isSelected() )
    {
      QPointF itemPoint = theItem->mapFromScene( scenePoint );
      theItem->beginCommand( tr( "Zoom item content" ) );
      theItem->zoomContent( event->delta(), itemPoint.x(), itemPoint.y() );
      theItem->endCommand();
    }
  }
}
Exemple #3
0
void QgsComposerView::wheelEvent( QWheelEvent* event )
{
  if ( mRubberBandItem || mRubberBandLineItem )
  {
    //ignore wheel events while marquee operations are active (eg, creating new item)
    return;
  }

  if ( composition()->selectionHandles()->isDragging() || composition()->selectionHandles()->isResizing() )
  {
    //ignore wheel events while dragging/resizing items
    return;
  }

  if ( currentTool() == MoveItemContent )
  {
    //move item content tool, so scroll events get handled by the selected composer item

    QPointF scenePoint = mapToScene( event->pos() );
    //select topmost item at position of event
    QgsComposerItem* theItem = composition()->composerItemAt( scenePoint, true );
    if ( theItem )
    {
      if ( theItem->isSelected() )
      {
        QPointF itemPoint = theItem->mapFromScene( scenePoint );
        theItem->beginCommand( tr( "Zoom item content" ) );
        theItem->zoomContent( event->delta(), itemPoint.x(), itemPoint.y() );
        theItem->endCommand();
      }
    }
  }
  else
  {
    //not using move item content tool, so zoom whole composition
    wheelZoom( event );
  }
}