Skip to content
Permalink
Browse files

Const correctness for QgsVectorLayer methods

  • Loading branch information
nyalldawson committed Jul 14, 2016
1 parent 0d84ca7 commit 2d50895d043f79cec6ce9e5eb644718b1f8fa2f0
@@ -106,6 +106,13 @@ plugins calling this method will need to be updated.</li>
plugins calling this method will need to be updated.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayer QgsVectorLayer

<ul>
<li>commitErrors() now returns an object, rather than a reference. This has no effect on PyQGIS code.</li>
<li>subsetString() was made const. This has no effect on PyQGIS code, but c++ code implementing derived layer classes will need to update the signature of this method to match.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorFileWriter QgsVectorFileWriter

<ul>
@@ -60,11 +60,11 @@ class QgsAggregateCalculator
/** Constructor for QgsAggregateCalculator.
* @param layer vector layer to calculate aggregate from
*/
QgsAggregateCalculator( QgsVectorLayer* layer );
QgsAggregateCalculator( const QgsVectorLayer* layer );

/** Returns the associated vector layer.
*/
QgsVectorLayer* layer() const;
const QgsVectorLayer* layer() const;

/** Sets all aggregate parameters from a parameter bundle.
* @param parameters aggregate parameters
@@ -79,7 +79,7 @@ class QgsRelationManager : QObject
*
* @return A list of relations matching the given layer and fieldIdx.
*/
QList<QgsRelation> referencingRelations( QgsVectorLayer *layer = 0, int fieldIdx = -2 ) const;
QList<QgsRelation> referencingRelations( const QgsVectorLayer *layer = 0, int fieldIdx = -2 ) const;

/**
* Get all relations where this layer is the referenced part (i.e. the parent table with the primary key being referenced from another layer).
@@ -207,7 +207,7 @@ class QgsVectorLayer : QgsMapLayer
*
* @return The expression which will be used to preview features for this layer
*/
const QString displayExpression();
QString displayExpression() const;

/** Returns the data provider */
QgsVectorDataProvider* dataProvider();
@@ -269,7 +269,7 @@ class QgsVectorLayer : QgsMapLayer
*
* @note added in 2.9
*/
const QString expressionField( int index );
QString expressionField( int index ) const;

/**
* Changes the expression used to define an expression based (virtual) field
@@ -297,7 +297,7 @@ class QgsVectorLayer : QgsMapLayer
*
* @return See description
*/
int selectedFeatureCount();
int selectedFeatureCount() const;

/**
* Select features found within the search rectangle (in layer's coordinates)
@@ -364,7 +364,7 @@ class QgsVectorLayer : QgsMapLayer
void selectAll();

/** Get all feature Ids */
QgsFeatureIds allFeatureIds();
QgsFeatureIds allFeatureIds() const;

/**
* Invert selection of features found within the search rectangle (in layer's coordinates)
@@ -383,7 +383,7 @@ class QgsVectorLayer : QgsMapLayer
* @see selectedFeaturesIds()
* @see selectedFeaturesIterator() which is more memory friendly when handling large selections
*/
QgsFeatureList selectedFeatures();
QgsFeatureList selectedFeatures() const;

/**
* Get an iterator of the selected features
@@ -396,7 +396,7 @@ class QgsVectorLayer : QgsMapLayer
* @see selectedFeaturesIds()
* @see selectedFeatures()
*/
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() ) const;

/**
* Return reference to identifiers of selected features
@@ -417,7 +417,7 @@ class QgsVectorLayer : QgsMapLayer
void setSelectedFeatures( const QgsFeatureIds &ids ) /Deprecated/;

/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
QgsRectangle boundingBoxOfSelected();
QgsRectangle boundingBoxOfSelected() const;

/** Returns whether the layer contains labels which are enabled and should be drawn.
* @return true if layer contains enabled labels
@@ -573,7 +573,7 @@ class QgsVectorLayer : QgsMapLayer
* @param symbol the symbol
* @return number of features rendered by symbol or -1 if failed or counts are not available
*/
long featureCount( QgsSymbolV2* symbol );
long featureCount( QgsSymbolV2* symbol ) const;

/**
* Update the data source of the layer. The layer's renderer and legend will be preserved only
@@ -607,7 +607,7 @@ class QgsVectorLayer : QgsMapLayer
* Get the string (typically sql) used to define a subset of the layer
* @return The subset string or QString::null if not implemented by the provider
*/
virtual QString subsetString();
virtual QString subsetString() const;

/**
* Query the layer for features specified in request.
@@ -1085,7 +1085,7 @@ class QgsVectorLayer : QgsMapLayer
* that the user has some chance of repairing the damage cleanly.
*/
bool commitChanges();
const QStringList &commitErrors();
QStringList commitErrors() const;

