From 00200334fb96a3c5bc1e3619def50596881e794c Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sat, 1 Jul 2023 18:57:33 -0700 Subject: [PATCH] Add filter to SeriesSelectionWindow and IssueSelectionWindow fixes #476 --- comictaggerlib/issueselectionwindow.py | 11 +++++++++++ comictaggerlib/seriesselectionwindow.py | 11 +++++++++++ comictaggerlib/ui/issueselectionwindow.ui | 9 ++++++++- comictaggerlib/ui/seriesselectionwindow.ui | 7 +++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/comictaggerlib/issueselectionwindow.py b/comictaggerlib/issueselectionwindow.py index 58101b2..4e673e7 100644 --- a/comictaggerlib/issueselectionwindow.py +++ b/comictaggerlib/issueselectionwindow.py @@ -115,6 +115,17 @@ class IssueSelectionWindow(QtWidgets.QDialog): self.twList.selectRow(r) break + self.leFilter.textChanged.connect(self.filter) + + def filter(self, text: str) -> None: + rows = set(range(self.twList.rowCount())) + for r in rows: + self.twList.showRow(r) + if text.strip(): + shown_rows = {x.row() for x in self.twList.findItems(text, QtCore.Qt.MatchFlag.MatchContains)} + for r in rows - shown_rows: + self.twList.hideRow(r) + def perform_query(self) -> None: QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor)) diff --git a/comictaggerlib/seriesselectionwindow.py b/comictaggerlib/seriesselectionwindow.py index 7d90d44..fee4e5d 100644 --- a/comictaggerlib/seriesselectionwindow.py +++ b/comictaggerlib/seriesselectionwindow.py @@ -187,6 +187,17 @@ class SeriesSelectionWindow(QtWidgets.QDialog): self.update_buttons() self.twList.selectRow(0) + self.leFilter.textChanged.connect(self.filter) + + def filter(self, text: str) -> None: + rows = set(range(self.twList.rowCount())) + for r in rows: + self.twList.showRow(r) + if text.strip(): + shown_rows = {x.row() for x in self.twList.findItems(text, QtCore.Qt.MatchFlag.MatchContains)} + for r in rows - shown_rows: + self.twList.hideRow(r) + def update_buttons(self) -> None: enabled = bool(self.ct_search_results) diff --git a/comictaggerlib/ui/issueselectionwindow.ui b/comictaggerlib/ui/issueselectionwindow.ui index 4d23de9..8d0d6b7 100644 --- a/comictaggerlib/ui/issueselectionwindow.ui +++ b/comictaggerlib/ui/issueselectionwindow.ui @@ -7,7 +7,7 @@ 0 0 872 - 670 + 673 @@ -16,6 +16,13 @@ + + + + Filter + + + diff --git a/comictaggerlib/ui/seriesselectionwindow.ui b/comictaggerlib/ui/seriesselectionwindow.ui index ceafc65..a73454a 100644 --- a/comictaggerlib/ui/seriesselectionwindow.ui +++ b/comictaggerlib/ui/seriesselectionwindow.ui @@ -110,6 +110,13 @@ + + + + Filter + + +