search box

This commit is contained in:
ThomasV 2015-04-23 13:50:35 +02:00
parent 6fb9f2e241
commit 45081b1c8b
2 changed files with 30 additions and 0 deletions

View File

@ -382,6 +382,7 @@ class ElectrumWindow(QMainWindow):
self.import_menu = self.private_keys_menu.addAction(_("&Import"), self.do_import_privkey)
self.export_menu = self.private_keys_menu.addAction(_("&Export"), self.export_privkeys_dialog)
wallet_menu.addAction(_("&Export History"), self.export_history_dialog)
wallet_menu.addAction(_("Search"), self.toggle_search).setShortcut(QKeySequence("Ctrl+S"))
tools_menu = menubar.addMenu(_("&Tools"))
@ -1655,6 +1656,11 @@ class ElectrumWindow(QMainWindow):
self.connect(self.account_selector,SIGNAL("activated(QString)"),self.change_account)
sb.addPermanentWidget(self.account_selector)
self.search_box = QLineEdit()
self.search_box.textChanged.connect(self.do_search)
self.search_box.hide()
sb.addPermanentWidget(self.search_box)
if (int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7):
sb.addPermanentWidget( StatusBarButton( QIcon(":icons/switchgui.png"), _("Switch to Lite Mode"), self.go_lite ) )
@ -1691,6 +1697,23 @@ class ElectrumWindow(QMainWindow):
self.update_lock_icon()
def toggle_search(self):
self.search_box.setHidden(not self.search_box.isHidden())
if not self.search_box.isHidden():
self.search_box.setFocus(1)
else:
self.do_search('')
def do_search(self, t):
i = self.tabs.currentIndex()
if i == 0:
self.history_list.filter(t, 2)
elif i == 3:
self.address_list.filter(t, 1)
elif i == 4:
self.contacts_list.filter(t, 0)
def new_contact_dialog(self):
d = QDialog(self)
d.setWindowTitle(_("New Contact"))

View File

@ -330,6 +330,13 @@ class MyTreeWidget(QTreeWidget):
self.parent.update_history_tab()
self.parent.update_completions()
def filter(self, p, column):
root = self.invisibleRootItem()
child_count = root.childCount()
for i in range(child_count):
item = root.child(i)
item.setHidden(unicode(item.text(column)).lower().find(p) == -1)
class ButtonsWidget(QWidget):