From ea92cdc346112be0be2a4416aee04521edf7f732 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 9 Jul 2010 22:19:20 -0500 Subject: [PATCH] Adding row deletion --- src/qhistory.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qhistory.py b/src/qhistory.py index 62d53e7..e39fb71 100644 --- a/src/qhistory.py +++ b/src/qhistory.py @@ -40,6 +40,7 @@ class QCalcHistory(history.AbstractHistory): self._historyView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self._historyView.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self._historyView.setHeaderHidden(True) + self._historyView.activated.connect(self._on_delete_row) viewHeader = self._historyView.header() viewHeader.setSortIndicatorShown(True) @@ -66,10 +67,13 @@ class QCalcHistory(history.AbstractHistory): icon = QtGui.QStandardItem(QtGui.QIcon.fromTheme("gtk-close"), "") icon.setEditable(False) + icon.setCheckable(False) equation = QtGui.QStandardItem(operation.render_operation(self._prettyRenderer, node)) equation.setData(node) + equation.setCheckable(False) result = QtGui.QStandardItem(operation.render_operation(self._prettyRenderer, simpleNode)) result.setData(simpleNode) + result.setCheckable(False) row = (icon, equation, result) self._historyStore.appendRow(row) @@ -101,6 +105,13 @@ class QCalcHistory(history.AbstractHistory): self._rowCount = 0 @misc_utils.log_exception(_moduleLogger) + def _on_delete_row(self, index): + if index.column() == self._CLOSE_COLUMN: + self._historyStore.removeRow(index.row(), index.parent()) + else: + raise NotImplementedError("Unsupported column to activate %s" % index.column()) + + @misc_utils.log_exception(_moduleLogger) def _on_item_changed(self, item): if self._programmaticUpdate: _moduleLogger.info("Blocking updating %r recursively" % item) -- 1.7.9.5