Skip to content
Permalink
Browse files

Rename some static variables for consistency

Ensure non-const statics have "s" prefix and const statics
are in all caps
  • Loading branch information
nyalldawson committed Jan 12, 2017
1 parent 3705ff1 commit b7706b358fc164aa1d5d5c716ba02be799bd688a
Showing with 212 additions and 223 deletions.
  1. +2 −2 python/core/symbology-ng/qgsgraduatedsymbolrenderer.sip
  2. +2 −2 src/analysis/interpolation/DualEdgeTriangulation.cc
  3. +1 −1 src/analysis/interpolation/DualEdgeTriangulation.h
  4. +9 −11 src/app/qgsdecorationnortharrow.cpp
  5. +0 −1 src/app/qgsdecorationnortharrow.h
  6. +1 −1 src/core/auth/qgsauthconfig.cpp
  7. +1 −1 src/core/auth/qgsauthconfig.h
  8. +12 −12 src/core/dxf/qgsdxfexport.cpp
  9. +2 −2 src/core/dxf/qgsdxfexport.h
  10. +3 −3 src/core/layertree/qgslayertreemodellegendnode.cpp
  11. +1 −1 src/core/layertree/qgslayertreemodellegendnode.h
  12. +3 −3 src/core/qgsapplication.cpp
  13. +1 −1 src/core/qgsconnectionpool.h
  14. +3 −3 src/core/qgscoordinatereferencesystem.cpp
  15. +3 −3 src/core/qgsmaprendererjob.cpp
  16. +2 −2 src/core/qgsmapsettings.cpp
  17. +2 −2 src/core/qgsrenderchecker.cpp
  18. +4 −4 src/core/qgsscalecalculator.cpp
  19. +4 −4 src/core/qgsvectorlayerundocommand.cpp
  20. +2 −2 src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp
  21. +2 −2 src/core/symbology-ng/qgsgraduatedsymbolrenderer.h
  22. +3 −3 src/gui/effects/qgspainteffectpropertieswidget.cpp
  23. +3 −3 src/gui/raster/qgsrendererrasterpropertieswidget.cpp
  24. +3 −3 src/gui/symbology-ng/qgslayerpropertieswidget.cpp
  25. +3 −3 src/gui/symbology-ng/qgsrendererpropertiesdialog.cpp
  26. +4 −4 src/plugins/georeferencer/qgsimagewarper.cpp
  27. +1 −1 src/plugins/georeferencer/qgsimagewarper.h
  28. +5 −5 src/plugins/grass/qgsgrassnewmapset.cpp
  29. +1 −1 src/plugins/grass/qgsgrassnewmapset.h
  30. +3 −3 src/plugins/grass/qgsgrassselect.cpp
  31. +1 −1 src/plugins/grass/qgsgrassselect.h
  32. +7 −7 src/plugins/spatialquery/qgsspatialquerydialog.cpp
  33. +7 −7 src/providers/gdal/qgsgdalprovider.cpp
  34. +2 −2 src/providers/gpx/qgsgpxprovider.cpp
  35. +1 −1 src/providers/gpx/qgsgpxprovider.h
  36. +19 −19 src/providers/grass/qgsgrass.cpp
  37. +5 −5 src/providers/grass/qgsgrass.h
  38. +4 −4 src/providers/grass/qgsgrassprovider.cpp
  39. +1 −1 src/providers/grass/qgsgrassprovider.h
  40. +62 −70 src/providers/postgres/qgspostgresexpressioncompiler.cpp
  41. +3 −3 src/providers/wfs/qgswfsprovider.cpp
  42. +3 −3 src/providers/wfs/qgswfsshareddata.cpp
  43. +9 −9 src/providers/wfs/qgswfsutils.cpp
  44. +2 −2 src/providers/wfs/qgswfsutils.h
@@ -76,8 +76,8 @@ class QgsRendererRangeLabelFormat
void setFromDomElement( QDomElement &element );
void saveToDomElement( QDomElement &element );

