Skip to content

Commit

Permalink
Save algorithm results to dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 21, 2017
1 parent edcd058 commit ce28cf5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions python/gui/processing/qgsprocessingalgorithmdialogbase.sip
Expand Up @@ -69,6 +69,19 @@ Switches the dialog to the log page.
bool wasExecuted() const;
%Docstring
Returns true if an algorithm was executed in the dialog.

.. seealso:: :py:func:`results()`

.. seealso:: :py:func:`setExecuted()`
%End

QVariantMap results() const;
%Docstring
Returns the results returned by the algorithm executed.

.. seealso:: :py:func:`wasExecuted()`

.. seealso:: :py:func:`setResults()`
%End

QgsProcessingFeedback *createFeedback() /Factory/;
Expand Down Expand Up @@ -157,6 +170,19 @@ Clears any current progress from the dialog.
void setExecuted( bool executed );
%Docstring
Sets whether the algorithm was executed through the dialog.

.. seealso:: :py:func:`wasExecuted()`

.. seealso:: :py:func:`setResults()`
%End

void setResults( const QVariantMap &results );
%Docstring
Sets the algorithm results.

.. seealso:: :py:func:`results()`

.. seealso:: :py:func:`setExecuted()`
%End

void setInfo( const QString &message, bool isError = false, bool escapeHtml = true );
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -276,6 +276,7 @@ def finish(self, successful, result, context, feedback):
return

self.setExecuted(True)
self.setResults(result)
self.setInfo(self.tr('Algorithm \'{0}\' finished').format(self.algorithm().displayName()), escapeHtml=False)

if not keepOpen:
Expand Down
5 changes: 5 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -210,6 +210,11 @@ void QgsProcessingAlgorithmDialogBase::setExecuted( bool executed )
mExecuted = executed;
}

void QgsProcessingAlgorithmDialogBase::setResults( const QVariantMap &results )
{
mResults = results;
}

void QgsProcessingAlgorithmDialogBase::finished( bool, const QVariantMap &, QgsProcessingContext &, QgsProcessingFeedback * )
{

Expand Down
19 changes: 19 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.h
Expand Up @@ -118,9 +118,18 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::

/**
* Returns true if an algorithm was executed in the dialog.
* \see results()
* \see setExecuted()
*/
bool wasExecuted() const { return mExecuted; }

/**
* Returns the results returned by the algorithm executed.
* \see wasExecuted()
* \see setResults()
*/
QVariantMap results() const { return mResults; }

/**
* Creates a new processing feedback object, automatically connected to the appropriate
* slots in this dialog.
Expand Down Expand Up @@ -203,9 +212,18 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::

/**
* Sets whether the algorithm was executed through the dialog.
* \see wasExecuted()
* \see setResults()
*/
void setExecuted( bool executed );

/**
* Sets the algorithm results.
* \see results()
* \see setExecuted()
*/
void setResults( const QVariantMap &results );

/**
* Displays an info \a message in the dialog's log.
*/
Expand Down Expand Up @@ -250,6 +268,7 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
QgsMessageBar *mMessageBar = nullptr;

bool mExecuted = false;
QVariantMap mResults;
QWidget *mMainWidget = nullptr;
QgsProcessingAlgorithm *mAlgorithm = nullptr;
bool mHelpCollapsed = false;
Expand Down

0 comments on commit ce28cf5

Please sign in to comment.