mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
Setup framework for receiving model child results after running through model designer
This commit is contained in:
parent
4a8511042b
commit
cb990c69c2
@ -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
|
||||
|
||||
};
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
@ -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():
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -437,6 +437,11 @@ bool QgsModelDesignerDialog::checkForUnsavedChanges()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsModelDesignerDialog::setLastRunChildAlgorithmResults( const QVariantMap &results )
|
||||
{
|
||||
mChildResults = results;
|
||||
}
|
||||
|
||||
void QgsModelDesignerDialog::zoomIn()
|
||||
{
|
||||
mView->setTransformationAnchor( QGraphicsView::NoAnchor );
|
||||
|
@ -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();
|
||||
|
@ -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:
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user