/** Stop editing and discard the edits
* @param deleteBuffer whether to delete editing buffer
@@ -1235,15 +1235,15 @@ class QgsVectorLayer : QgsMapLayer
RangeData range( int idx ) /Deprecated/;

/** Access value relation widget data */
ValueRelationData valueRelation( int idx );
ValueRelationData valueRelation( int idx ) const;

/**
* Get relations, where the foreign key is on this layer
*
* @param idx Only get relations, where idx forms part of the foreign key
* @return A list of relations
*/
QList<QgsRelation> referencingRelations( int idx );
QList<QgsRelation> referencingRelations( int idx ) const;

/**
* Access date format
@@ -1324,13 +1324,13 @@ class QgsVectorLayer : QgsMapLayer
* @param uniqueValues out: result list
* @param limit maximum number of values to return (-1 if unlimited)
*/
void uniqueValues( int index, QList<QVariant> &uniqueValues /Out/, int limit = -1 );
void uniqueValues( int index, QList<QVariant> &uniqueValues /Out/, int limit = -1 ) const;

/** Returns minimum value for an attribute column or invalid variant in case of error */
QVariant minimumValue( int index );
QVariant minimumValue( int index ) const;

/** Returns maximum value for an attribute column or invalid variant in case of error */
QVariant maximumValue( int index );
QVariant maximumValue( int index ) const;

/** Calculates an aggregated value from the layer's features.
* @param aggregate aggregate to calculate
@@ -1345,7 +1345,7 @@ class QgsVectorLayer : QgsMapLayer
const QString& fieldOrExpression,
const QgsAggregateCalculator::AggregateParameters& parameters = QgsAggregateCalculator::AggregateParameters(),
QgsExpressionContext* context = nullptr,
bool* ok = nullptr );
bool* ok = nullptr ) const;

/** Fetches all values from a specified field name or expression.
* @param fieldOrExpression field name or an expression string
@@ -1355,7 +1355,7 @@ class QgsVectorLayer : QgsMapLayer
* @note added in QGIS 2.9
* @see getDoubleValues
*/
QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false ) const;

/** Fetches all double values from a specified field name or expression. Null values or
* invalid expression results are skipped.
@@ -1367,7 +1367,7 @@ class QgsVectorLayer : QgsMapLayer
* @note added in QGIS 2.9
* @see getValues
*/
QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = 0 );
QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = 0 ) const;

/** Set the blending mode used for rendering each feature */
void setFeatureBlendMode( QPainter::CompositionMode blendMode );
@@ -23,13 +23,13 @@



QgsAggregateCalculator::QgsAggregateCalculator( QgsVectorLayer* layer )
QgsAggregateCalculator::QgsAggregateCalculator( const QgsVectorLayer* layer )
: mLayer( layer )
{

}

QgsVectorLayer*QgsAggregateCalculator::layer() const
const QgsVectorLayer* QgsAggregateCalculator::layer() const
{
return mLayer;
}
@@ -86,11 +86,11 @@ class CORE_EXPORT QgsAggregateCalculator
/** Constructor for QgsAggregateCalculator.
* @param layer vector layer to calculate aggregate from
*/
QgsAggregateCalculator( QgsVectorLayer* layer );
QgsAggregateCalculator( const QgsVectorLayer* layer );

/** Returns the associated vector layer.
*/
QgsVectorLayer* layer() const;
const QgsVectorLayer* layer() const;

/** Sets all aggregate parameters from a parameter bundle.
* @param parameters aggregate parameters
@@ -140,7 +140,7 @@ class CORE_EXPORT QgsAggregateCalculator
private:

//! Source layer
QgsVectorLayer* mLayer;
const QgsVectorLayer* mLayer;

//! Filter expression, or empty for no filter
QString mFilterExpression;
@@ -93,7 +93,7 @@ void QgsRelationManager::clear()
emit changed();
}

QList<QgsRelation> QgsRelationManager::referencingRelations( QgsVectorLayer* layer, int fieldIdx ) const
QList<QgsRelation> QgsRelationManager::referencingRelations( const QgsVectorLayer* layer, int fieldIdx ) const
{
if ( !layer )
{
@@ -106,7 +106,7 @@ class CORE_EXPORT QgsRelationManager : public QObject
*
* @return A list of relations matching the given layer and fieldIdx.
*/
QList<QgsRelation> referencingRelations( QgsVectorLayer *layer = nullptr, int fieldIdx = -2 ) const;
QList<QgsRelation> referencingRelations( const QgsVectorLayer* layer = nullptr, int fieldIdx = -2 ) const;

/**
* Get all relations where this layer is the referenced part (i.e. the parent table with the primary key being referenced from another layer).

0 comments on commit 2d50895

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