1 /***************************************************************************
2   qgsgeopackagerasterwritertask.h - QgsGeoPackageRasterWriterTask
3 
4  ---------------------
5  begin                : 23.8.2017
6  copyright            : (C) 2017 by Alessandro Pasotti
7  email                : apasotti at boundlessgeo dot com
8  ***************************************************************************
9  *                                                                         *
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  ***************************************************************************/
16 #ifndef QGSGEOPACKAGERASTERWRITERTASK_H
17 #define QGSGEOPACKAGERASTERWRITERTASK_H
18 
19 
20 ///@cond PRIVATE
21 
22 #define SIP_NO_FILE
23 
24 #include "qgis_core.h"
25 #include "qgsgeopackagerasterwriter.h"
26 #include "qgstaskmanager.h"
27 #include "qgsfeedback.h"
28 
29 
30 /**
31  * \class QgsGeoPackageRasterWriterTask
32  * QgsTask task which performs a QgsGeoPackageRasterWriter layer saving operation as a background
33  * task. This can be used to save a raster layer out to a file without blocking the
34  * QGIS interface.
35  * \see QgsGeoPackageRasterWriterTask
36  * \since QGIS 3.0
37  */
38 class CORE_EXPORT QgsGeoPackageRasterWriterTask : public QgsTask
39 {
40     Q_OBJECT
41 
42   public:
43 
44     /**
45      * Constructor for QgsVectorFileWriterTask. Takes a source \a layer, destination \a fileName
46      * and save \a options.
47      */
48     QgsGeoPackageRasterWriterTask( const QgsMimeDataUtils::Uri &sourceUri, const QString &destinationPath );
49 
50     void cancel() override;
51 
52   signals:
53 
54     /**
55      * Emitted when writing the layer is successfully completed. The \a newFilename
56      * parameter indicates the file path for the written file.
57      */
58     void writeComplete( const QString &newFilename );
59 
60     /**
61      * Emitted when an error occurs which prevented the file being written (or if
62      * the task is canceled). The writing \a error and \a errorMessage will be reported.
63      */
64     void errorOccurred( QgsGeoPackageRasterWriter::WriterError error, const QString &errorMessage );
65 
66   protected:
67 
68     bool run() override;
69     void finished( bool result ) override;
70 
71   private:
72 
73     QgsGeoPackageRasterWriter mWriter;
74     std::unique_ptr< QgsFeedback > mFeedback;
75     QgsGeoPackageRasterWriter::WriterError mError = QgsGeoPackageRasterWriter::WriterError::NoError;
76     QString mErrorMessage;
77 
78 };
79 
80 
81 ///@endcond
82 
83 #endif // QGSGEOPACKAGERASTERWRITERTASK_H
84