Skip to content

Commit 422963e

Browse files
committed
Replace use of deprecated QMouseEvent::posF()
1 parent 31fcc67 commit 422963e

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

src/app/qgsmaptoolannotation.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
9494
return;
9595
}
9696

97-
mLastMousePosition = e->posF();
97+
mLastMousePosition = e->pos();
9898

9999
QgsMapCanvasAnnotationItem *item = selectedItem();
100100
if ( item )
101101
{
102-
mCurrentMoveAction = item->moveActionForPosition( e->posF() );
102+
mCurrentMoveAction = item->moveActionForPosition( e->pos() );
103103
if ( mCurrentMoveAction != QgsMapCanvasAnnotationItem::NoAction )
104104
{
105105
return;
@@ -110,7 +110,7 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
110110
{
111111
//select a new item if there is one at this position
112112
mCanvas->scene()->clearSelection();
113-
QgsMapCanvasAnnotationItem *existingItem = itemAtPos( e->posF() );
113+
QgsMapCanvasAnnotationItem *existingItem = itemAtPos( e->pos() );
114114
if ( existingItem )
115115
{
116116
existingItem->setSelected( true );
@@ -124,8 +124,8 @@ void QgsMapToolAnnotation::canvasPressEvent( QgsMapMouseEvent *e )
124124
QgsPointXY mapPos = transformCanvasToAnnotation( toMapCoordinates( e->pos() ), annotation );
125125
annotation->setMapPosition( mapPos );
126126
annotation->setMapPositionCrs( mCanvas->mapSettings().destinationCrs() );
127-
annotation->setRelativePosition( QPointF( e->posF().x() / mCanvas->width(),
128-
e->posF().y() / mCanvas->height() ) );
127+
annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(),
128+
e->pos().y() / mCanvas->height() ) );
129129
annotation->setFrameSize( QSizeF( 200, 100 ) );
130130

131131
QgsProject::instance()->annotationManager()->addAnnotation( annotation );
@@ -184,17 +184,17 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
184184
{
185185
QgsPointXY mapPos = transformCanvasToAnnotation( e->snapPoint(), annotation );
186186
annotation->setMapPosition( mapPos );
187-
annotation->setRelativePosition( QPointF( e->posF().x() / mCanvas->width(),
188-
e->posF().y() / mCanvas->height() ) );
187+
annotation->setRelativePosition( QPointF( e->pos().x() / mCanvas->width(),
188+
e->pos().y() / mCanvas->height() ) );
189189
item->update();
190190
QgsProject::instance()->setDirty( true );
191191
}
192192
else if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::MoveFramePosition )
193193
{
194-
QPointF newCanvasPos = item->pos() + ( e->posF() - mLastMousePosition );
194+
QPointF newCanvasPos = item->pos() + ( e->pos() - mLastMousePosition );
195195
if ( annotation->hasFixedMapPosition() )
196196
{
197-
annotation->setFrameOffsetFromReferencePoint( annotation->frameOffsetFromReferencePoint() + ( e->posF() - mLastMousePosition ) );
197+
annotation->setFrameOffsetFromReferencePoint( annotation->frameOffsetFromReferencePoint() + ( e->pos() - mLastMousePosition ) );
198198
annotation->setRelativePosition( QPointF( newCanvasPos.x() / mCanvas->width(),
199199
newCanvasPos.y() / mCanvas->height() ) );
200200
}
@@ -223,27 +223,27 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
223223
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown ||
224224
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp )
225225
{
226-
xmax += e->posF().x() - mLastMousePosition.x();
226+
xmax += e->pos().x() - mLastMousePosition.x();
227227
}
228228
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeft ||
229229
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown ||
230230
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp )
231231
{
232-
xmin += e->posF().x() - mLastMousePosition.x();
233-
relPosX = ( relPosX * mCanvas->width() + e->posF().x() - mLastMousePosition.x() ) / ( double )mCanvas->width();
232+
xmin += e->pos().x() - mLastMousePosition.x();
233+
relPosX = ( relPosX * mCanvas->width() + e->pos().x() - mLastMousePosition.x() ) / ( double )mCanvas->width();
234234
}
235235
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameUp ||
236236
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftUp ||
237237
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightUp )
238238
{
239-
ymin += e->posF().y() - mLastMousePosition.y();
240-
relPosY = ( relPosY * mCanvas->height() + e->posF().y() - mLastMousePosition.y() ) / ( double )mCanvas->height();
239+
ymin += e->pos().y() - mLastMousePosition.y();
240+
relPosY = ( relPosY * mCanvas->height() + e->pos().y() - mLastMousePosition.y() ) / ( double )mCanvas->height();
241241
}
242242
if ( mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameDown ||
243243
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameLeftDown ||
244244
mCurrentMoveAction == QgsMapCanvasAnnotationItem::ResizeFrameRightDown )
245245
{
246-
ymax += e->posF().y() - mLastMousePosition.y();
246+
ymax += e->pos().y() - mLastMousePosition.y();
247247
}
248248

