Skip to content

Commit

Permalink
QgsVectorDataProvider is a QgsFeatureSink
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 3633363 commit 7ae71de
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions python/core/qgsfeaturesink.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 2 additions & 5 deletions python/core/qgsvectordataprovider.sip
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

class QgsVectorDataProvider : QgsDataProvider
class QgsVectorDataProvider : QgsDataProvider, QgsFeatureSink
{
%TypeHeaderCode
#include <qgsvectordataprovider.h>
Expand Down Expand Up @@ -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/ );

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsfeaturesink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions src/core/qgsvectordataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,7 +50,7 @@ class QgsFeedback;
*
*
*/
class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeatureSink
{
Q_OBJECT

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7ae71de

Please sign in to comment.