QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsprocessingfeedback.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingfeedback.h
3  -----------------------
4  begin : December 2016
5  copyright : (C) 2016 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 QGSPROCESSINGFEEDBACK_H
19 #define QGSPROCESSINGFEEDBACK_H
20 
21 #include "qgis_core.h"
22 #include "qgsfeedback.h"
23 #include "qgsmessagelog.h"
24 
35 class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
36 {
37  Q_OBJECT
38 
39  public:
40 
47  virtual void setProgressText( const QString &text ) { Q_UNUSED( text ); }
48 
54  virtual void reportError( const QString &error, bool fatalError = false ) { Q_UNUSED( fatalError ); QgsMessageLog::logMessage( error, tr( "Processing" ), Qgis::Critical ); }
55 
64  virtual void pushInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
65 
74  virtual void pushCommandInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
75 
83  virtual void pushDebugInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
84 
92  virtual void pushConsoleInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
93 
94 };
95 
96 
110 {
111  Q_OBJECT
112 
113  public:
114 
121 
126  void setCurrentStep( int step );
127 
128  void setProgressText( const QString &text ) override;
129  void reportError( const QString &error, bool fatalError ) override;
130  void pushInfo( const QString &info ) override;
131  void pushCommandInfo( const QString &info ) override;
132  void pushDebugInfo( const QString &info ) override;
133  void pushConsoleInfo( const QString &info ) override;
134 
135  private slots:
136 
137  void updateOverallProgress( double progress );
138 
139  private:
140 
141  int mChildSteps = 0;
142  int mCurrentStep = 0;
143  QgsProcessingFeedback *mFeedback = nullptr;
144 };
145 
146 #endif // QGSPROCESSINGFEEDBACK_H
147 
148 
Base class for providing feedback from a processing algorithm.
Processing feedback object for multi-step operations.
virtual void setProgressText(const QString &text)
Sets a progress report text string.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
virtual void pushConsoleInfo(const QString &info)
Pushes a console feedback message from the algorithm.
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.