Skip to content
Permalink
Browse files

Replace use of deprecated QMouseEvent::posF()

  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent 31fcc67 commit 422963e995970cfa6f43c7dd75cee25860e79134
@@ -94,12 +94,12 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
return;
}

mLastMousePosition = e->posF();
mLastMousePosition = e->pos();

QgsMapCanvasAnnotationItem *item = selectedItem();
if ( item )
{
mCurrentMoveAction = item->moveActionForPosition( e->posF() );
mCurrentMoveAction = item->moveActionForPosition( e->pos() );
if ( mCurrentMoveAction != QgsMapCanvasAnnotationItem::NoAction )
{
return;
@@ -110,7 +110,7 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
{
//select a new item if there is one at this position
mCanvas->scene()->clearSelection();
QgsMapCanvasAnnotationItem *existingItem = itemAtPos( e->posF() );
QgsMapCanvasAnnotationItem *existingItem = itemAtPos( e->pos() );
if ( existingItem )
{
existingItem->setSelected( true );
@@ -124,8 +124,8 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
QgsPointXY mapPos = transformCanvasToAnnotation( toMapCoordinates( e->pos() ), annotation );
annotation->setMapPosition( mapPos );
annotation->setMapPositionCrs( mCanvas->mapSettings().destinationCrs() );
annotation->setRelativePosition( QPointF( e->posF().x() / mCanvas->width(),
e->posF().y() / mCanvas->height() ) );
annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(),
e->pos().y() / mCanvas->height() ) );
annotation->setFrameSize( QSizeF( 200, 100 ) );

QgsProject::instance()->annotationManager()->addAnnotation( annotation );
@@ -184,17 +184,17 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
{
QgsPointXY mapPos = transformCanvasToAnnotation( e->snapPoint(), annotation );
annotation->setMapPosition( mapPos );
annotation->setRelativePosition( QPointF( e->posF().x() / mCanvas->width(),
e->posF().y() / mCanvas->height() ) );
annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(),
e->pos().y() / mCanvas->height() ) );
item->update();
QgsProject::instance()->setDirty( true );
}
else if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::MoveFramePosition )
{
QPointF newCanvasPos = item->pos() + ( e->posF() - mLastMousePosition );
QPointF newCanvasPos = item->pos() + ( e->pos() - mLastMousePosition );
if ( annotation->hasFixedMapPosition() )
{
annotation->setFrameOffsetFromReferencePoint( annotation->frameOffsetFromReferencePoint() + ( e->posF() - mLastMousePosition ) );
annotation->setFrameOffsetFromReferencePoint( annotation->frameOffsetFromReferencePoint() + ( e->pos() - mLastMousePosition ) );
annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(),
newCanvasPos.y() / mCanvas->height() ) );
}
@@ -223,27 +223,27 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp )
{
xmax += e->posF().x() - mLastMousePosition.x();
xmax += e->pos().x() - mLastMousePosition.x();
}
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeft ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp )
{
xmin += e->posF().x() - mLastMousePosition.x();
relPosX = ( relPosX * mCanvas->width() + e->posF().x() - mLastMousePosition.x() ) / ( double )mCanvas->width();
xmin += e->pos().x() - mLastMousePosition.x();
relPosX = ( relPosX * mCanvas->width() + e->pos().x() - mLastMousePosition.x() ) / ( double )mCanvas->width();
}
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameUp ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp )
{
ymin += e->posF().y() - mLastMousePosition.y();
relPosY = ( relPosY * mCanvas->height() + e->posF().y() - mLastMousePosition.y() ) / ( double )mCanvas->height();
ymin += e->pos().y() - mLastMousePosition.y();
relPosY = ( relPosY * mCanvas->height() + e->pos().y() - mLastMousePosition.y() ) / ( double )mCanvas->height();
}
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameDown ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown ||
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown )
{
ymax += e->posF().y() - mLastMousePosition.y();
ymax += e->pos().y() - mLastMousePosition.y();
}

