Skip to content
Permalink
Browse files

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

…38b8cb
  • Loading branch information
slarosa committed Nov 2, 2013
1 parent 169f646 commit a411e79fa738107966a7d7292677569d63733e58
Showing with 33 additions and 15 deletions.
  1. +22 −9 python/console/console_history_dlg.ui
  2. +11 −6 python/console/console_sci.py
@@ -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>
@@ -633,11 +633,15 @@ def __init__(self, parent):
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 @@ def _reloadHistory(self):

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)

0 comments on commit a411e79

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