Skip to content

Commit

Permalink
Standardise names for static variables
Browse files Browse the repository at this point in the history
All non-const variables are prefixed with "s", all const
statics are ALL_CAPS
  • Loading branch information
nyalldawson committed Jan 14, 2017
1 parent 231f6af commit b548063
Show file tree
Hide file tree
Showing 187 changed files with 1,307 additions and 1,304 deletions.
30 changes: 30 additions & 0 deletions doc/api_break.dox
Expand Up @@ -475,6 +475,11 @@ QgsColorBrewerColorRampDialog {#qgis_api_break_3_0_QgsColorBrewerColorRam
and the new ramp can be retrieved after executing the dialog by calling ramp().
- Some internal methods which were previously public or protected were made private.

QgsColorBrewerPalette {#qgis_api_break_3_0_QgsColorBrewerPalette}
---------------------

- brewerString was renamed to BREWER_STRING

QgsColorButton {#qgis_api_break_3_0_QgsColorButton}
--------------

Expand Down Expand Up @@ -902,6 +907,11 @@ QgsExpression::Function {#qgis_api_break_3_0_QgsExpression_Function}
- `QStringList QgsExpression::Function::referencedColumns()` has been changed to `QSet<QString> QgsExpression::Function::referencedColumns( const NodeFunction* node )`
- `QgsExpression::Function::helptext()` has been renamed to `helpText()`

QgsExpressionItem {#qgis_api_break_3_0_QgsExpressionItem}
-----------------

- CustomSortRole was renamed to CUSTOM_SORT_ROLE
- ItemTypeRole was renamed to ITEM_TYPE_ROLE

QgsExpressionContextUtils {#qgis_api_break_3_0_QgsExpressionContextUtils}
-------------------------
Expand All @@ -924,6 +934,11 @@ None will need to be modified, as the method will return an empty geometry if th
- fields() no longer returns a pointer, but instead a QgsFields value.
- The duplicate method setFeatureId() was removed. Use setId() instead.

QgsFeatureListViewDelegate {#qgis_api_break_3_0_QgsFeatureListViewDelegate}
--------------------------

- sIconSize was rename to ICON_SIZE


QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
--------------------
Expand All @@ -940,6 +955,10 @@ QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
- originalSymbolsForFeature( QgsFeature& feat ) has been removed. The originalSymbolsForFeature( QgsFeature& feat, QgsRenderContext& context ) method should be used instead (previously available as originalSymbolsForFeature2 in PyQGIS bindings).
- copyPaintEffect() was removed. copyRendererData() should be used instead.

QgsFeatureRequest {#qgis_api_break_3_0_QgsFeatureRequest}
-----------------

- AllAttributes was renamed to ALL_ATTRIBUTES

QgsFieldCombobox {#qgis_api_break_3_0_QgsFieldCombobox}
----------------
Expand Down Expand Up @@ -1512,6 +1531,12 @@ QgsRenderContext {#qgis_api_break_3_0_QgsRenderContext}
be returned instead of a null pointer if no transformation is required.
- setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.

QgsRendererRangeLabelFormat {#qgis_api_break_3_0_QgsRendererRangeLabelFormat}
---------------------------

- MaxPrecision was renamed to MAX_PRECISION
- MinPrecision was renamed to MIN_PRECISION


QgsRendererRegistry {#qgis_api_break_3_0_QgsRendererRegistry}
----------------------
Expand Down Expand Up @@ -1830,6 +1855,11 @@ QgsWMSLegendNode {#qgis_api_break_3_0_QgsWMSLegendNode}

- QgsWMSLegendNode has been renamed to QgsWmsLegendNode

QgsZipItem {#qgis_api_break_3_0_QgsZipItem}
----------

- mProviderNames was rename to sProviderNames


QgsRenderer {#qgis_api_break_3_0_QgsRenderer}
-----------
Expand Down
4 changes: 2 additions & 2 deletions python/core/__init__.py
Expand Up @@ -42,7 +42,7 @@ def _geometryNonZero(self):
QgsGeometry.__bool__ = _geometryNonZero


def register_function(function, arg_count, group, usesgeometry=False, referenced_columns=[QgsFeatureRequest.AllAttributes], **kwargs):
def register_function(function, arg_count, group, usesgeometry=False, referenced_columns=[QgsFeatureRequest.ALL_ATTRIBUTES], **kwargs):
"""
Register a Python function to be used as a expression function.
Expand Down Expand Up @@ -71,7 +71,7 @@ def myfunc(values, *args):
"""
class QgsExpressionFunction(QgsExpression.Function):

def __init__(self, func, name, args, group, helptext='', usesGeometry=True, referencedColumns=QgsFeatureRequest.AllAttributes, expandargs=False):
def __init__(self, func, name, args, group, helptext='', usesGeometry=True, referencedColumns=QgsFeatureRequest.ALL_ATTRIBUTES, expandargs=False):
QgsExpression.Function.__init__(self, name, args, group, helptext)
self.function = func
self.expandargs = expandargs
Expand Down
10 changes: 5 additions & 5 deletions python/core/qgis.sip
Expand Up @@ -31,11 +31,11 @@ class Qgis
// Version constants
//
// Version string
static QString QGIS_VERSION;
static const QString QGIS_VERSION;
// Version number used for comparing versions using the "Check QGIS Version" function
static const int QGIS_VERSION_INT;
// Release name
static QString QGIS_RELEASE_NAME;
static const QString QGIS_RELEASE_NAME;
// The development version
static const char* QGIS_DEV_VERSION;

Expand Down Expand Up @@ -91,17 +91,17 @@ class Qgis

/** Default highlight buffer in mm.
* @note added in 2.3 */
static double DEFAULT_HIGHLIGHT_BUFFER_MM;
static const double DEFAULT_HIGHLIGHT_BUFFER_MM;

/** Default highlight line/outline minimum width in mm.
* @note added in 2.3 */
static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM;
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM;

/** Fudge factor used to compare two scales. The code is often going from scale to scale
* denominator. So it looses precision and, when a limit is inclusive, can lead to errors.
* To avoid that, use this factor instead of using <= or >=.
* @note added in 2.15*/
static double SCALE_PRECISION;
static const double SCALE_PRECISION;
};

/** Converts a string to a double in a permissive way, e.g., allowing for incorrect
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsdataitem.sip
Expand Up @@ -496,7 +496,7 @@ class QgsZipItem : QgsDataCollectionItem

//! @note not available via python bindings
// static QVector<dataItem_t *> mDataItemPtr;
static QStringList mProviderNames;
static QStringList sProviderNames;

static QString vsiPrefix( const QString& uri );

Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsfeaturerequest.sip
Expand Up @@ -155,7 +155,7 @@ class QgsFeatureRequest
/**
* A special attribute that if set matches all attributes
*/
static const QString AllAttributes;
static const QString ALL_ATTRIBUTES;

//! construct a default request: for all features get attributes and geometries
QgsFeatureRequest();
Expand Down
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgscolorbrewerpalette.sip
Expand Up @@ -11,5 +11,5 @@ class QgsColorBrewerPalette
static QList<int> listSchemeVariants( const QString& schemeName );

// extracted ColorBrewer data
static const char *brewerString;
static const char * BREWER_STRING;
};
4 changes: 2 additions & 2 deletions python/core/symbology-ng/qgsgraduatedsymbolrenderer.sip
Expand Up @@ -76,8 +76,8 @@ class QgsRendererRangeLabelFormat
void setFromDomElement( QDomElement &element );
void saveToDomElement( QDomElement &element );

static const int MaxPrecision;
static const int MinPrecision;
static const int MAX_PRECISION;
static const int MIN_PRECISION;

};

Expand Down
2 changes: 1 addition & 1 deletion python/gui/attributetable/qgsfeaturelistviewdelegate.sip
Expand Up @@ -4,7 +4,7 @@ class QgsFeatureListViewDelegate : QItemDelegate
#include <qgsfeaturelistviewdelegate.h>
%End
public:
static const int sIconSize;
static const int ICON_SIZE;

enum Element
{
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgsexpressionbuilderwidget.sip
Expand Up @@ -43,9 +43,9 @@ class QgsExpressionItem : QStandardItem
QgsExpressionItem::ItemType getItemType() const;

//! Custom sort order role
static const int CustomSortRole;
static const int CUSTOM_SORT_ROLE;
//! Item type role
static const int ItemTypeRole;
static const int ITEM_TYPE_ROLE;
};

/** Search proxy used to filter the QgsExpressionBuilderWidget tree.
Expand Down
8 changes: 4 additions & 4 deletions python/sip_helpers/qgissiphelper.cpp
Expand Up @@ -24,9 +24,9 @@

bool null_from_qvariant_converter( const QVariant *varp, PyObject **objp )
{
static bool watchdog = false;
static bool sWatchDog = false;

if ( watchdog )
if ( sWatchDog )
return false;

// If we deal with a NULL QVariant (and it's not a QByteArray which properly
Expand All @@ -35,10 +35,10 @@ bool null_from_qvariant_converter( const QVariant *varp, PyObject **objp )
// instead of a blacklist.
if ( varp->isNull() && varp->type() != QVariant::ByteArray )
{
watchdog = true;
sWatchDog = true;
PyObject* vartype = sipConvertFromEnum( varp->type(), sipType_QVariant_Type );
*objp = PyObject_Call(( PyObject * )sipTypeAsPyTypeObject( sipType_QVariant ), PyTuple_Pack( 1, vartype ), nullptr );
watchdog = false;
sWatchDog = false;
return true;
}
else
Expand Down
6 changes: 3 additions & 3 deletions scripts/process_contexthelp.py
Expand Up @@ -6,11 +6,11 @@
cpp.write(
"#include \"qgscontexthelp.h\"\n"
"#include <QCoreApplication>\n\n"
"QHash<QString, QString> QgsContextHelp::gContextHelpTexts;\n"
"QHash<QString, QString> QgsContextHelp::sContextHelpTexts;\n"
"\n"
"void QgsContextHelp::init()\n"
"{\n"
" if( !gContextHelpTexts.isEmpty() )\n"
" if( !sContextHelpTexts.isEmpty() )\n"
" return;\n"
)

Expand All @@ -20,7 +20,7 @@
# Protect from IOError: [Errno 21] Is a directory
continue
with open(f) as content:
cpp.write("\n gContextHelpTexts.insert( \"{0}\", QCoreApplication::translate( \"context_help\", \"{1}\") );".format(
cpp.write("\n sContextHelpTexts.insert( \"{0}\", QCoreApplication::translate( \"context_help\", \"{1}\") );".format(
n, content.read().replace("\\", "&#92;").replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n\"')))

cpp.write("\n}\n")
Expand Down
8 changes: 4 additions & 4 deletions scripts/process_function_template.py
Expand Up @@ -14,11 +14,11 @@
cpp.write(
"#include \"qgsexpression.h\"\n"
"\n"
"QHash<QString, QgsExpression::Help> QgsExpression::gFunctionHelpTexts;\n"
"QHash<QString, QgsExpression::Help> QgsExpression::sFunctionHelpTexts;\n"
"\n"
"void QgsExpression::initFunctionHelp()\n"
"{\n"
" if( !gFunctionHelpTexts.isEmpty() )\n"
" if( !sFunctionHelpTexts.isEmpty() )\n"
" return;"
)

Expand Down Expand Up @@ -76,7 +76,7 @@ def quote(v):
if len(list(v['arguments'])) < 1 or len(list(v['arguments'])) > 2:
raise BaseException("%s: 1 or 2 arguments expected for operator")

cpp.write("\n\n gFunctionHelpTexts.insert( {0},\n Help( {0}, tr( \"{1}\" ), tr( \"{2}\" ),\n QList<HelpVariant>()".format(
cpp.write("\n\n sFunctionHelpTexts.insert( {0},\n Help( {0}, tr( \"{1}\" ), tr( \"{2}\" ),\n QList<HelpVariant>()".format(
name, json_params['type'], json_params['description'])
)

Expand Down Expand Up @@ -119,7 +119,7 @@ def quote(v):
n = os.path.basename(f)

with open(f) as content:
cpp.write("\n\n gFunctionHelpTexts.insert( \"{0}\",\n Help( tr( \"{0}\" ), tr( \"group\" ), tr( \"{1}\" ), QList<HelpVariant>() ) );\n".format(
cpp.write("\n\n sFunctionHelpTexts.insert( \"{0}\",\n Help( tr( \"{0}\" ), tr( \"group\" ), tr( \"{1}\" ), QList<HelpVariant>() ) );\n".format(
n, content.read().replace("\\", "&#92;").replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')))

cpp.write("\n}\n")
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -487,7 +487,7 @@ int DualEdgeTriangulation::baseEdgeOfTriangle( Point3D* point )

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

while ( true )
{
if ( runs > sNumBaseOfRuns )//prevents endless loops
if ( runs > MAX_BASE_ITERATIONS )//prevents endless loops
{
QgsDebugMsg( QString( "warning, instability detected: Point coordinates: %1//%2" ).arg( x ).arg( y ) );
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/analysis/interpolation/DualEdgeTriangulation.h
Expand Up @@ -114,11 +114,11 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
//! Y-coordinate of the lower left corner of the bounding box
double yMin;
//! Default value for the number of storable points at the beginning
const static unsigned int mDefaultStorageForPoints = 100000;
static const unsigned int DEFAULT_STORAGE_FOR_POINTS = 100000;
//! Stores pointers to all points in the triangulations (including the points contained in the lines)
QVector<Point3D*> mPointVector;
//! Default value for the number of storable HalfEdges at the beginning
const static unsigned int mDefaultStorageForHalfEdges = 300006;
static const unsigned int DEFAULT_STORAGE_FOR_HALF_EDGES = 300006;
//! Stores pointers to the HalfEdges
QVector<HalfEdge*> mHalfEdge;
//! Association to an interpolator object
Expand All @@ -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 sNumBaseOfRuns = 300000;
static const int MAX_BASE_ITERATIONS = 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
Expand Down Expand Up @@ -194,8 +194,8 @@ inline DualEdgeTriangulation::DualEdgeTriangulation()
, mUnstableEdge( 0 )
, mTwiceInsPoint( 0 )
{
mPointVector.reserve( mDefaultStorageForPoints );
mHalfEdge.reserve( mDefaultStorageForHalfEdges );
mPointVector.reserve( DEFAULT_STORAGE_FOR_POINTS );
mHalfEdge.reserve( DEFAULT_STORAGE_FOR_HALF_EDGES );
}

inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator )
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/interpolation/NormVecDecorator.h
Expand Up @@ -72,7 +72,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
protected:
//! Is true, if the normals already have been estimated
bool alreadyestimated;
const static unsigned int mDefaultStorageForNormals = 100000;
static const unsigned int DEFAULT_STORAGE_FOR_NORMALS = 100000;
//! Association with an interpolator object
TriangleInterpolator* mInterpolator;
//! Vector that stores the normals for the points. If 'estimateFirstDerivatives()' was called and there is a null pointer, this means, that the triangle point is on a breakline
Expand All @@ -83,12 +83,12 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
void setState( int pointno, PointState s );
};

inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<PointState>( mDefaultStorageForNormals ) )
inline NormVecDecorator::NormVecDecorator(): TriDecorator(), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) ), mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
{
alreadyestimated = false;
}

inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( mDefaultStorageForNormals ) ), mPointState( new QVector<PointState>( mDefaultStorageForNormals ) )
inline NormVecDecorator::NormVecDecorator( Triangulation* tin ): TriDecorator( tin ), mInterpolator( nullptr ), mNormVec( new QVector<Vector3D*>( DEFAULT_STORAGE_FOR_NORMALS ) ), mPointState( new QVector<PointState>( DEFAULT_STORAGE_FOR_NORMALS ) )
{
alreadyestimated = false;
}
Expand Down

0 comments on commit b548063

Please sign in to comment.