mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[processing] Use a proxy task for batch processing execution
This commit is contained in:
parent
5030121e8a
commit
db1600871a
@ -40,7 +40,8 @@ from qgis.core import (QgsProcessingParameterDefinition,
|
|||||||
QgsProcessingOutputNumber,
|
QgsProcessingOutputNumber,
|
||||||
QgsProcessingOutputString,
|
QgsProcessingOutputString,
|
||||||
QgsProject,
|
QgsProject,
|
||||||
Qgis)
|
Qgis,
|
||||||
|
QgsScopedProxyProgressTask)
|
||||||
|
|
||||||
from qgis.gui import QgsProcessingAlgorithmDialogBase
|
from qgis.gui import QgsProcessingAlgorithmDialogBase
|
||||||
from qgis.utils import OverrideCursor
|
from qgis.utils import OverrideCursor
|
||||||
@ -115,6 +116,8 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
|||||||
|
|
||||||
alg_parameters.append(parameters)
|
alg_parameters.append(parameters)
|
||||||
|
|
||||||
|
task = QgsScopedProxyProgressTask(self.tr('Batch Processing - {0}').format(self.algorithm().displayName()))
|
||||||
|
|
||||||
with OverrideCursor(Qt.WaitCursor):
|
with OverrideCursor(Qt.WaitCursor):
|
||||||
|
|
||||||
self.mainWidget().setEnabled(False)
|
self.mainWidget().setEnabled(False)
|
||||||
@ -135,6 +138,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
|||||||
break
|
break
|
||||||
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters)))
|
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)
|
self.setInfo(self.tr('<b>Algorithm {0} starting…</b>').format(self.algorithm().displayName()), escapeHtml=False)
|
||||||
|
task.setProgress(100 * count / len(alg_parameters))
|
||||||
|
|
||||||
parameters = self.algorithm().preprocessParameters(parameters)
|
parameters = self.algorithm().preprocessParameters(parameters)
|
||||||
|
|
||||||
@ -165,6 +169,7 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
|||||||
handleAlgorithmResults(self.algorithm(), context, feedback, False)
|
handleAlgorithmResults(self.algorithm(), context, feedback, False)
|
||||||
|
|
||||||
feedback.pushInfo(self.tr('Batch execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
feedback.pushInfo(self.tr('Batch execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
||||||
|
task = None
|
||||||
|
|
||||||
self.finish(algorithm_results)
|
self.finish(algorithm_results)
|
||||||
self.cancelButton().setEnabled(False)
|
self.cancelButton().setEnabled(False)
|
||||||
@ -175,8 +180,6 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
|||||||
|
|
||||||
self.createSummaryTable(algorithm_results)
|
self.createSummaryTable(algorithm_results)
|
||||||
self.mainWidget().setEnabled(True)
|
self.mainWidget().setEnabled(True)
|
||||||
QMessageBox.information(self, self.tr('Batch processing'),
|
|
||||||
self.tr('Batch processing completed'))
|
|
||||||
|
|
||||||
def loadHTMLResults(self, results, num):
|
def loadHTMLResults(self, results, num):
|
||||||
for out in self.algorithm().outputDefinitions():
|
for out in self.algorithm().outputDefinitions():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user