Skip to content

Commit

Permalink
Provide a base class version of QgsFeatureSink::addFeature
Browse files Browse the repository at this point in the history
Means that subclasses are only required to implement addFeatures
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent dd7be73 commit 3dfc4cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsfeaturesink.sip
Expand Up @@ -24,7 +24,7 @@ class QgsFeatureSink

virtual ~QgsFeatureSink();

virtual bool addFeature( QgsFeature &feature ) = 0;
virtual bool addFeature( QgsFeature &feature );
%Docstring
Adds a single ``feature`` to the sink.
\see addFeatures()
Expand Down
1 change: 0 additions & 1 deletion python/core/qgsvectordataprovider.sip
Expand Up @@ -197,7 +197,6 @@ class QgsVectorDataProvider : QgsDataProvider, QgsFeatureSink
*/
virtual void enumValues( int index, QStringList& enumList /Out/ ) const;

virtual bool addFeature( QgsFeature &feature /In,Out/ );
virtual bool addFeatures( QList<QgsFeature> &flist /In,Out/ );

/**
Expand Down
11 changes: 11 additions & 0 deletions src/core/qgsfeaturesink.cpp
Expand Up @@ -17,6 +17,17 @@

#include "qgsfeaturestore.h"

bool QgsFeatureSink::addFeature( QgsFeature &feature )
{
QgsFeatureList features;
features << feature;
bool result = addFeatures( features );

// need to update the passed feature reference to the updated copy from the features list
feature = features.at( 0 );
return result;
}

bool QgsFeatureSink::addFeatures( QgsFeatureIterator &iterator )
{
QgsFeature f;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeaturesink.h
Expand Up @@ -41,7 +41,7 @@ class CORE_EXPORT QgsFeatureSink
* \see addFeatures()
* \returns true in case of success and false in case of failure
*/
virtual bool addFeature( QgsFeature &feature ) = 0;
virtual bool addFeature( QgsFeature &feature );

/**
* Adds a list of \a features to the sink.
Expand Down
5 changes: 0 additions & 5 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -495,11 +495,6 @@ QVariant QgsVectorDataProvider::aggregate( QgsAggregateCalculator::Aggregate agg
return QVariant();
}

bool QgsVectorDataProvider::addFeature( QgsFeature &feature )
{
return addFeatures( QgsFeatureList() << feature );
}

void QgsVectorDataProvider::clearMinMaxCache()
{
mCacheMinMaxDirty = true;
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsvectordataprovider.h
Expand Up @@ -248,7 +248,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat
*/
virtual void enumValues( int index, QStringList &enumList ) const { Q_UNUSED( index ); enumList.clear(); }

virtual bool addFeature( QgsFeature &feature ) override;
virtual bool addFeatures( QgsFeatureList &flist ) override;

/**
Expand Down

0 comments on commit 3dfc4cf

Please sign in to comment.