QGIS API Documentation 3.35.0-Master (274c3da7543)
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#include "qgsmessagelog.h"
24
28
39class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
40{
41 Q_OBJECT
42
43 public:
44
51 QgsProcessingFeedback( bool logFeedback = true );
52
59 virtual void setProgressText( const QString &text );
60
66 virtual void reportError( const QString &error, bool fatalError = false );
67
78 virtual void pushWarning( const QString &warning );
79
91 virtual void pushInfo( const QString &info );
92
107 virtual void pushFormattedMessage( const QString &html, const QString &text );
108
118 virtual void pushCommandInfo( const QString &info );
119
128 virtual void pushDebugInfo( const QString &info );
129
138 virtual void pushConsoleInfo( const QString &info );
139
144 void pushVersionInfo( const QgsProcessingProvider *provider = nullptr );
145
151 void pushFormattedResults( const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &results );
152
159 virtual QString htmlLog() const;
160
167 virtual QString textLog() const;
168
169 private:
170
171 void log( const QString &htmlMessage, const QString &textMessage );
172
173 bool mLogFeedback = true;
174 QString mHtmlLog;
175 QString mTextLog;
176 int mMessageLoggedCount = 0;
177
178};
179
180
194{
195 Q_OBJECT
196
197 public:
198
205
210 void setCurrentStep( int step );
211
212 void setProgressText( const QString &text ) override;
213 void reportError( const QString &error, bool fatalError = false ) override;
214 void pushWarning( const QString &warning ) override;
215 void pushInfo( const QString &info ) override;
216 void pushCommandInfo( const QString &info ) override;
217 void pushDebugInfo( const QString &info ) override;
218 void pushConsoleInfo( const QString &info ) override;
219 void pushFormattedMessage( const QString &html, const QString &text ) override;
220
221 QString htmlLog() const override;
222 QString textLog() const override;
223 private slots:
224
225 void updateOverallProgress( double progress );
226
227 private:
228
229 int mChildSteps = 0;
230 int mCurrentStep = 0;
231 QgsProcessingFeedback *mFeedback = nullptr;
232
233};
234
235#endif // QGSPROCESSINGFEEDBACK_H
236
237
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:45
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
Processing feedback object for multi-step operations.
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