[pyqgis-console] add save button to history dialog, minor fixes for c38b8cb

This commit is contained in:
Salvatore Larosa 2013-11-02 18:01:22 +01:00
parent 169f646f7c
commit a411e79fa7
2 changed files with 33 additions and 15 deletions

View File

@ -29,7 +29,7 @@
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="2" column="1">
<item row="2" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -39,14 +39,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="reloadHistory">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="3">
<widget class="QListView" name="listView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -60,6 +53,26 @@
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="reloadHistory">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="saveHistory">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>

View File

@ -633,11 +633,15 @@ class HistoryDialog(QDialog, Ui_HistoryDialogPythonConsole):
self.deleteScut.activated.connect(self._deleteItem)
self.listView.doubleClicked.connect(self._runHistory)
self.reloadHistory.clicked.connect(self._reloadHistory)
self.saveHistory.clicked.connect(self._saveHistory)
def _runHistory(self, item):
cmd = item.data(Qt.DisplayRole)
self.parent.runCommand(unicode(cmd))
def _saveHistory(self):
self.parent.writeHistoryFile(True)
def _reloadHistory(self):
self.model.clear()
for i in self.parent.history:
@ -651,9 +655,10 @@ class HistoryDialog(QDialog, Ui_HistoryDialogPythonConsole):
def _deleteItem(self):
itemsSelected = self.listView.selectionModel().selectedIndexes()
item = itemsSelected[0].row()
## Remove item from the command history (just for the current session)
self.parent.history.pop(item)
self.parent.historyIndex -= 1
## Remove row from the command history dialog
self.model.removeRow(item)
if itemsSelected:
item = itemsSelected[0].row()
## Remove item from the command history (just for the current session)
self.parent.history.pop(item)
self.parent.historyIndex -= 1
## Remove row from the command history dialog
self.model.removeRow(item)