Beispiel #1
0
void QgsComposerItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
{
    if ( mItemPositionLocked )
    {
        return;
    }

    //set current position and type of mouse move action
    mMouseMoveStartPos = event->lastScenePos();
    mLastMouseEventPos = event->lastScenePos();
    mCurrentMouseMoveAction = mouseMoveActionForPosition( event->pos() );

    //remove the old rubber band item if it is still there
    if ( mBoundingResizeRectangle )
    {
        scene()->removeItem( mBoundingResizeRectangle );
        delete mBoundingResizeRectangle;
        mBoundingResizeRectangle = 0;
    }
    //create and show bounding rectangle
    mBoundingResizeRectangle = new QGraphicsRectItem( 0 );
    scene()->addItem( mBoundingResizeRectangle );
    mBoundingResizeRectangle->setRect( QRectF( 0, 0, rect().width(), rect().height() ) );
    QTransform resizeTransform;
    resizeTransform.translate( transform().dx(), transform().dy() );
    mBoundingResizeRectangle->setTransform( resizeTransform );

    mBoundingResizeRectangle->setBrush( Qt::NoBrush );
    mBoundingResizeRectangle->setPen( QPen( QColor( 0, 0, 0 ), 0 ) );
    mBoundingResizeRectangle->setZValue( 90 );
    mBoundingResizeRectangle->show();
}
Beispiel #2
0
Qt::CursorShape QgsComposerItem::cursorForPosition( const QPointF& itemCoordPos )
{
    QgsComposerItem::MouseMoveAction mouseAction = mouseMoveActionForPosition( itemCoordPos );

    if ( mouseAction == QgsComposerItem::NoAction )
    {
        return Qt::ForbiddenCursor;
    }
    if ( mouseAction == QgsComposerItem::MoveItem )
    {
        return Qt::ClosedHandCursor;
    }
    else if ( mouseAction == QgsComposerItem::ResizeLeftUp || mouseAction == QgsComposerItem::ResizeRightDown )
    {
        return Qt::SizeFDiagCursor;
    }
    else if ( mouseAction == QgsComposerItem::ResizeLeftDown || mouseAction == QgsComposerItem::ResizeRightUp )
    {
        return Qt::SizeBDiagCursor;
    }
    else if ( mouseAction == QgsComposerItem::ResizeUp || mouseAction == QgsComposerItem::ResizeDown )
    {
        return Qt::SizeVerCursor;
    }
    else //if(mouseAction == QgsComposerItem::ResizeLeft || mouseAction == QgsComposerItem::ResizeRight)
    {
        return Qt::SizeHorCursor;
    }
}
Beispiel #3
0
Qt::CursorShape QgsComposerItem::cursorForPosition( const QPointF& itemCoordPos )
{
  QgsComposerItem::MouseMoveAction mouseAction = mouseMoveActionForPosition( itemCoordPos );
  switch ( mouseAction )
  {
    case NoAction:
      return Qt::ForbiddenCursor;
    case MoveItem:
      return Qt::SizeAllCursor;
    case ResizeUp:
    case ResizeDown:
      return Qt::SizeVerCursor;
    case ResizeLeft:
    case ResizeRight:
      return Qt::SizeHorCursor;
    case ResizeLeftUp:
    case ResizeRightDown:
      return Qt::SizeFDiagCursor;
    case ResizeRightUp:
    case ResizeLeftDown:
      return Qt::SizeBDiagCursor;
    default:
      return Qt::ArrowCursor;
  }
}