Navigation Menu

Skip to content

Commit

Permalink
[processing] Use algorithm icon and friendly display names in the his…
Browse files Browse the repository at this point in the history
…tory dialog
  • Loading branch information
nirvn committed Mar 29, 2021
1 parent fb2240e commit 7b66ba8
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions python/plugins/processing/gui/HistoryDialog.py
Expand Up @@ -23,6 +23,7 @@

import os
import warnings
import re

from qgis.core import QgsApplication
from qgis.gui import QgsGui, QgsHelp
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.