QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsproxyprogresstask.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsproxyprogresstask.h
3  ----------------------
4  begin : August 2018
5  copyright : (C) 2018 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 QGSPROXYPROGRESSTASK_H
19 #define QGSPROXYPROGRESSTASK_H
20 
22 #include "qgstaskmanager.h"
23 
24 #include <QWaitCondition>
25 
37 class CORE_EXPORT QgsProxyProgressTask : public QgsTask
38 {
39  Q_OBJECT
40 
41  public:
42 
46  QgsProxyProgressTask( const QString &description );
47 
54  void finalize( bool result );
55 
56  bool run() override;
57 
63  void setProxyProgress( double progress );
64 
65  private:
66 
67  QWaitCondition mNotFinishedWaitCondition;
68  QMutex mNotFinishedMutex;
69  bool mAlreadyFinished = false;
70  bool mResult = true;
71 
72 };
73 
83 class CORE_EXPORT QgsScopedProxyProgressTask
84 {
85  public:
86 
90  QgsScopedProxyProgressTask( const QString &description );
91 
93 
97  void setProgress( double progress );
98 
99  private:
100 
101  QgsProxyProgressTask *mTask = nullptr;
102 
103  // SIP generates .cpp code that doesn't compile if commenting out the legit following line.
104  // Q_DISABLE_COPY( QgsScopedProxyProgressTask )
105 };
106 
107 #endif // QGSPROXYPROGRESSTASK_H
A QgsTask shell which proxies progress reports.
Scoped QgsScopedProxyProgressTask, which automatically adds the proxy task to the application task ma...
Abstract base class for long running background tasks.
virtual bool run()=0
Performs the task's operation.
void setProgress(double progress)
Sets the task's current progress.