Skip to content
Permalink
Browse files
Make some member functions const, because they can be
Also removes the getDefaultInterval() member function from the .h file
because it is not used and doesn't have an implementation.

And makes an argument a const ptr instead of a non-const ptr, because it
is only used in const context.
  • Loading branch information
joto authored and nyalldawson committed Oct 23, 2021
1 parent eb609b1 commit e4b611db7dcc81a9f98a465edce78db386dd6271
Showing with 7 additions and 9 deletions.
  1. +3 −3 src/app/decorations/qgsdecorationgrid.cpp
  2. +4 −6 src/app/decorations/qgsdecorationgrid.h
@@ -513,7 +513,7 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa
return 0;
}

QgsDecorationGrid::Border QgsDecorationGrid::borderForLineCoord( QPointF point, QPainter *p ) const
QgsDecorationGrid::Border QgsDecorationGrid::borderForLineCoord( QPointF point, const QPainter *p ) const
{
if ( point.x() <= mGridPen.widthF() )
{
@@ -572,7 +572,7 @@ void QgsDecorationGrid::setDirty( bool dirty )
}
}

bool QgsDecorationGrid::getIntervalFromExtent( double *values, bool useXAxis )
bool QgsDecorationGrid::getIntervalFromExtent( double *values, bool useXAxis ) const
{
// get default interval from current extents
// calculate a default interval that is approx (extent width)/5, adjusted so that it is a rounded number
@@ -601,7 +601,7 @@ bool QgsDecorationGrid::getIntervalFromExtent( double *values, bool useXAxis )
return true;
}

bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values )
bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const
{
// get current layer and make sure it is a raster layer and CRSs match
QgsMapLayer *layer = QgisApp::instance()->mapCanvas()->currentLayer();
@@ -126,18 +126,16 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem

//! Sets map unit type
void setMapUnits( QgsUnitTypes::DistanceUnit t ) { mMapUnits = t; }
QgsUnitTypes::DistanceUnit mapUnits() { return mMapUnits; }
QgsUnitTypes::DistanceUnit mapUnits() const { return mMapUnits; }

//! Sets mapUnits value
void setDirty( bool dirty = true );
bool isDirty();

//! Computes interval that is approx. 1/5 of canvas extent
bool getIntervalFromExtent( double *values, bool useXAxis = true );
bool getIntervalFromExtent( double *values, bool useXAxis = true ) const;
//! Computes interval from current raster layer
bool getIntervalFromCurrentLayer( double *values );

double getDefaultInterval( bool useXAxis = true );
bool getIntervalFromCurrentLayer( double *values ) const;

public slots:
//! Sets values on the gui when a project is read or the gui first loaded
@@ -214,7 +212,7 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
int yGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const;

//! Returns the item border of a point (in item coordinates)
Border borderForLineCoord( QPointF point, QPainter *p ) const;
Border borderForLineCoord( QPointF point, const QPainter *p ) const;

QgsTextFormat mTextFormat;
};

0 comments on commit e4b611d

Please sign in to comment.