Skip to content
Permalink
Browse files

[processing] Use algorithm icon and friendly display names in the his…

…tory dialog
  • Loading branch information
nirvn committed Mar 29, 2021
1 parent fb2240e commit 7b66ba829152d22ac3c03afa82c7fbd1323939c4
Showing with 22 additions and 4 deletions.
  1. +22 −4 python/plugins/processing/gui/HistoryDialog.py
@@ -23,6 +23,7 @@

import os
import warnings
import re

from qgis.core import QgsApplication
from qgis.gui import QgsGui, QgsHelp
@@ -114,12 +115,29 @@ def openHelp(self):
def fillTree(self):
self.tree.clear()
entries = ProcessingLog.getLogEntries()
names = {}
icons = {}
groupItem = QTreeWidgetItem()
groupItem.setText(0, 'ALGORITHM')
groupItem.setIcon(0, self.groupIcon)
for entry in entries:
item = TreeLogEntryItem(entry, True)
item.setIcon(0, self.keyIcon)
icon = self.keyIcon
name = ''
match = re.search('processing.run\\("(.*?)"', entry.text)
if match.group:
algorithm_id = match.group(1)
if algorithm_id not in names:
algorithm = QgsApplication.processingRegistry().algorithmById(algorithm_id)
if algorithm:
names[algorithm_id] = algorithm.displayName()
icons[algorithm_id] = QgsApplication.processingRegistry().algorithmById(algorithm_id).icon()
else:
names[algorithm_id] = ''
icons[algorithm_id] = self.keyIcon
name = names[algorithm_id]
icon = icons[algorithm_id]
item = TreeLogEntryItem(entry, True, name)
item.setIcon(0, icon)
groupItem.insertChild(0, item)
self.tree.addTopLevelItem(groupItem)
groupItem.setExpanded(True)
@@ -161,8 +179,8 @@ def showPopupMenu(self, point):

class TreeLogEntryItem(QTreeWidgetItem):

def __init__(self, entry, isAlg):
def __init__(self, entry, isAlg, algName):
QTreeWidgetItem.__init__(self)
self.entry = entry
self.isAlg = isAlg
self.setText(0, '[' + entry.date + '] ' + entry.text.split(LOG_SEPARATOR)[0])
self.setText(0, '[' + entry.date + '] ' + algName + ' - ' + entry.text.split(LOG_SEPARATOR)[0])

0 comments on commit 7b66ba8

Please sign in to comment.