mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] add "Save as" functionality to History dialog (fix #10086)
This commit is contained in:
parent
e3f630adb1
commit
986bd1c41a
@ -134,6 +134,14 @@ class ProcessingLog:
|
||||
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 @@ class HistoryDialog(QDialog, Ui_DlgHistory):
|
||||
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 @@ class HistoryDialog(QDialog, Ui_DlgHistory):
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user