249249
//switch min / max if necessary
@@ -270,18 +270,18 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent *e )
270270
}
271271
else if ( item )
272272
{
273-
QgsMapCanvasAnnotationItem::MouseMoveAction moveAction = item->moveActionForPosition( e->posF() );
273+
QgsMapCanvasAnnotationItem::MouseMoveAction moveAction = item->moveActionForPosition( e->pos() );
274274
if ( mCanvas )
275275
{
276276
mCanvas->setCursor( QCursor( item->cursorShapeForAction( moveAction ) ) );
277277
}
278278
}
279-
mLastMousePosition = e->posF();
279+
mLastMousePosition = e->pos();
280280
}
281281

282282
void QgsMapToolAnnotation::canvasDoubleClickEvent( QgsMapMouseEvent *e )
283283
{
284-
QgsMapCanvasAnnotationItem *item = itemAtPos( e->posF() );
284+
QgsMapCanvasAnnotationItem *item = itemAtPos( e->pos() );
285285
if ( !item )
286286
{
287287
return;

src/app/qgsmaptoolannotation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class APP_EXPORT QgsMapToolAnnotation: public QgsMapTool
6060
QgsPointXY transformCanvasToAnnotation( QgsPointXY p, QgsAnnotation *annotation ) const;
6161

6262
QgsMapCanvasAnnotationItem::MouseMoveAction mCurrentMoveAction = QgsMapCanvasAnnotationItem::NoAction;
63-
QPointF mLastMousePosition = QPointF( 0, 0 );
63+
QPoint mLastMousePosition = QPoint( 0, 0 );
6464
};
6565

6666
#endif // QGSMAPTOOLANNOTATION_H

src/gui/layout/qgslayoutruler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ void QgsLayoutRuler::setCursorPosition( QPointF position )
571571

572572
void QgsLayoutRuler::mouseMoveEvent( QMouseEvent *event )
573573
{
574-
mMarkerPos = event->posF();
574+
mMarkerPos = event->pos();
575575
update();
576576

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

653653
//update cursor position in status bar
654-
displayPos = mTransform.inverted().map( event->posF() );
654+
displayPos = mTransform.inverted().map( event->pos() );
655655
switch ( mOrientation )
656656
{
657657
case Qt::Horizontal:

src/gui/layout/qgslayoutruler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class GUI_EXPORT QgsLayoutRuler: public QWidget
104104
QgsLayoutView *mView = nullptr;
105105

106106
QTransform mTransform;
107-
QPointF mMarkerPos;
107+
QPoint mMarkerPos;
108108

109109
QFont mRulerFont;
110110
std::unique_ptr< QFontMetrics > mRulerFontMetrics;

src/gui/qgscolorwidgets.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void QgsColorWheel::setColorFromPos( const QPointF pos )
601601

602602
void QgsColorWheel::mouseMoveEvent( QMouseEvent *event )
603603
{
604-
setColorFromPos( event->posF() );
604+
setColorFromPos( event->pos() );
605605
QgsColorWidget::mouseMoveEvent( event );
606606
}
607607

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

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

11631163
void QgsColorRampWidget::mouseMoveEvent( QMouseEvent *event )
11641164
{
1165-
setColorFromPoint( event->posF() );
1165+
setColorFromPoint( event->pos() );
11661166
QgsColorWidget::mouseMoveEvent( event );
11671167
}
11681168

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

11921192
void QgsColorRampWidget::mousePressEvent( QMouseEvent *event )
11931193
{
1194-
setColorFromPoint( event->posF() );
1194+
setColorFromPoint( event->pos() );
11951195
}
11961196

11971197
void QgsColorRampWidget::keyPressEvent( QKeyEvent *event )

src/gui/qgscomposerruler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ void QgsComposerRuler::setSceneTransform( const QTransform &transform )
386386
void QgsComposerRuler::mouseMoveEvent( QMouseEvent *event )
387387
{
388388
//qWarning( "QgsComposerRuler::mouseMoveEvent" );
389-
updateMarker( event->posF() );
390-
setSnapLinePosition( event->posF() );
389+
updateMarker( event->pos() );
390+
setSnapLinePosition( event->pos() );
391391

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

0 commit comments

Comments
 (0)