QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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
27
37class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
38{
39 Q_OBJECT
40
41 public:
42
49 QgsProcessingFeedback( bool logFeedback = true );
50
57 virtual void setProgressText( const QString &text );
58
64 virtual void reportError( const QString &error, bool fatalError = false );
65
76 virtual void pushWarning( const QString &warning );
77
89 virtual void pushInfo( const QString &info );
90
105 virtual void pushFormattedMessage( const QString &html, const QString &text );
106
116 virtual void pushCommandInfo( const QString &info );
117
126 virtual void pushDebugInfo( const QString &info );
127
136 virtual void pushConsoleInfo( const QString &info );
137
142 void pushVersionInfo( const QgsProcessingProvider *provider = nullptr );
143
149 void pushFormattedResults( const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &results );
150
157 virtual QString htmlLog() const;
158
165 virtual QString textLog() const;
166
167 private:
168
169 void log( const QString &htmlMessage, const QString &textMessage );
170
171 bool mLogFeedback = true;
172 QString mHtmlLog;
173 QString mTextLog;
174 int mMessageLoggedCount = 0;
175
176};
177
178
191{
192 Q_OBJECT
193
194 public:
195
202
207 void setCurrentStep( int step );
208
209 void setProgressText( const QString &text ) override;
210 void reportError( const QString &error, bool fatalError = false ) override;
211 void pushWarning( const QString &warning ) override;
212 void pushInfo( const QString &info ) override;
213 void pushCommandInfo( const QString &info ) override;
214 void pushDebugInfo( const QString &info ) override;
215 void pushConsoleInfo( const QString &info ) override;
216 void pushFormattedMessage( const QString &html, const QString &text ) override;
217
218 QString htmlLog() const override;
219 QString textLog() const override;
220 private slots:
221
222 void updateOverallProgress( double progress );
223
224 private:
225
226 int mChildSteps = 0;
227 int mCurrentStep = 0;
228 QgsProcessingFeedback *mFeedback = nullptr;
229
230};
231
232#endif // QGSPROCESSINGFEEDBACK_H
233
234
QgsFeedback(QObject *parent=nullptr)
Construct a feedback object.
Definition qgsfeedback.h:48
double progress() const
Returns the current progress reported by the feedback object.
Definition qgsfeedback.h:77
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
void pushVersionInfo(const QgsProcessingProvider *provider=nullptr)
Pushes a summary of the QGIS (and underlying library) version information to the log.
virtual QString textLog() const
Returns the plain text contents of the log, which contains all messages pushed to the feedback object...
QgsProcessingFeedback(bool logFeedback=true)
Constructor for QgsProcessingFeedback.
void pushFormattedResults(const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &results)
Pushes a summary of the execution results to the log.
virtual QString htmlLog() const
Returns the HTML formatted contents of the log, which contains all messages pushed to the feedback ob...
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
virtual void pushFormattedMessage(const QString &html, const QString &text)
Pushes a pre-formatted message from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual void pushConsoleInfo(const QString &info)
Pushes a console feedback message from the algorithm.
virtual void setProgressText(const QString &text)
Sets a progress report text string.
QgsProcessingMultiStepFeedback(int steps, QgsProcessingFeedback *feedback)
Constructor for QgsProcessingMultiStepFeedback, for a process with the specified number of steps.
void pushDebugInfo(const QString &info) override
Pushes an informational message containing debugging helpers from the algorithm.
void pushFormattedMessage(const QString &html, const QString &text) override
Pushes a pre-formatted message from the algorithm.
void pushConsoleInfo(const QString &info) override
Pushes a console feedback message from the algorithm.
void pushInfo(const QString &info) override
Pushes a general informational message from the algorithm.
void pushWarning(const QString &warning) override
Pushes a warning informational message from the algorithm.
void setProgressText(const QString &text) override
Sets a progress report text string.
void setCurrentStep(int step)
Sets the step which is being executed.
void reportError(const QString &error, bool fatalError=false) override
Reports that the algorithm encountered an error while executing.
QString textLog() const override
Returns the plain text contents of the log, which contains all messages pushed to the feedback object...
void pushCommandInfo(const QString &info) override
Pushes an informational message containing a command from the algorithm.
QString htmlLog() const override
Returns the HTML formatted contents of the log, which contains all messages pushed to the feedback ob...
Abstract base class for processing providers.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call