18 #ifndef QGSVECTORLAYEREXPORTER_H
19 #define QGSVECTORLAYEREXPORTER_H
21 #include "qgis_core.h"
31 class QProgressDialog;
84 const QString &providerKey,
86 bool onlySelected =
false,
87 QString *errorMessage
SIP_OUT =
nullptr,
88 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
105 const QString &provider,
109 bool overwrite =
false,
110 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
111 QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags() );
130 QString errorMessage()
const;
140 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() )
override;
153 bool createSpatialIndex();
157 QString mErrorMessage;
164 QMap<int, int> mOldToNewAttrIdx;
168 int mFeatureBufferMemoryUsage = 0;
170 bool mCreateSpatialIndex =
true;
203 const QString &providerKey,
205 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
206 bool ownsLayer =
false );
216 const QString &providerKey,
218 const QMap<QString, QVariant> &options = QMap<QString, QVariant>() )
SIP_FACTORY;
220 void cancel()
override;
238 void finished(
bool result )
override;
242 QPointer< QgsVectorLayer > mLayer =
nullptr;
243 bool mOwnsLayer =
false;
246 QString mDestProviderKey;
248 QMap<QString, QVariant> mOptions;
250 std::unique_ptr< QgsFeedback > mOwnedFeedback;
253 QString mErrorMessage;
This class represents a coordinate reference system (CRS).
An interface for objects which accept features via addFeature(s) methods.
virtual bool flushBuffer()
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to...
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
virtual QString lastError() const
Returns the most recent error encountered by the sink, e.g.
virtual bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())=0
Adds a list of features to the sink.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Container of fields for a vector layer.
Abstract base class for long running background tasks.
This is the base class for vector data providers.
QgsTask task which performs a QgsVectorLayerExporter layer export operation as a background task.
void exportComplete()
Emitted when exporting the layer is successfully completed.
void errorOccurred(int error, const QString &errorMessage)
Emitted when an error occurs which prevented the layer being exported (or if the task is canceled).
A convenience class for exporting vector layers to a destination data provider.
@ ErrUserCanceled
User canceled the export.
@ ErrCreateDataSource
Could not create the destination data source.
@ ErrInvalidProvider
Could not find a matching provider key.
@ ErrInvalidLayer
Could not access newly created destination layer.
@ ErrAttributeCreationFailed
Destination provider was unable to create an attribute.
@ ErrCreateLayer
Could not create destination layer.
@ ErrConnectionFailed
Could not connect to destination.
@ ErrProviderUnsupportedFeature
Provider does not support creation of empty layers.
@ ErrProjection
An error occurred while reprojecting features to destination CRS.
@ NoError
No errors were encountered.
@ ErrFeatureWriteFailed
An error occurred while writing a feature to the destination.
@ ErrAttributeTypeUnsupported
Source layer has an attribute type which could not be handled by destination.
int errorCount() const
Returns the number of error messages encountered during the export.
QgsVectorLayerExporter & operator=(const QgsVectorLayerExporter &rh)=delete
QgsVectorLayerExporter cannot be copied.
QgsVectorLayerExporter(const QgsVectorLayerExporter &rh)=delete
QgsVectorLayerExporter cannot be copied.
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
QList< QgsFeature > QgsFeatureList
const QgsCoordinateReferenceSystem & crs