24#include "moc_qgsvectorfilewritertask.cpp"
28 , mDestFileName( fileName )
29 , mSinkFlags( sinkFlags )
32 if ( mOptions.fieldValueConverter )
36 mFieldValueConverter.reset( mOptions.fieldValueConverter->clone() );
37 mOptions.fieldValueConverter = mFieldValueConverter.get();
39 if ( !mOptions.feedback )
41 mOwnedFeedback = std::make_unique<QgsFeedback>( );
42 mOptions.feedback = mOwnedFeedback.get();
50 mError = QgsVectorFileWriter::prepareWriteAsVectorFormat( layer, mOptions, mWriterDetails );
55 mOptions.feedback->cancel();
68 mWriterDetails, mDestFileName, mTransformContext, mOptions, &mNewFilename, &mNewLayer, &mErrorMessage, mSinkFlags );
77 emit
completed( mNewFilename, mNewLayer );
QFlags< SinkFlag > SinkFlags
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
virtual void cancel()
Notifies the task that it should terminate.
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
@ CanCancel
Task can be canceled.
void setProgress(double progress)
Sets the task's current progress.
void errorOccurred(int error, const QString &errorMessage)
Emitted when an error occurs which prevented the file being written (or if the task is canceled).
bool run() override
Performs the task's operation.
void completed(const QString &newFilename, const QString &newLayer)
Emitted when writing the layer is successfully completed.
void writeComplete(const QString &newFilename)
Emitted when writing the layer is successfully completed.
void finished(bool result) override
If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether ...
QgsVectorFileWriterTask(QgsVectorLayer *layer, const QString &fileName, const QgsVectorFileWriter::SaveVectorOptions &options, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags())
Constructor for QgsVectorFileWriterTask.
void cancel() override
Notifies the task that it should terminate.
Options to pass to QgsVectorFileWriter::writeAsVectorFormat().
static Q_DECL_DEPRECATED QgsVectorFileWriter::WriterError writeAsVectorFormatV2(QgsVectorLayer *layer, const QString &fileName, const QgsCoordinateTransformContext &transformContext, const QgsVectorFileWriter::SaveVectorOptions &options, QString *newFilename=nullptr, QString *newLayer=nullptr, QString *errorMessage=nullptr)
Writes a layer out to a vector file.
Represents a vector layer which manages a vector based dataset.