Skip to content

Commit

Permalink
Replace use of deprecated QMouseEvent::posF()
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent 31fcc67 commit 422963e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
36 changes: 18 additions & 18 deletions src/app/qgsmaptoolannotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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() ) );
}
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolannotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/gui/layout/qgslayoutruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void QgsLayoutRuler::setCursorPosition( QPointF position )

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

QPointF displayPos;
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/gui/layout/qgslayoutruler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgscolorwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void QgsColorWheel::setColorFromPos( const QPointF pos )

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

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

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

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

Expand Down Expand Up @@ -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 )
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgscomposerruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 422963e

Please sign in to comment.