Skip to content

Commit 46ff652

Browse files
committed
QgsVectorLayerImport is a QgsFeatureSink
1 parent 8d03642 commit 46ff652

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

python/core/qgsvectorlayerimport.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer
55
2. create an instance of the class and issue calls to addFeature(...)
66
*/
7-
class QgsVectorLayerImport
7+
class QgsVectorLayerImport : QgsFeatureSink
88
{
99
%TypeHeaderCode
1010
#include <qgsvectorlayerimport.h>
@@ -85,7 +85,7 @@ class QProgressDialog;
8585

8686
int errorCount() const;
8787

88-
/** Add feature to the new created layer */
88+
bool addFeatures( QgsFeatureList &features );
8989
bool addFeature( QgsFeature &feature );
9090

9191
/** Close the new created layer */

src/core/qgsvectorlayerimport.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ QString QgsVectorLayerImport::errorMessage()
145145
return mErrorMessage;
146146
}
147147

148+
bool QgsVectorLayerImport::addFeatures( QgsFeatureList &features )
149+
{
150+
QgsFeatureList::iterator fIt = features.begin();
151+
bool result = true;
152+
for ( ; fIt != features.end(); ++fIt )
153+
{
154+
result = result && addFeature( *fIt );
155+
}
156+
return result;
157+
}
158+
148159
bool QgsVectorLayerImport::addFeature( QgsFeature &feat )
149160
{
150161
QgsAttributes attrs = feat.attributes();

src/core/qgsvectorlayerimport.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgis_core.h"
2323
#include "qgis.h"
2424
#include "qgsfeature.h"
25+
#include "qgsfeaturesink.h"
2526

2627
class QProgressDialog;
2728
class QgsVectorDataProvider;
@@ -34,7 +35,7 @@ class QgsFields;
3435
1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer
3536
2. create an instance of the class and issue calls to addFeature(...)
3637
*/
37-
class CORE_EXPORT QgsVectorLayerImport
38+
class CORE_EXPORT QgsVectorLayerImport : public QgsFeatureSink
3839
{
3940
public:
4041

@@ -114,8 +115,8 @@ class CORE_EXPORT QgsVectorLayerImport
114115

115116
int errorCount() const { return mErrorCount; }
116117

117-
//! Add feature to the new created layer
118-
bool addFeature( QgsFeature &feature );
118+
bool addFeatures( QgsFeatureList &features ) override;
119+
bool addFeature( QgsFeature &feature ) override;
119120

120121
//! Close the new created layer
121122
~QgsVectorLayerImport();

0 commit comments

Comments
 (0)