static int MaxPrecision;
static int MinPrecision;
static const int MaxPrecision;

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jan 12, 2017

Member

Shouldn't that be all-caps?

static const int MinPrecision;

};

@@ -487,7 +487,7 @@ int DualEdgeTriangulation::baseEdgeOfTriangle( Point3D* point )

while ( true )
{
if ( runs > nBaseOfRuns )//prevents endless loops
if ( runs > sNumBaseOfRuns )//prevents endless loops
{
// QgsDebugMsg("warning, probable endless loop detected");
return -100;
@@ -2606,7 +2606,7 @@ bool DualEdgeTriangulation::pointInside( double x, double y )

while ( true )
{
if ( runs > nBaseOfRuns )//prevents endless loops
if ( runs > sNumBaseOfRuns )//prevents endless loops
{
QgsDebugMsg( QString( "warning, instability detected: Point coordinates: %1//%2" ).arg( x ).arg( y ) );
return false;
@@ -140,7 +140,7 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
//! Threshold for the leftOfTest to handle numerical instabilities
//const static double leftOfTresh=0.00001;
//! Security to prevent endless loops in 'baseEdgeOfTriangle'. It there are more iteration then this number, the point will not be inserted
const static int nBaseOfRuns = 300000;
const static int sNumBaseOfRuns = 300000;
//! Returns the number of an edge which points to the point with number 'point' or -1 if there is an error
int baseEdgeOfPoint( int point );
//! Returns the number of a HalfEdge from a triangle in which 'point' is in. If the number -10 is returned, this means, that 'point' is outside the convex hull. If -5 is returned, then numerical problems with the leftOfTest occurred (and the value of the possible edge is stored in the variable 'mUnstableEdge'. -20 means, that the inserted point is exactly on an edge (the number is stored in the variable 'mEdgeWithPoint'). -25 means, that the point is already in the triangulation (the number of the point is stored in the member 'mTwiceInsPoint'. If -100 is returned, this means that something else went wrong
@@ -42,8 +42,6 @@ email : tim@linfiniti.com
#include <cmath>
#include <cassert>


const double QgsDecorationNorthArrow::PI = 3.14159265358979323846;
// const double QgsNorthArrowPlugin::DEG2RAD = 0.0174532925199433;
const double QgsDecorationNorthArrow::TOL = 1e-8;

@@ -124,7 +122,7 @@ void QgsDecorationNorthArrow::render( QPainter * theQPainter )
if ( mAutomatic )
calculateNorthDirection();

double myRadiansDouble = mRotationInt * PI / 180.0;
double myRadiansDouble = mRotationInt * M_PI / 180.0;
int xShift = static_cast<int>((
( centerXDouble * cos( myRadiansDouble ) ) +
( centerYDouble * sin( myRadiansDouble ) )
@@ -266,8 +264,8 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
double angle = 0.0;

// convert to radians for the equations below
p1.multiply( PI / 180.0 );
p2.multiply( PI / 180.0 );
p1.multiply( M_PI / 180.0 );
p2.multiply( M_PI / 180.0 );

double y = sin( p2.x() - p1.x() ) * cos( p2.y() );
double x = cos( p1.y() ) * sin( p2.y() ) -
@@ -282,25 +280,25 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
if ( x > 0.0 && ( y / x ) > TOL )
angle = atan( y / x );
else if ( x < 0.0 && ( y / x ) < -TOL )
angle = PI - atan( -y / x );
angle = M_PI - atan( -y / x );
else
angle = 0.5 * PI;
angle = 0.5 * M_PI;
}
else if ( y < 0.0 )
{
if ( x > 0.0 && ( y / x ) < -TOL )
angle = -atan( -y / x );
else if ( x < 0.0 && ( y / x ) > TOL )
angle = atan( y / x ) - PI;
angle = atan( y / x ) - M_PI;
else
angle = 1.5 * PI;
angle = 1.5 * M_PI;
}
else
{
if ( x > TOL )
angle = 0.0;
else if ( x < -TOL )
angle = PI;
angle = M_PI;
else
{
angle = 0.0; // p1 = p2
@@ -309,7 +307,7 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
}
// And set the angle of the north arrow. Perhaps do something
// different if goodDirn = false.
mRotationInt = qRound( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) );
mRotationInt = qRound( fmod( 360.0 - angle * 180.0 / M_PI, 360.0 ) );
}
else
{
@@ -57,7 +57,6 @@ class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem

private:

static const double PI;
// static const double DEG2RAD;
static const double TOL;

@@ -32,7 +32,7 @@ const QString QgsAuthMethodConfig::mConfigSep = QStringLiteral( "|||" );
const QString QgsAuthMethodConfig::mConfigKeySep = QStringLiteral( ":::" );
const QString QgsAuthMethodConfig::mConfigListSep = QStringLiteral( "```" );

const int QgsAuthMethodConfig::mConfigVersion = 1;
const int QgsAuthMethodConfig::sConfigVersion = 1;

// get uniqueConfigId only on save
QgsAuthMethodConfig::QgsAuthMethodConfig( const QString& method, int version )
@@ -172,7 +172,7 @@ class CORE_EXPORT QgsAuthMethodConfig
static const QString mConfigKeySep;
static const QString mConfigListSep;

static const int mConfigVersion;
static const int sConfigVersion;
};

typedef QHash<QString, QgsAuthMethodConfig> QgsAuthMethodConfigsMap;
@@ -56,7 +56,7 @@
#define DXF_HANDPLOTSTYLE 0xf

// dxf color palette
int QgsDxfExport::mDxfColors[][3] =
int QgsDxfExport::sDxfColors[][3] =
{
{ 255, 255, 255 },
{ 255, 0, 0 },
@@ -316,7 +316,7 @@ int QgsDxfExport::mDxfColors[][3] =
{ 255, 255, 255 },
};

const char *QgsDxfExport::mDxfEncodings[][2] =
const char *QgsDxfExport::sDxfEncodings[][2] =
{
{ "ASCII", "" },
{ "8859_1", "ISO-8859-1" },
@@ -432,7 +432,7 @@ void QgsDxfExport::writeGroup( const QColor& color, int exactMatchCode, int rgbC
int minDistAt = -1;
int minDist = INT_MAX;

for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ) && minDist > 0; ++i )
for ( int i = 1; i < static_cast< int >( sizeof( sDxfColors ) / sizeof( *sDxfColors ) ) && minDist > 0; ++i )
{
int dist = color_distance( color.rgba(), i );
if ( dist >= minDist )
@@ -3873,7 +3873,7 @@ int QgsDxfExport::closestColorMatch( QRgb pixel )
{
int idx = 0;
int current_distance = INT_MAX;
for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
for ( int i = 1; i < static_cast< int >( sizeof( sDxfColors ) / sizeof( *sDxfColors ) ); ++i )
{
int dist = color_distance( pixel, i );
if ( dist < current_distance )
@@ -3894,9 +3894,9 @@ int QgsDxfExport::color_distance( QRgb p1, int index )
return 0;
}

double redDiff = qRed( p1 ) - mDxfColors[index][0];
double greenDiff = qGreen( p1 ) - mDxfColors[index][1];
double blueDiff = qBlue( p1 ) - mDxfColors[index][2];
double redDiff = qRed( p1 ) - sDxfColors[index][0];
double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
#if 0
QgsDebugMsg( QString( "color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
.arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
@@ -4211,13 +4211,13 @@ QString QgsDxfExport::dxfEncoding( const QString &name )
continue;

int i;
for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
for ( i = 0; i < static_cast< int >( sizeof( sDxfEncodings ) / sizeof( *sDxfEncodings ) ) && name != sDxfEncodings[i][1]; ++i )
;

if ( i == static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
if ( i == static_cast< int >( sizeof( sDxfEncodings ) / sizeof( *sDxfEncodings ) ) )
continue;

return mDxfEncodings[i][0];
return sDxfEncodings[i][0];
}

return QString::null;
@@ -4229,10 +4229,10 @@ QStringList QgsDxfExport::encodings()
Q_FOREACH ( QByteArray codec, QTextCodec::availableCodecs() )
{
int i;
for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
for ( i = 0; i < static_cast< int >( sizeof( sDxfEncodings ) / sizeof( *sDxfEncodings ) ) && strcmp( codec.data(), sDxfEncodings[i][1] ) != 0; ++i )
;

if ( i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
if ( i < static_cast< int >( sizeof( sDxfEncodings ) / sizeof( *sDxfEncodings ) ) )
encodings << codec.data();
}
return encodings;
@@ -340,8 +340,8 @@ class CORE_EXPORT QgsDxfExport

QTextStream mTextStream;

static int mDxfColors[][3];
static const char *mDxfEncodings[][2];
static int sDxfColors[][3];
static const char *sDxfEncodings[][2];

int mSymbolLayerCounter; //internal counter
int mNextHandleId;
@@ -176,7 +176,7 @@ QSize QgsSymbolLegendNode::minimumIconSize( QgsRenderContext* context ) const
}

if ( mItem.level() != 0 && !( model() && model()->testFlag( QgsLayerTreeModel::ShowLegendAsTree ) ) )
minSz.setWidth( mItem.level() * indentSize + minSz.width() );
minSz.setWidth( mItem.level() * sIndentSize + minSz.width() );

return minSz;
}
@@ -279,10 +279,10 @@ QVariant QgsSymbolLegendNode::data( int role ) const
else
{
// ident the symbol icon to make it look like a tree structure
QPixmap pix2( pix.width() + mItem.level() * indentSize, pix.height() );
QPixmap pix2( pix.width() + mItem.level() * sIndentSize, pix.height() );
pix2.fill( Qt::transparent );
QPainter p( &pix2 );
p.drawPixmap( mItem.level() * indentSize, 0, pix );
p.drawPixmap( mItem.level() * sIndentSize, 0, pix );
p.end();
mPixmap = pix2;
}
@@ -225,7 +225,7 @@ class CORE_EXPORT QgsSymbolLegendNode : public QgsLayerTreeModelLegendNode
QSize mIconSize;

// ident the symbol icon to make it look like a tree structure
static const int indentSize = 20;
static const int sIndentSize = 20;

// return a temporary context or null if legendMapViewData are not valid
QgsRenderContext * createTemporaryRenderContext() const;
@@ -426,10 +426,10 @@ QString QgsApplication::prefixPath()
{
if ( ABISYM( mRunningFromBuildDir ) )
{
static bool once = true;
if ( once )
static bool sOnce = true;
if ( sOnce )
qWarning( "!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
once = false;
sOnce = false;
}

return ABISYM( mPrefixPath );
@@ -55,7 +55,7 @@ class QgsConnectionPoolGroup
{
public:

static const int maxConcurrentConnections;
static const int sMaxConcurrentConnections;

struct Item
{
@@ -1121,10 +1121,10 @@ void QgsCoordinateReferenceSystem::setMapUnits()
// do better than that ... (but perhaps ogr should be enhanced to
// do this instead?).

static const double feetToMeter = 0.3048;
static const double smallNum = 1e-3;
static const double FEET_TO_METER = 0.3048;
static const double SMALL_NUM = 1e-3;

if ( qAbs( toMeter - feetToMeter ) < smallNum )
if ( qAbs( toMeter - FEET_TO_METER ) < SMALL_NUM )
unit = QStringLiteral( "Foot" );

QgsDebugMsg( "Projection has linear units of " + unit );
@@ -79,7 +79,7 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
// geographic coordinates (usually +/- 180 degrees,
// and is assumed to be so here), and draw each
// extent separately.
static const double splitCoord = 180.0;
static const double SPLIT_COORD = 180.0;

if ( ml->crs().isGeographic() )
{
@@ -132,8 +132,8 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
// so let's use (-180,180). This hopefully does not add too much overhead. It is
// more straightforward than rendering with two separate extents and more consistent
// for rendering, labeling and caching as everything is rendered just in one go
extent.setXMinimum( -splitCoord );
extent.setXMaximum( splitCoord );
extent.setXMinimum( -SPLIT_COORD );
extent.setXMaximum( SPLIT_COORD );
}
}

@@ -150,8 +150,8 @@ void QgsMapSettings::updateDerived()
double xRange = extent.width() / xMean;
double yRange = extent.height() / yMean;

static const double minProportion = 1e-12;
if ( xRange < minProportion || yRange < minProportion )
static const double MIN_PROPORTION = 1e-12;
if ( xRange < MIN_PROPORTION || yRange < MIN_PROPORTION )
{
mValid = false;
return;
@@ -28,7 +28,7 @@
#include <QDebug>
#include <QBuffer>

static int renderCounter = 0;
static int sRenderCounter = 0;

QgsRenderChecker::QgsRenderChecker()
: mReport( QLatin1String( "" ) )
@@ -357,7 +357,7 @@ bool QgsRenderChecker::compareImages( const QString& theTestName,
mRenderedImageFile,
mExpectedImageFile )
.arg( imgWidth ).arg( imgHeight )
.arg( renderCounter++ );
.arg( sRenderCounter++ );

QString prefix;
if ( !mControlPathPrefix.isNull() )
@@ -118,12 +118,12 @@ double QgsScaleCalculator::calculateGeographicDistance( const QgsRectangle &mapE
const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0;
double a = pow( cos( lat * rads ), 2 );
double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) );
const static double ra = 6378000; // [m]
const static double RA = 6378000; // [m]
// The eccentricity. This comes from sqrt(1.0 - rb*rb/(ra*ra)) with rb set
// to 6357000 m.
const static double e = 0.0810820288;
double radius = ra * ( 1.0 - e * e ) /
pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 );
const static double E = 0.0810820288;
double radius = RA * ( 1.0 - E * E ) /
pow( 1.0 - E * E * sin( lat * rads ) * sin( lat * rads ), 1.5 );
double meters = ( mapExtent.xMaximum() - mapExtent.xMinimum() ) / 180.0 * radius * c;

QgsDebugMsg( "Distance across map extent (m): " + QString::number( meters ) );
@@ -28,17 +28,17 @@
QgsVectorLayerUndoCommandAddFeature::QgsVectorLayerUndoCommandAddFeature( QgsVectorLayerEditBuffer* buffer, QgsFeature& f )
: QgsVectorLayerUndoCommand( buffer )
{
static int addedIdLowWaterMark = -1;
static int sAddedIdLowWaterMark = -1;

//assign a temporary id to the feature (use negative numbers)
addedIdLowWaterMark--;
sAddedIdLowWaterMark--;

QgsDebugMsgLevel( "Assigned feature id " + QString::number( addedIdLowWaterMark ), 4 );
QgsDebugMsgLevel( "Assigned feature id " + QString::number( sAddedIdLowWaterMark ), 4 );

// Force a feature ID (to keep other functions in QGIS happy,
// providers will use their own new feature ID when we commit the new feature)
// and add to the known added features.
f.setId( addedIdLowWaterMark );
f.setId( sAddedIdLowWaterMark );

mFeature = f;
}
@@ -176,8 +176,8 @@ void QgsRendererRange::toSld( QDomDocument &doc, QDomElement &element, QgsString

///////////

int QgsRendererRangeLabelFormat::MaxPrecision = 15;
int QgsRendererRangeLabelFormat::MinPrecision = -6;
const int QgsRendererRangeLabelFormat::MaxPrecision = 15;
const int QgsRendererRangeLabelFormat::MinPrecision = -6;

QgsRendererRangeLabelFormat::QgsRendererRangeLabelFormat()
: mFormat( QStringLiteral( " %1 - %2 " ) )

2 comments on commit b7706b3

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Jan 12, 2017

Maybe I got something wrong, I find a couple of static const changes in here that are not in all-caps

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Jan 12, 2017

No - you're right. This needs more work.

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