Skip to content
Permalink
Browse files
QgsVectorDataProvider is a QgsFeatureSink
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 3633363 commit 7ae71ded57d3929e1f5582af3665768484313dc3
Showing with 15 additions and 11 deletions.
  1. +2 −0 python/core/qgsfeaturesink.sip
  2. +2 −5 python/core/qgsvectordataprovider.sip
  3. +2 −0 src/core/qgsfeaturesink.h
  4. +5 −0 src/core/qgsvectordataprovider.cpp
  5. +4 −6 src/core/qgsvectordataprovider.h
@@ -28,13 +28,15 @@ class QgsFeatureSink
%Docstring
Adds a single ``feature`` to the sink.
\see addFeatures()
:return: true in case of success and false in case of failure
:rtype: bool
%End

virtual bool addFeatures( QgsFeatureList &features ) = 0;
%Docstring
Adds a list of ``features`` to the sink.
\see addFeature()
:return: true in case of success and false in case of failure
:rtype: bool
%End

@@ -1,5 +1,5 @@

class QgsVectorDataProvider : QgsDataProvider
class QgsVectorDataProvider : QgsDataProvider, QgsFeatureSink
{
%TypeHeaderCode
#include <qgsvectordataprovider.h>
@@ -197,10 +197,7 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual void enumValues( int index, QStringList& enumList /Out/ ) const;

/**
* Adds a list of features
* @return true in case of success and false in case of failure
*/
virtual bool addFeature( QgsFeature &feature /In,Out/ );
virtual bool addFeatures( QList<QgsFeature> &flist /In,Out/ );

/**
@@ -38,12 +38,14 @@ class CORE_EXPORT QgsFeatureSink
/**
* Adds a single \a feature to the sink.
* \see addFeatures()
* \returns true in case of success and false in case of failure
*/
virtual bool addFeature( QgsFeature &feature ) = 0;

/**
* Adds a list of \a features to the sink.
* \see addFeature()
* \returns true in case of success and false in case of failure
*/
virtual bool addFeatures( QgsFeatureList &features ) = 0;

@@ -495,6 +495,11 @@ QVariant QgsVectorDataProvider::aggregate( QgsAggregateCalculator::Aggregate agg
return QVariant();
}

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

void QgsVectorDataProvider::clearMinMaxCache()
{
mCacheMinMaxDirty = true;
@@ -30,6 +30,7 @@ class QTextCodec;
#include "qgsaggregatecalculator.h"
#include "qgsmaplayerdependency.h"
#include "qgsrelation.h"
#include "qgsfeaturesink.h"

typedef QList<int> QgsAttributeList;
typedef QSet<int> QgsAttributeIds;
@@ -49,7 +50,7 @@ class QgsFeedback;
*
*
*/
class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeatureSink
{
Q_OBJECT

@@ -247,11 +248,8 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
virtual void enumValues( int index, QStringList &enumList ) const { Q_UNUSED( index ); enumList.clear(); }

/**
* Adds a list of features
* \returns true in case of success and false in case of failure
*/
virtual bool addFeatures( QgsFeatureList &flist );
virtual bool addFeature( QgsFeature &feature ) override;
virtual bool addFeatures( QgsFeatureList &flist ) override;

/**
* Deletes one or more features from the provider. This requires the DeleteFeatures capability.

0 comments on commit 7ae71de

Please sign in to comment.