Skip to content

Commit 655bd11

Browse files
author
cpolymeris@gmail.com
committed
History algorithm execution progress & cancel button.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@277 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 0d475df commit 655bd11

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/sextante/core/Sextante.py

+16
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,32 @@ def runandload(name, *args):
358358
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
359359
if SextanteConfig.getSetting(SextanteConfig.USE_THREADS):
360360
algEx = AlgorithmExecutor(alg)
361+
progress = QProgressDialog()
362+
progress.setWindowTitle(alg.name)
363+
progress.setLabelText("Executing %s..." % alg.name)
361364
def finish():
362365
SextantePostprocessing.handleAlgorithmResults(alg)
363366
QApplication.restoreOverrideCursor()
367+
progress.close()
364368
def error(msg):
365369
QApplication.restoreOverrideCursor()
366370
QMessageBox.critical(None, "Error", msg)
367371
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
372+
def cancel():
373+
try:
374+
algEx.finished.disconnect()
375+
algEx.terminate()
376+
QApplication.restoreOverrideCursor()
377+
progress.close()
378+
except:
379+
pass
368380
algEx.error.connect(error)
369381
algEx.finished.connect(finish)
382+
algEx.textChanged.connect(lambda t: progress.setLabelText(t))
383+
algEx.percentageChanged.connect(lambda x: progress.setValue(x))
384+
progress.canceled.connect(cancel)
370385
algEx.start()
386+
progress.show()
371387
else:
372388
if UnthreadedAlgorithmExecutor.runalg(alg, SilentProgress()):
373389
SextantePostprocessing.handleAlgorithmResults(alg)

0 commit comments

Comments
 (0)