Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into nn_fix_http_error…
Browse files Browse the repository at this point in the history
…_response
  • Loading branch information
nilsnolde committed Mar 29, 2021
2 parents 89a09b1 + a18613c commit e28c212
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
38 changes: 33 additions & 5 deletions python/plugins/processing/gui/HistoryDialog.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@


import os import os
import warnings import warnings
import re


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

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


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


QgsGui.instance().enableAutoGeometryRestore(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.groupIcon = QgsApplication.getThemeIcon('mIconFolder.svg')


self.keyIcon = self.style().standardIcon(QStyle.SP_FileIcon) self.keyIcon = self.style().standardIcon(QStyle.SP_FileIcon)
Expand Down Expand Up @@ -105,12 +115,29 @@ def openHelp(self):
def fillTree(self): def fillTree(self):
self.tree.clear() self.tree.clear()
entries = ProcessingLog.getLogEntries() entries = ProcessingLog.getLogEntries()
names = {}
icons = {}
groupItem = QTreeWidgetItem() groupItem = QTreeWidgetItem()
groupItem.setText(0, 'ALGORITHM') groupItem.setText(0, 'ALGORITHM')
groupItem.setIcon(0, self.groupIcon) groupItem.setIcon(0, self.groupIcon)
for entry in entries: for entry in entries:
item = TreeLogEntryItem(entry, True) icon = self.keyIcon
item.setIcon(0, 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) groupItem.insertChild(0, item)
self.tree.addTopLevelItem(groupItem) self.tree.addTopLevelItem(groupItem)
groupItem.setExpanded(True) groupItem.setExpanded(True)
Expand All @@ -131,7 +158,8 @@ def executeAlgorithm(self):
def changeText(self): def changeText(self):
item = self.tree.currentItem() item = self.tree.currentItem()
if isinstance(item, TreeLogEntryItem): 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): def createTest(self):
item = self.tree.currentItem() item = self.tree.currentItem()
Expand All @@ -152,8 +180,8 @@ def showPopupMenu(self, point):


class TreeLogEntryItem(QTreeWidgetItem): class TreeLogEntryItem(QTreeWidgetItem):


def __init__(self, entry, isAlg): def __init__(self, entry, isAlg, algName):
QTreeWidgetItem.__init__(self) QTreeWidgetItem.__init__(self)
self.entry = entry self.entry = entry
self.isAlg = isAlg 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])
14 changes: 9 additions & 5 deletions python/plugins/processing/ui/DlgHistory.ui
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
</property> </property>
</column> </column>
</widget> </widget>
<widget class="QTextEdit" name="text"> <widget class="QgsCodeEditorPython" name="text" native="true"/>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget> </widget>
</item> </item>
<item> <item>
Expand All @@ -54,6 +50,14 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QgsCodeEditorPython</class>
<extends>QWidget</extends>
<header>qgscodeeditorpython.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
Expand Down

0 comments on commit e28c212

Please sign in to comment.