electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 7d990987099d410a9af31021d1b90288383cd7ca
parent 54ce9f722eba1dd5a640cabf1d0114f2d48730a5
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 16 Feb 2017 18:40:22 +0100

Merge pull request #2167 from bauerj/filter-2165

Keep filter after updating the list
Diffstat:
Mgui/qt/address_list.py | 1+
Mgui/qt/contact_list.py | 1+
Mgui/qt/history_list.py | 1+
Mgui/qt/invoice_list.py | 1+
Mgui/qt/main_window.py | 10+++++-----
Mgui/qt/request_list.py | 2++
Mgui/qt/util.py | 7++++++-
7 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gui/qt/address_list.py b/gui/qt/address_list.py @@ -34,6 +34,7 @@ from electrum.bitcoin import is_address class AddressList(MyTreeWidget): + filter_columns = [0, 1, 2] # Address, Label, Balance def __init__(self, parent=None): MyTreeWidget.__init__(self, parent, self.create_menu, [ _('Address'), _('Label'), _('Balance'), _('Tx')], 1) diff --git a/gui/qt/contact_list.py b/gui/qt/contact_list.py @@ -35,6 +35,7 @@ from util import MyTreeWidget, pr_tooltips, pr_icons class ContactList(MyTreeWidget): + filter_columns = [0, 1] # Key, Value def __init__(self, parent): MyTreeWidget.__init__(self, parent, self.create_menu, [_('Name'), _('Address')], 0, [0]) diff --git a/gui/qt/history_list.py b/gui/qt/history_list.py @@ -49,6 +49,7 @@ TX_ICONS = [ class HistoryList(MyTreeWidget): + filter_columns = [2, 3, 4] # Date, Description, Amount def __init__(self, parent=None): MyTreeWidget.__init__(self, parent, self.create_menu, [], 3) diff --git a/gui/qt/invoice_list.py b/gui/qt/invoice_list.py @@ -31,6 +31,7 @@ from electrum.plugins import run_hook class InvoiceList(MyTreeWidget): + filter_columns = [0, 1, 2, 3] # Date, Requestor, Description, Amount def __init__(self, parent): MyTreeWidget.__init__(self, parent, self.create_menu, [_('Expires'), _('Requestor'), _('Description'), _('Amount'), _('Status')], 2) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1711,15 +1711,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): def do_search(self, t): i = self.tabs.currentIndex() if i == 0: - self.history_list.filter(t, [2, 3, 4]) # Date, Description, Amount + self.history_list.filter(t) elif i == 1: - self.invoice_list.filter(t, [0, 1, 2, 3]) # Date, Requestor, Description, Amount + self.invoice_list.filter(t) elif i == 2: - self.request_list.filter(t, [0, 1, 2, 3, 4]) # Date, Account, Address, Description, Amount + self.request_list.filter(t) elif i == 3: - self.address_list.filter(t, [0,1, 2]) # Address, Label, Balance + self.address_list.filter(t) elif i == 4: - self.contact_list.filter(t, [0, 1]) # Key, Value + self.contact_list.filter(t) def new_contact_dialog(self): diff --git a/gui/qt/request_list.py b/gui/qt/request_list.py @@ -34,6 +34,8 @@ from util import MyTreeWidget, pr_tooltips, pr_icons class RequestList(MyTreeWidget): + filter_columns = [0, 1, 2, 3, 4] # Date, Account, Address, Description, Amount + def __init__(self, parent): MyTreeWidget.__init__(self, parent, self.create_menu, [_('Date'), _('Address'), '', _('Description'), _('Amount'), _('Status')], 3) diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -391,6 +391,7 @@ class MyTreeWidget(QTreeWidget): self.setItemDelegate(ElectrumItemDelegate(self)) self.itemDoubleClicked.connect(self.on_doubleclick) self.update_headers(headers) + self.current_filter = "" def update_headers(self, headers): self.setColumnCount(len(headers)) @@ -477,6 +478,8 @@ class MyTreeWidget(QTreeWidget): self.setUpdatesEnabled(False) self.on_update() self.setUpdatesEnabled(True) + if self.current_filter: + self.filter(self.current_filter) def on_update(self): pass @@ -490,8 +493,10 @@ class MyTreeWidget(QTreeWidget): for x in self.get_leaves(item): yield x - def filter(self, p, columns): + def filter(self, p): + columns = self.__class__.filter_columns p = unicode(p).lower() + self.current_filter = p for item in self.get_leaves(self.invisibleRootItem()): item.setHidden(all([unicode(item.text(column)).lower().find(p) == -1 for column in columns]))