QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsvectorfilewritertask.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorfilewritertask.h
3  -------------------------
4  begin : Feb 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSVECTORFILEWRITERTASK_H
19 #define QGSVECTORFILEWRITERTASK_H
20 
21 #include "qgis_core.h"
22 #include "qgsvectorfilewriter.h"
23 #include "qgstaskmanager.h"
24 #include "qgsvectorlayer.h"
25 
36 class CORE_EXPORT QgsVectorFileWriterTask : public QgsTask
37 {
38  Q_OBJECT
39 
40  public:
41 
47  const QString &fileName,
49 
50  void cancel() override;
51 
52  signals:
53 
58  void writeComplete( const QString &newFilename );
59 
64  void errorOccurred( int error, const QString &errorMessage );
65 
66  protected:
67 
68  bool run() override;
69  void finished( bool result ) override;
70 
71  private:
72 
73  QString mDestFileName;
74 
75  std::unique_ptr< QgsFeedback > mOwnedFeedback;
77 
78  QString mNewFilename;
79  QString mErrorMessage;
80 
82  QgsVectorFileWriter::PreparedWriterDetails mWriterDetails;
83  std::unique_ptr< QgsVectorFileWriter::FieldValueConverter > mFieldValueConverter;
84 };
85 
86 #endif
Options to pass to writeAsVectorFormat()
Abstract base class for long running background tasks.
virtual void cancel()
Notifies the task that it should terminate.
virtual void finished(bool result)
If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether ...
virtual bool run()=0
Performs the task&#39;s operation.
QgsTask task which performs a QgsVectorFileWriter layer saving operation as a background task...
Represents a vector layer which manages a vector based data sets.