Skip to content
Permalink
Browse files

[processing] harmonize order of result panel (latest first) and add t…

…imestamp
  • Loading branch information
nirvn committed Feb 12, 2018
1 parent f10758e commit e5d7733bfc8b1acab528d0124873a758e9cb0926
@@ -34,8 +34,8 @@ class ProcessingResults(QObject):

results = []

def addResult(self, icon, name, result):
self.results.append(Result(icon, name, result))
def addResult(self, icon, name, timestamp, result):
self.results.append(Result(icon, name, timestamp, result))
self.resultAdded.emit()

def getResults(self):
@@ -44,9 +44,10 @@ def getResults(self):

class Result:

def __init__(self, icon, name, filename):
def __init__(self, icon, name, timestamp, filename):
self.icon = icon
self.name = name
self.timestamp = timestamp
self.filename = filename


@@ -286,7 +286,7 @@ def finish(self, successful, result, context, feedback):
# add html results to results dock
for out in self.algorithm().outputDefinitions():
if isinstance(out, QgsProcessingOutputHtml) and out.name() in result and result[out.name()]:
resultsList.addResult(icon=self.algorithm().icon(), name=out.description(),
resultsList.addResult(icon=self.algorithm().icon(), name=out.description(), timestamp=time.localtime(),
result=result[out.name()])

if not handleAlgorithmResults(self.algorithm(), context, feedback, not keepOpen):
@@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
import time

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QUrl
@@ -56,12 +57,12 @@ def fillTree(self):
elements = resultsList.getResults()
for element in elements:
item = TreeResultItem(element)
self.treeResults.addTopLevelItem(item)
self.treeResults.insertTopLevelItem(0, item)
self.treeResults.blockSignals(False)

def updateDescription(self, current, previous):
if isinstance(current, TreeResultItem):
html = '<b>Algorithm</b>: {}<br><b>File path</b>: {}'.format(current.text(0), current.filename)
html = '<b>Algorithm</b>: {}<br><b>File path</b>: {}'.format(current.algorithm, current.filename)
self.txtDescription.setHtml(html)

def openResult(self, item, column):
@@ -73,5 +74,6 @@ class TreeResultItem(QTreeWidgetItem):
def __init__(self, result):
QTreeWidgetItem.__init__(self)
self.setIcon(0, result.icon)
self.setText(0, result.name)
self.setText(0, '{0} [{1}]'.format(result.name, time.strftime('%I:%M:%S%p', result.timestamp)))
self.algorithm = result.name
self.filename = result.filename

0 comments on commit e5d7733

Please sign in to comment.
You can’t perform that action at this time.