Skip to content


Browse files Browse the repository at this point in the history
Merge pull request #3959 from nyalldawson/processing_port_feedback
[processing] Port feedback object to c++
  • Loading branch information
nyalldawson committed Jan 11, 2017
2 parents 26a8a54 + 86e1138 commit a7806d1
Show file tree
Hide file tree
Showing 303 changed files with 1,024 additions and 836 deletions.
5 changes: 5 additions & 0 deletions doc/api_break.dox
Expand Up @@ -1831,6 +1831,11 @@ Processing {#qgis_api_break_3_0_Processing}

- Algorithm providers now subclass the c++ QgsProcessingProvider class, and must be adapted to the API for QgsProcessingProvider. Specifically,
getName() should be replaced with id(), getDescription() with name(), and getIcon with icon().
- Algorithm's processAlgorithm method now passes a QgsProcessingFeedback object instead of the loosely defined progress parameter. Algorithms will
need to update their use of the progress argument to utilise the QgsProcessingFeedback API.
- Similarly, Python processing scripts no longer have access to a progress variable for reporting their progress. Instead they have a feedback
object of type QgsProcessingFeedback, and will need to adapt their use of progress reporting to the QgsProcessingFeedback API.
- SilentProgress was removed. Use the base QgsProcessingFeedback class instead.

QGIS 2.4 {#qgis_api_break_2_4}
Expand Down
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -259,6 +259,7 @@
%Include layertree/qgslayertreeregistrybridge.sip
%Include layertree/qgslayertreeutils.sip

%Include processing/qgsprocessingfeedback.sip
%Include processing/qgsprocessingprovider.sip
%Include processing/qgsprocessingregistry.sip

Expand Down
80 changes: 80 additions & 0 deletions python/core/processing/qgsprocessingfeedback.sip
@@ -0,0 +1,80 @@
* \class QgsProcessingFeedback
* \ingroup core
* Base class for providing feedback from a processing algorithm.
* This base class implementation silently ignores all feedback reported by algorithms.
* Subclasses of QgsProcessingFeedback can be used to log this feedback or report
* it to users via the GUI.
* \note added in QGIS 3.0
class QgsProcessingFeedback : public QgsFeedback
#include <qgsprocessingfeedback.h>


* Sets the algorithm's progress. The progress
* argument is limited to the range 0-100 and reflects the percentage
* progress through the task.
* @see setProgressText()
virtual void setProgress( double progress );

* Sets a progress report text string. This can be used in conjunction with
* setProgress() to provide detailed progress reports, such as "Transformed
* 4 of 5 layers".
* @see setProgress()
virtual void setProgressText( const QString& text );

* Reports that the algorithm encountered an error which prevented it
* from successfully executing.
virtual void reportError( const QString& error );

* Pushes a general informational message from the algorithm. This can
* be used to report feedback which is neither a status report or an
* error, such as "Found 47 matching features".
* @see pushCommandInfo()
* @see pushDebugInfo()
* @see pushConsoleInfo()
virtual void pushInfo( const QString& info );

* Pushes an informational message containing a command from the algorithm.
* This is usually used to report commands which are executed in an external
* application or as subprocesses.
* @see pushInfo()
* @see pushDebugInfo()
* @see pushConsoleInfo()
virtual void pushCommandInfo( const QString& info );

* Pushes an informational message containing debugging helpers from
* the algorithm.
* @see pushInfo()
* @see pushCommandInfo()
* @see pushConsoleInfo()
virtual void pushDebugInfo( const QString& info );

* Pushes a console feedback message from the algorithm. This is used to
* report the output from executing an external command or subprocess.
* @see pushInfo()
* @see pushDebugInfo()
* @see pushCommandInfo()
virtual void pushConsoleInfo( const QString& info );

Expand Up @@ -75,7 +75,7 @@ def defineCharacteristics(self):
self.addOutput(OutputVector(self.OUTPUT_LAYER,'Output layer with selected features')))

def processAlgorithm(self, progress):
def processAlgorithm(self, feedback):
"""Here is where the processing itself takes place."""

# The first thing to do is retrieve the values of the parameters
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/
Expand Up @@ -56,7 +56,7 @@ def getIcon(self):
def getCustomParametersDialog(self):
return GdalAlgorithmDialog(self)

def processAlgorithm(self, progress):
def processAlgorithm(self, feedback):
commands = self.getConsoleCommands()
layers = dataobjects.getVectorLayers()
supported = dataobjects.getSupportedOutputVectorLayerExtensions()
Expand All @@ -73,7 +73,7 @@ def processAlgorithm(self, progress):
c = re.sub('["\']{}["\']'.format(fileName), "'"