//switch min / max if necessary
@@ -270,18 +270,18 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
}
else if ( item )
{
QgsMapCanvasAnnotationItem::MouseMoveAction moveAction = item->moveActionForPosition( e->posF() );
QgsMapCanvasAnnotationItem::MouseMoveAction moveAction = item->moveActionForPosition( e->pos() );
if ( mCanvas )
{
mCanvas->setCursor( QCursor( item->cursorShapeForAction( moveAction ) ) );
}
}
mLastMousePosition = e->posF();
mLastMousePosition = e->pos();
}

void QgsMapToolAnnotation::canvasDoubleClickEvent( QgsMapMouseEvent *e )
{
QgsMapCanvasAnnotationItem *item = itemAtPos( e->posF() );
QgsMapCanvasAnnotationItem *item = itemAtPos( e->pos() );
if ( !item )
{
return;
@@ -60,7 +60,7 @@ class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool
QgsPointXY transformCanvasToAnnotation( QgsPointXY p, QgsAnnotation *annotation ) const;

QgsMapCanvasAnnotationItem::MouseMoveAction mCurrentMoveAction = QgsMapCanvasAnnotationItem::NoAction;
QPointF mLastMousePosition = QPointF( 0, 0 );
QPoint mLastMousePosition = QPoint( 0, 0 );
};

#endif // QGSMAPTOOLANNOTATION_H
@@ -571,7 +571,7 @@ void QgsLayoutRuler::setCursorPosition( QPointF position )

void QgsLayoutRuler::mouseMoveEvent( QMouseEvent *event )
{
mMarkerPos = event->posF();
mMarkerPos = event->pos();
update();

QPointF displayPos;
@@ -651,7 +651,7 @@ void QgsLayoutRuler::mouseMoveEvent( QMouseEvent *event )
}

//update cursor position in status bar
displayPos = mTransform.inverted().map( event->posF() );
displayPos = mTransform.inverted().map( event->pos() );
switch ( mOrientation )
{
case Qt::Horizontal:
@@ -104,7 +104,7 @@ class GUI_EXPORT QgsLayoutRuler: public QWidget
QgsLayoutView *mView = nullptr;

QTransform mTransform;
QPointF mMarkerPos;
QPoint mMarkerPos;

QFont mRulerFont;
std::unique_ptr< QFontMetrics > mRulerFontMetrics;
@@ -601,7 +601,7 @@ void QgsColorWheel::setColorFromPos( const QPointF pos )

void QgsColorWheel::mouseMoveEvent( QMouseEvent *event )
{
setColorFromPos( event->posF() );
setColorFromPos( event->pos() );
QgsColorWidget::mouseMoveEvent( event );
}

@@ -621,7 +621,7 @@ void QgsColorWheel::mousePressEvent( QMouseEvent *event )
{
mClickedPart = QgsColorWheel::Wheel;
}
setColorFromPos( event->posF() );
setColorFromPos( event->pos() );
}

void QgsColorWheel::mouseReleaseEvent( QMouseEvent *event )
@@ -1162,7 +1162,7 @@ void QgsColorRampWidget::setMarkerSize( const int markerSize )

void QgsColorRampWidget::mouseMoveEvent( QMouseEvent *event )
{
setColorFromPoint( event->posF() );
setColorFromPoint( event->pos() );
QgsColorWidget::mouseMoveEvent( event );
}

@@ -1191,7 +1191,7 @@ void QgsColorRampWidget::wheelEvent( QWheelEvent *event )

void QgsColorRampWidget::mousePressEvent( QMouseEvent *event )
{
setColorFromPoint( event->posF() );
setColorFromPoint( event->pos() );
}

void QgsColorRampWidget::keyPressEvent( QKeyEvent *event )
@@ -386,11 +386,11 @@ void QgsComposerRuler::setSceneTransform( const QTransform &transform )
void QgsComposerRuler::mouseMoveEvent( QMouseEvent *event )
{
//qWarning( "QgsComposerRuler::mouseMoveEvent" );
updateMarker( event->posF() );
setSnapLinePosition( event->posF() );
updateMarker( event->pos() );
setSnapLinePosition( event->pos() );

//update cursor position in status bar
QPointF displayPos = mTransform.inverted().map( event->posF() );
QPointF displayPos = mTransform.inverted().map( event->pos() );
if ( mDirection == Horizontal )
{
//mouse is over a horizontal ruler, so don't show a y coordinate

0 comments on commit 422963e

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