From dbafe6c7028e43fdfa50b981c49f7c245f8c1785 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 5 Aug 2024 08:54:45 +1000 Subject: [PATCH] Fix clang-tidy warning --- .../PyQt6/gui/auto_generated/qgsrubberband.sip.in | 6 +++--- python/gui/auto_generated/qgsrubberband.sip.in | 6 +++--- src/gui/qgsrubberband.cpp | 14 +++++++------- src/gui/qgsrubberband.h | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/python/PyQt6/gui/auto_generated/qgsrubberband.sip.in b/python/PyQt6/gui/auto_generated/qgsrubberband.sip.in index 8c53b9063b5..6f44e5dfafa 100644 --- a/python/PyQt6/gui/auto_generated/qgsrubberband.sip.in +++ b/python/PyQt6/gui/auto_generated/qgsrubberband.sip.in @@ -121,7 +121,7 @@ Set to an invalid color to avoid drawing the secondary stroke. Returns the current secondary stroke color. %End - void setWidth( int width ); + void setWidth( double width ); %Docstring Sets the width of the line. Stroke width for polygon. @@ -157,12 +157,12 @@ Calling this function automatically calls setIcon(ICON_SVG) Returns the current icon type to highlight point geometries. %End - void setIconSize( int iconSize ); + void setIconSize( double iconSize ); %Docstring Sets the size of the point icons %End - int iconSize() const; + double iconSize() const; %Docstring Returns the current icon size of the point icons. %End diff --git a/python/gui/auto_generated/qgsrubberband.sip.in b/python/gui/auto_generated/qgsrubberband.sip.in index bcec6b787ac..51bbf30a5ec 100644 --- a/python/gui/auto_generated/qgsrubberband.sip.in +++ b/python/gui/auto_generated/qgsrubberband.sip.in @@ -121,7 +121,7 @@ Set to an invalid color to avoid drawing the secondary stroke. Returns the current secondary stroke color. %End - void setWidth( int width ); + void setWidth( double width ); %Docstring Sets the width of the line. Stroke width for polygon. @@ -157,12 +157,12 @@ Calling this function automatically calls setIcon(ICON_SVG) Returns the current icon type to highlight point geometries. %End - void setIconSize( int iconSize ); + void setIconSize( double iconSize ); %Docstring Sets the size of the point icons %End - int iconSize() const; + double iconSize() const; %Docstring Returns the current icon size of the point icons. %End diff --git a/src/gui/qgsrubberband.cpp b/src/gui/qgsrubberband.cpp index bb6d8bb49f9..aad53c93e7e 100644 --- a/src/gui/qgsrubberband.cpp +++ b/src/gui/qgsrubberband.cpp @@ -75,9 +75,9 @@ void QgsRubberBand::setSecondaryStrokeColor( const QColor &color ) mSecondaryPen.setColor( color ); } -void QgsRubberBand::setWidth( int width ) +void QgsRubberBand::setWidth( double width ) { - mPen.setWidth( width ); + mPen.setWidthF( width ); } void QgsRubberBand::setIcon( IconType icon ) @@ -92,7 +92,7 @@ void QgsRubberBand::setSvgIcon( const QString &path, QPoint drawOffset ) mSvgOffset = drawOffset; } -void QgsRubberBand::setIconSize( int iconSize ) +void QgsRubberBand::setIconSize( double iconSize ) { mIconSize = iconSize; } @@ -508,7 +508,7 @@ void QgsRubberBand::paint( QPainter *p ) if ( i == 0 && iterations > 1 ) { // first iteration with multi-pen painting, so use secondary pen - mSecondaryPen.setWidth( mPen.width() + QgsGuiUtils::scaleIconSize( 2 ) ); + mSecondaryPen.setWidthF( mPen.widthF() + QgsGuiUtils::scaleIconSize( 2 ) ); p->setBrush( Qt::NoBrush ); p->setPen( mSecondaryPen ); } @@ -587,11 +587,11 @@ void QgsRubberBand::drawShape( QPainter *p, const QVector &pts ) break; case ICON_FULL_BOX: - p->drawRect( static_cast< int>( x - s ), static_cast< int >( y - s ), mIconSize, mIconSize ); + p->drawRect( QRectF( static_cast< int>( x - s ), static_cast< int >( y - s ), mIconSize, mIconSize ) ); break; case ICON_CIRCLE: - p->drawEllipse( static_cast< int >( x - s ), static_cast< int >( y - s ), mIconSize, mIconSize ); + p->drawEllipse( QRectF( static_cast< int >( x - s ), static_cast< int >( y - s ), mIconSize, mIconSize ) ); break; case ICON_DIAMOND: @@ -654,7 +654,7 @@ void QgsRubberBand::updateRect() } #endif - qreal w = ( ( mIconSize - 1 ) / 2 + mPen.width() ); // in canvas units + qreal w = ( ( mIconSize - 1 ) / 2 + mPen.widthF() ); // in canvas units QgsRectangle r; // in canvas units for ( const QgsPolygonXY &poly : std::as_const( mPoints ) ) diff --git a/src/gui/qgsrubberband.h b/src/gui/qgsrubberband.h index 9cdf3c4e4f4..518ed72613e 100644 --- a/src/gui/qgsrubberband.h +++ b/src/gui/qgsrubberband.h @@ -187,7 +187,7 @@ class GUI_EXPORT QgsRubberBand : public QgsMapCanvasItem * Sets the width of the line. Stroke width for polygon. * \param width The width for any lines painted for this rubberband */ - void setWidth( int width ); + void setWidth( double width ); /** * Returns the current width of the line or stroke width for polygon. @@ -218,12 +218,12 @@ class GUI_EXPORT QgsRubberBand : public QgsMapCanvasItem /** * Sets the size of the point icons */ - void setIconSize( int iconSize ); + void setIconSize( double iconSize ); /** * Returns the current icon size of the point icons. */ - int iconSize() const { return mIconSize; } + double iconSize() const { return mIconSize; } /** * Sets the style of the line @@ -449,7 +449,7 @@ class GUI_EXPORT QgsRubberBand : public QgsMapCanvasItem QPen mSecondaryPen; //! The size of the icon for points. - int mIconSize = 5; + double mIconSize = 5; //! Icon to be shown. IconType mIconType = ICON_CIRCLE;