Setup framework for receiving model child results after running through model designer

This commit is contained in:
Nyall Dawson 2020-03-31 15:04:20 +10:00
parent 4a8511042b
commit cb990c69c2
8 changed files with 41 additions and 0 deletions

View File

@ -95,6 +95,11 @@ Checks if the model can current be saved, and returns ``True`` if it can.
Checks if there are unsaved changes in the model, and if so, prompts the user to save them.
Returns ``False`` if the cancel option was selected
%End
void setLastRunChildAlgorithmResults( const QVariantMap &results );
%Docstring
Sets the results of child algorithms for the last run of the model through the designer window.
%End
};

View File

@ -299,6 +299,15 @@ by the dialog. Ownership of ``task`` is transferred to the dialog.
Formats an input ``string`` for display in the log tab.
.. versionadded:: 3.0.1
%End
signals:
void algorithmFinished( bool successful, const QVariantMap &result );
%Docstring
Emitted whenever an algorithm has finished executing in the dialog.
.. versionadded:: 3.14
%End
protected slots:

View File

@ -342,6 +342,7 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
self.setExecuted(True)
self.setResults(result)
self.setInfo(self.tr('Algorithm \'{0}\' finished').format(self.algorithm().displayName()), escapeHtml=False)
self.algorithmFinished.emit(successful, result)
if not in_place and not keepOpen:
self.close()

View File

@ -120,8 +120,12 @@ class ModelerDialog(QgsModelDesignerDialog):
duration=5)
return
def on_finished(successful, results):
self.setLastRunChildAlgorithmResults(dlg.results()['CHILD_RESULTS'])
dlg = AlgorithmDialog(self.model().create(), parent=self)
dlg.setParameters(self.model().designerParameterValues())
dlg.algorithmFinished.connect(on_finished)
dlg.exec_()
if dlg.wasExecuted():

View File

@ -402,6 +402,7 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
feedback->pushDebugInfo( QObject::tr( "Model processed OK. Executed %1 algorithms total in %2 s." ).arg( executed.count() ).arg( totalTime.elapsed() / 1000.0 ) );
mResults = finalResults;
mResults.insert( QStringLiteral( "CHILD_RESULTS" ), childResults );
return mResults;
}

View File

@ -437,6 +437,11 @@ bool QgsModelDesignerDialog::checkForUnsavedChanges()
}
}
void QgsModelDesignerDialog::setLastRunChildAlgorithmResults( const QVariantMap &results )
{
mChildResults = results;
}
void QgsModelDesignerDialog::zoomIn()
{
mView->setTransformationAnchor( QGraphicsView::NoAnchor );

View File

@ -120,6 +120,11 @@ class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsMode
*/
bool checkForUnsavedChanges();
/**
* Sets the results of child algorithms for the last run of the model through the designer window.
*/
void setLastRunChildAlgorithmResults( const QVariantMap &results );
private slots:
void zoomIn();
void zoomOut();
@ -164,6 +169,8 @@ class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsMode
int mBlockRepaints = 0;
QVariantMap mChildResults;
bool isDirty() const;
void fillInputsTree();

View File

@ -343,6 +343,15 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
*/
static QString formatStringForLog( const QString &string );
signals:
/**
* Emitted whenever an algorithm has finished executing in the dialog.
*
* \since QGIS 3.14
*/
void algorithmFinished( bool successful, const QVariantMap &result );
protected slots:
/**