Skip to content

Commit

Permalink
[processing] Port feedback object to c++
Browse files Browse the repository at this point in the history
Algorithms are now passed a QgsProcessingFeedback object
instead of the loosely defined progress parameter.
  • Loading branch information
nyalldawson committed Jan 11, 2017
1 parent 26a8a54 commit ede452b
Show file tree
Hide file tree
Showing 303 changed files with 1,012 additions and 835 deletions.
5 changes: 5 additions & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
{
%TypeHeaderCode
#include <qgsprocessingfeedback.h>
%End

public:

/**
* 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.