Skip to content

Commit

Permalink
Log only for threaded algorithm execution
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@332 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Aug 3, 2012
1 parent f2c9b03 commit e46b466
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/sextante/gui/AlgorithmExecutionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
self.tabWidget.addTab(self.logText, "Log")
if SextanteConfig.getSetting(SextanteConfig.USE_THREADS):
self.tabWidget.addTab(self.logText, "Log")
self.webView = QtWebKit.QWebView()
cssUrl = QtCore.QUrl(os.path.join(os.path.dirname(__file__), "help", "help.css"))
self.webView.settings().setUserStyleSheetUrl(cssUrl)
Expand Down Expand Up @@ -199,10 +200,11 @@ def accept(self):
self.algEx.percentageChanged.connect(self.setPercentage)
self.algEx.textChanged.connect(self.setText)
self.algEx.iterated.connect(self.iterate)
self.algEx.infoSet.connect(self.log)
self.algEx.infoSet.connect(self.setInfo)
self.algEx.start()
self.log("Algorithm %s started" % self.alg.name)
self.setInfo("Algorithm %s started" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
self.tabWidget.setCurrentIndex(1) # log tab
self.finish()
else:
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
Expand Down Expand Up @@ -233,7 +235,7 @@ def accept(self):
@pyqtSlot()
def finish(self):
self.executed = True
self.log("Algorithm %s finished correctly" % self.alg.name)
self.setInfo("Algorithm %s finished correctly" % self.alg.name)
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
Expand All @@ -250,7 +252,7 @@ def finish(self):
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
self.log(msg, True)
self.setInfo(msg, True)
QMessageBox.critical(self, "Error", msg)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
Expand All @@ -262,11 +264,11 @@ def error(self, msg):

@pyqtSlot(int)
def iterate(self, i):
self.log("Algorithm %s iteration #%i completed" % (self.alg.name, i))
self.setInfo("Algorithm %s iteration #%i completed" % (self.alg.name, i))

@pyqtSlot()
def cancel(self):
self.log("Algorithm %s canceled" % self.alg.name)
self.setInfo("Algorithm %s canceled" % self.alg.name)
try:
self.algEx.finished.disconnect()
self.algEx.terminate()
Expand All @@ -276,7 +278,7 @@ def cancel(self):
pass

@pyqtSlot(str)
def log(self, msg, error = False):
def setInfo(self, msg, error = False):
if error:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
self.logText.append('<b>' + msg + '</b>')
Expand All @@ -291,4 +293,4 @@ def setPercentage(self, i):

def setText(self, text):
self.progressLabel.setText(text)
self.log(text, False)
self.setInfo(text, False)
5 changes: 4 additions & 1 deletion src/sextante/gui/UnthreadedAlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ def setText(self, text):
pass

def setPercentage(self, i):
pass
pass

def setInfo(self, _):
pass

0 comments on commit e46b466

Please sign in to comment.