mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[processing] Use multi-step feedback for batch execution
Gives better indication of total progress vs showing just current algorithm progress
This commit is contained in:
parent
db1600871a
commit
45bc2a0798
@ -40,6 +40,7 @@ from qgis.core import (QgsProcessingParameterDefinition,
|
||||
QgsProcessingOutputNumber,
|
||||
QgsProcessingOutputString,
|
||||
QgsProject,
|
||||
QgsProcessingMultiStepFeedback,
|
||||
Qgis,
|
||||
QgsScopedProxyProgressTask)
|
||||
|
||||
@ -117,6 +118,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
alg_parameters.append(parameters)
|
||||
|
||||
task = QgsScopedProxyProgressTask(self.tr('Batch Processing - {0}').format(self.algorithm().displayName()))
|
||||
multi_feedback = QgsProcessingMultiStepFeedback(len(alg_parameters), feedback)
|
||||
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
|
||||
@ -139,6 +141,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters)))
|
||||
self.setInfo(self.tr('<b>Algorithm {0} starting…</b>').format(self.algorithm().displayName()), escapeHtml=False)
|
||||
task.setProgress(100 * count / len(alg_parameters))
|
||||
multi_feedback.setCurrentStep(count)
|
||||
|
||||
parameters = self.algorithm().preprocessParameters(parameters)
|
||||
|
||||
@ -153,10 +156,9 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
context = dataobjects.createContext(feedback)
|
||||
|
||||
alg_start_time = time.time()
|
||||
ret, results = execute(self.algorithm(), parameters, context, feedback)
|
||||
ret, results = execute(self.algorithm(), parameters, context, multi_feedback)
|
||||
if ret:
|
||||
self.setInfo(QCoreApplication.translate('BatchAlgorithmDialog', 'Algorithm {0} correctly executed…').format(self.algorithm().displayName()), escapeHtml=False)
|
||||
feedback.setProgress(100)
|
||||
feedback.pushInfo(
|
||||
self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - alg_start_time)))
|
||||
feedback.pushInfo(self.tr('Results:'))
|
||||
@ -166,7 +168,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
else:
|
||||
break
|
||||
|
||||
handleAlgorithmResults(self.algorithm(), context, feedback, False)
|
||||
handleAlgorithmResults(self.algorithm(), context, multi_feedback, False)
|
||||
|
||||
feedback.pushInfo(self.tr('Batch execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
||||
task = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user