Skip to content
Permalink
Browse files

[processing] add "Save as" functionality to History dialog (fix #10086)

  • Loading branch information
alexbruy committed Sep 24, 2014
1 parent e3f630a commit 986bd1c41ab7a2ec69f09fc0c7641eb27dae4deb
Showing with 25 additions and 0 deletions.
  1. +8 −0 python/plugins/processing/core/ProcessingLog.py
  2. +17 −0 python/plugins/processing/gui/HistoryDialog.py
@@ -134,6 +134,14 @@ def clearLog():
os.unlink(ProcessingLog.logFilename())
ProcessingLog.startLogging()

@staticmethod
def saveLog(fileName):
entries = ProcessingLog.getLogEntries()
with codecs.open(fileName, 'w', encoding='utf-8') as f:
for k, v in entries.iteritems():
for entry in v:
f.write('%s|%s|%s\n' % (k, entry.date, entry.text))


class LogEntry:

@@ -51,9 +51,14 @@ def __init__(self):
self.clearButton.setToolTip(self.tr('Clear history and log'))
self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole)

self.saveButton = QPushButton(self.tr('Save As...'))
self.saveButton.setToolTip(self.tr('Save history and log'))
self.buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole)

self.tree.doubleClicked.connect(self.executeAlgorithm)
self.tree.currentItemChanged.connect(self.changeText)
self.clearButton.clicked.connect(self.clearLog)
self.saveButton.clicked.connect(self.saveLog)

self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
self.tree.customContextMenuRequested.connect(self.showPopupMenu)
@@ -70,6 +75,18 @@ def clearLog(self):
ProcessingLog.clearLog()
self.fillTree()

def saveLog(self):
fileName = QFileDialog.getSaveFileName(self,
self.tr('Save file'), '.', 'Log files (*.log *.LOG)')

if fileName == '':
return

if not fileName.lower().endswith('.log'):
fileName += '.log'

ProcessingLog.saveLog(fileName)

def fillTree(self):
self.tree.clear()
elements = ProcessingLog.getLogEntries()

0 comments on commit 986bd1c

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