Skip to content
Permalink
Browse files

const correctness QgsVectorLayer::deleteAttributes

  • Loading branch information
m-kuhn authored and nyalldawson committed May 29, 2018
1 parent 04e779a commit b202d606720f312cf72bc3ace944e6015bee78a1
Showing with 10 additions and 6 deletions.
  1. +3 −1 python/core/auto_generated/qgsvectorlayer.sip.in
  2. +4 −4 src/core/qgsvectorlayer.cpp
  3. +3 −1 src/core/qgsvectorlayer.h
@@ -1679,7 +1679,7 @@ Deletes an attribute field (but does not commit it).
changes can be discarded by calling rollBack().
%End

bool deleteAttributes( QList<int> attrs );
bool deleteAttributes( const QList<int> &attrs );
%Docstring
Deletes a list of attribute fields (but does not commit it)

@@ -2559,6 +2559,8 @@ Sets the extent
};




/************************************************************************
* This file has been generated automatically from *
* *
@@ -2677,16 +2677,16 @@ bool QgsVectorLayer::deleteAttribute( int index )
return mEditBuffer->deleteAttribute( index );
}

bool QgsVectorLayer::deleteAttributes( QList<int> attrs )
bool QgsVectorLayer::deleteAttributes( const QList<int> &attrs )
{
bool deleted = false;

// Remove multiple occurrences of same attribute
attrs = attrs.toSet().toList();
QList<int> attrList = attrs.toSet().toList();

std::sort( attrs.begin(), attrs.end(), std::greater<int>() );
std::sort( attrList.begin(), attrList.end(), std::greater<int>() );

Q_FOREACH ( int attr, attrs )
for ( int attr : qgis::as_const( attrList ) )
{
if ( deleteAttribute( attr ) )
{
@@ -1546,7 +1546,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* \returns true if at least one attribute has been deleted
*
*/
bool deleteAttributes( QList<int> attrs );
bool deleteAttributes( const QList<int> &attrs );

bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) override;

@@ -2457,6 +2457,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
friend class QgsVectorLayerFeatureSource;
};



// clazy:excludeall=qstring-allocations

#endif

0 comments on commit b202d60

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