18#ifndef QGSVECTORLAYEREXPORTER_H
19#define QGSVECTORLAYEREXPORTER_H
68 const QString &providerKey,
70 bool onlySelected =
false,
72 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
192 void setFilterExpression(
const QString &expression );
206 QString filterExpression()
const;
231 QList<QgsVectorLayerExporter::OutputField> outputFields()
const;
242 void setOutputFields(
const QList<QgsVectorLayerExporter::OutputField> &fields );
245 bool mSelectedOnly =
false;
253 QString mFilterExpression;
256 QList< QgsVectorLayerExporter::OutputField > mOutputFields;
276 const QString &providerKey,
278 QString *errorMessage
SIP_OUT =
nullptr,
279 const QMap<QString, QVariant> &providerOptions = QMap<QString, QVariant>(),
297 const QString &provider,
301 bool overwrite =
false,
302 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
351 bool createSpatialIndex();
355 QString mErrorMessage;
362 QMap<int, int> mOldToNewAttrIdx;
363 int mAttributeCount = -1;
366 int mFeatureBufferMemoryUsage = 0;
368 bool mCreateSpatialIndex =
true;
401 const QString &providerKey,
403 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
404 bool ownsLayer =
false
419 const QString &providerKey,
421 const QMap<QString, QVariant> &providerOptions = QMap<QString, QVariant>(),
422 bool ownsLayer =
false
434 const QString &providerKey,
436 const QMap<QString, QVariant> &options = QMap<QString, QVariant>()
456 void finished(
bool result )
override;
459 QPointer< QgsVectorLayer > mLayer =
nullptr;
460 bool mOwnsLayer =
false;
463 QString mDestProviderKey;
465 QMap<QString, QVariant> mOptions;
467 std::unique_ptr< QgsFeedback > mOwnedFeedback;
470 QString mErrorMessage;
VectorExportResult
Vector layer export result codes.
@ Success
No errors were encountered.
QFlags< VectorDataProviderAttributeEditCapability > VectorDataProviderAttributeEditCapabilities
Attribute editing capabilities which may be supported by vector data providers.
WkbType
The WKB type describes the number of dimensions a geometry has.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
An interface for objects which accept features via addFeature(s) methods.
QFlags< SinkFlag > SinkFlags
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 unique ID, geometry and a list of field...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
A QgsRectangle with associated coordinate reference system.
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
Base class for vector data providers.
void finished(bool result) override
If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether ...
QgsVectorLayerExporterTask(QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem &destinationCrs, const QMap< QString, QVariant > &options=QMap< QString, QVariant >(), bool ownsLayer=false)
Constructor for QgsVectorLayerExporterTask.
void exportComplete()
Emitted when exporting the layer is successfully completed.
void errorOccurred(Qgis::VectorExportResult error, const QString &errorMessage)
Emitted when an error occurs which prevented the layer being exported (or if the task is canceled).
void cancel() override
Notifies the task that it should terminate.
static QgsVectorLayerExporterTask * withLayerOwnership(QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem &destinationCrs, const QMap< QString, QVariant > &options=QMap< QString, QVariant >())
Creates a new QgsVectorLayerExporterTask which has ownership over a source layer.
bool run() override
Performs the task's operation.
Encapsulates options for use with QgsVectorLayerExporter.
void setSelectedOnly(bool selected)
Sets whether the export should only include selected features.
bool selectedOnly() const
Returns whether the export will only include selected features.
A convenience class for exporting vector layers to a destination data provider.
QgsVectorLayerExporter & operator=(const QgsVectorLayerExporter &rh)=delete
static Qgis::VectorExportResult exportLayer(QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem &destCRS, bool onlySelected=false, QString *errorMessage=nullptr, const QMap< QString, QVariant > &options=QMap< QString, QVariant >(), QgsFeedback *feedback=nullptr)
Writes the contents of vector layer to a different datasource.
int errorCount() const
Returns the number of error messages encountered during the export.
QString errorMessage() const
Returns any error message encountered during the export.
QgsVectorLayerExporter(const QgsVectorLayerExporter &rh)=delete
Qgis::VectorExportResult errorCode() const
Returns any encountered error code, or false if no error was encountered.
QgsVectorLayerExporter(const QString &uri, const QString &provider, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, bool overwrite=false, const QMap< QString, QVariant > &options=QMap< QString, QVariant >(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Constructor for QgsVectorLayerExporter.
Represents a vector layer which manages a vector based dataset.
QList< QgsFeature > QgsFeatureList
QString expression
The expression for the exported field from the source fields.
OutputField(const QgsField &field, const QString &expression)
Constructor for OutputField, with the specified field definition and source expression.
QgsField field
Destination field definition.