Skip to content

Commit

Permalink
[processing] add "Save as" functionality to History dialog (fix #10086)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Sep 24, 2014
1 parent e3f630a commit 986bd1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/plugins/processing/core/ProcessingLog.py
Expand Up @@ -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:

Expand Down
17 changes: 17 additions & 0 deletions python/plugins/processing/gui/HistoryDialog.py
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 986bd1c

Please sign in to comment.