Skip to content

Commit

Permalink
qt coins tab: Ctrl+F now searches the whole prevout string
Browse files Browse the repository at this point in the history
(not just the truncated string that is displayed in the list)
  • Loading branch information
SomberNight committed Apr 22, 2021
1 parent 3b77340 commit 1436760
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions electrum/gui/qt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ class MyTreeView(QTreeView):
ROLE_CLIPBOARD_DATA = Qt.UserRole + 100
ROLE_CUSTOM_PAINT = Qt.UserRole + 101
ROLE_EDIT_KEY = Qt.UserRole + 102
ROLE_FILTER_DATA = Qt.UserRole + 103

filter_columns: Iterable[int]

Expand Down Expand Up @@ -679,6 +680,14 @@ def get_edit_key_from_coordinate(self, row, col) -> Any:
# overriding this might allow avoiding storing duplicate data
return self.get_role_data_from_coordinate(row, col, role=self.ROLE_EDIT_KEY)

def get_filter_data_from_coordinate(self, row, col) -> str:
filter_data = self.get_role_data_from_coordinate(row, col, role=self.ROLE_FILTER_DATA)
if filter_data:
return filter_data
txt = self.get_text_from_coordinate(row, col)
txt = txt.lower()
return txt

def hide_row(self, row_num):
"""
row_num is for self.model(). So if there is a proxy, it is the row number
Expand All @@ -690,9 +699,8 @@ def hide_row(self, row_num):
self.setRowHidden(row_num, QModelIndex(), False)
return
for column in self.filter_columns:
txt = self.get_text_from_coordinate(row_num, column)
txt = txt.lower()
if self.current_filter in txt:
filter_data = self.get_filter_data_from_coordinate(row_num, column)
if self.current_filter in filter_data:
# the filter matched, but the date filter might apply
self.setRowHidden(row_num, QModelIndex(), bool(should_hide))
break
Expand Down
5 changes: 5 additions & 0 deletions electrum/gui/qt/utxo_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,8 @@ def create_menu(self, position):
menu.addAction(_("Unfreeze Addresses"), lambda: self.parent.set_frozen_state_of_addresses(addrs, False))

menu.exec_(self.viewport().mapToGlobal(position))

def get_filter_data_from_coordinate(self, row, col):
if col == self.Columns.OUTPOINT:
return self.get_role_data_from_coordinate(row, col, role=self.ROLE_PREVOUT_STR)
return super().get_filter_data_from_coordinate(row, col)

0 comments on commit 1436760

Please sign in to comment.