Provide a base class version of QgsFeatureSink::addFeature

Means that subclasses are only required to implement addFeatures
This commit is contained in:
Nyall Dawson 2017-04-26 11:56:25 +10:00
parent dd7be73fa4
commit 3dfc4cf6fd
6 changed files with 13 additions and 9 deletions

View File

@ -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()

View File

@ -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/ );
/**

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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;
/**