Skip to content
Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into nn_fix_http_error…

…_response
  • Loading branch information
nilsnolde committed Mar 29, 2021
2 parents 89a09b1 + a18613c commit e28c2120f0e07d22e5786bdddb01fc2796e13f66
Showing with 42 additions and 10 deletions.
  1. +33 −5 python/plugins/processing/gui/HistoryDialog.py
  2. +9 −5 python/plugins/processing/ui/DlgHistory.ui
@@ -23,13 +23,16 @@

import os
import warnings
import re

from qgis.core import QgsApplication
from qgis.gui import QgsGui, QgsHelp
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt, QCoreApplication
from qgis.PyQt.QtWidgets import QAction, QPushButton, QDialogButtonBox, QStyle, QMessageBox, QFileDialog, QMenu, QTreeWidgetItem
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.Qsci import QsciScintilla

from processing.gui import TestTools
from processing.core.ProcessingLog import ProcessingLog, LOG_SEPARATOR

@@ -49,6 +52,13 @@ def __init__(self):

QgsGui.instance().enableAutoGeometryRestore(self)

self.text.setReadOnly(True)
self.text.setCaretLineVisible(False)
self.text.setLineNumbersVisible(False) # NO linenumbers for the input line
self.text.setFoldingVisible(False)
self.text.setEdgeMode(QsciScintilla.EdgeNone)
self.text.setWrapMode(QsciScintilla.SC_WRAP_WORD)

self.groupIcon = QgsApplication.getThemeIcon('mIconFolder.svg')

self.keyIcon = self.style().standardIcon(QStyle.SP_FileIcon)
@@ -105,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)
@@ -131,7 +158,8 @@ def executeAlgorithm(self):
def changeText(self):
item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem):
self.text.setText(item.entry.text.replace(LOG_SEPARATOR, '\n'))
self.text.setText('"""\n' + self.tr('Double-click on the history item or paste the command below to re-run the algorithm') + '\n"""\n\n' +
item.entry.text.replace('processing.run(', 'processing.execAlgorithmDialog(').replace(LOG_SEPARATOR, '\n'))

def createTest(self):
item = self.tree.currentItem()
@@ -152,8 +180,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])
@@ -35,11 +35,7 @@
</property>
</column>
</widget>
<widget class="QTextEdit" name="text">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QgsCodeEditorPython" name="text" native="true"/>
</widget>
</item>
<item>
@@ -54,6 +50,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsCodeEditorPython</class>
<extends>QWidget</extends>
<header>qgscodeeditorpython.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

0 comments on commit e28c212

Please sign in to comment.