commit 477bd49577154079f6711713e86b49e6d39a134b
parent 00d0905d4024b2d14b8bad4df4230c9afcda4ef6
Author: ThomasV <thomasv@gitorious>
Date: Sat, 9 Jun 2012 17:49:44 +0200
menus for history items
Diffstat:
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/lib/gui_qt.py b/lib/gui_qt.py
@@ -241,19 +241,28 @@ class ElectrumWindow(QMainWindow):
def create_history_tab(self):
- self.history_list = w = QTreeWidget(self)
- #print w.getContentsMargins()
- w.setColumnCount(5)
- w.setColumnWidth(0, 40)
- w.setColumnWidth(1, 140)
- w.setColumnWidth(2, 350)
- w.setColumnWidth(3, 140)
- w.setColumnWidth(4, 140)
- w.setHeaderLabels( [ '', _( 'Date' ), _( 'Description' ) , _('Amount'), _('Balance')] )
- self.connect(w, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.tx_details)
- self.connect(w, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.tx_label_clicked)
- self.connect(w, SIGNAL('itemChanged(QTreeWidgetItem*, int)'), self.tx_label_changed)
- return w
+ self.history_list = l = QTreeWidget(self)
+ l.setColumnCount(5)
+ l.setColumnWidth(0, 40)
+ l.setColumnWidth(1, 140)
+ l.setColumnWidth(2, 350)
+ l.setColumnWidth(3, 140)
+ l.setColumnWidth(4, 140)
+ l.setHeaderLabels( [ '', _( 'Date' ), _( 'Description' ) , _('Amount'), _('Balance')] )
+ self.connect(l, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.tx_details)
+ self.connect(l, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.tx_label_clicked)
+ self.connect(l, SIGNAL('itemChanged(QTreeWidgetItem*, int)'), self.tx_label_changed)
+ l.setContextMenuPolicy(Qt.CustomContextMenu)
+ l.customContextMenuRequested.connect(self.create_history_menu)
+ return l
+
+ def create_history_menu(self, position):
+ self.history_list.selectedIndexes()
+ item = self.history_list.currentItem()
+ menu = QMenu()
+ menu.addAction(_("Details"), lambda: self.tx_details(item,2))
+ menu.addAction(_("Edit description"), lambda: self.tx_label_clicked(item,2))
+ menu.exec_(self.contacts_list.viewport().mapToGlobal(position))
def tx_details(self, item, column):
tx_hash = str(item.toolTip(0))