Skip to content

Commit ce28cf5

Browse files
committed
Save algorithm results to dialog
1 parent edcd058 commit ce28cf5

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

python/gui/processing/qgsprocessingalgorithmdialogbase.sip

+26
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ Switches the dialog to the log page.
6969
bool wasExecuted() const;
7070
%Docstring
7171
Returns true if an algorithm was executed in the dialog.
72+
73+
.. seealso:: :py:func:`results()`
74+
75+
.. seealso:: :py:func:`setExecuted()`
76+
%End
77+
78+
QVariantMap results() const;
79+
%Docstring
80+
Returns the results returned by the algorithm executed.
81+
82+
.. seealso:: :py:func:`wasExecuted()`
83+
84+
.. seealso:: :py:func:`setResults()`
7285
%End
7386

7487
QgsProcessingFeedback *createFeedback() /Factory/;
@@ -157,6 +170,19 @@ Clears any current progress from the dialog.
157170
void setExecuted( bool executed );
158171
%Docstring
159172
Sets whether the algorithm was executed through the dialog.
173+
174+
.. seealso:: :py:func:`wasExecuted()`
175+
176+
.. seealso:: :py:func:`setResults()`
177+
%End
178+
179+
void setResults( const QVariantMap &results );
180+
%Docstring
181+
Sets the algorithm results.
182+
183+
.. seealso:: :py:func:`results()`
184+
185+
.. seealso:: :py:func:`setExecuted()`
160186
%End
161187

162188
void setInfo( const QString &message, bool isError = false, bool escapeHtml = true );

python/plugins/processing/gui/AlgorithmDialog.py

+1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def finish(self, successful, result, context, feedback):
276276
return
277277

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

281282
if not keepOpen:

src/gui/processing/qgsprocessingalgorithmdialogbase.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ void QgsProcessingAlgorithmDialogBase::setExecuted( bool executed )
210210
mExecuted = executed;
211211
}
212212

213+
void QgsProcessingAlgorithmDialogBase::setResults( const QVariantMap &results )
214+
{
215+
mResults = results;
216+
}
217+
213218
void QgsProcessingAlgorithmDialogBase::finished( bool, const QVariantMap &, QgsProcessingContext &, QgsProcessingFeedback * )
214219
{
215220

src/gui/processing/qgsprocessingalgorithmdialogbase.h

+19
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,18 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
118118

119119
/**
120120
* Returns true if an algorithm was executed in the dialog.
121+
* \see results()
122+
* \see setExecuted()
121123
*/
122124
bool wasExecuted() const { return mExecuted; }
123125

126+
/**
127+
* Returns the results returned by the algorithm executed.
128+
* \see wasExecuted()
129+
* \see setResults()
130+
*/
131+
QVariantMap results() const { return mResults; }
132+
124133
/**
125134
* Creates a new processing feedback object, automatically connected to the appropriate
126135
* slots in this dialog.
@@ -203,9 +212,18 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
203212

204213
/**
205214
* Sets whether the algorithm was executed through the dialog.
215+
* \see wasExecuted()
216+
* \see setResults()
206217
*/
207218
void setExecuted( bool executed );
208219

220+
/**
221+
* Sets the algorithm results.
222+
* \see results()
223+
* \see setExecuted()
224+
*/
225+
void setResults( const QVariantMap &results );
226+
209227
/**
210228
* Displays an info \a message in the dialog's log.
211229
*/
@@ -250,6 +268,7 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
250268
QgsMessageBar *mMessageBar = nullptr;
251269

252270
bool mExecuted = false;
271+
QVariantMap mResults;
253272
QWidget *mMainWidget = nullptr;
254273
QgsProcessingAlgorithm *mAlgorithm = nullptr;
255274
bool mHelpCollapsed = false;

0 commit comments

Comments
 (0)