summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2025-07-01 15:58:51 +0200
committerRobert Honz <exislow+github@gmail.com>2025-07-01 15:58:51 +0200
commit99b4347b9ac5b20fa5bb60f8391b0e9871c53d0b (patch)
tree7350279d8c806b59536e41c7c5fb10e776170abe
parent76f6010a12e8972119117041ee1f737463a92c2f (diff)
downloadtidal-dl-ng-99b4347b9ac5b20fa5bb60f8391b0e9871c53d0b.tar.gz
refactor(gui): ✨ Improve filter handling in `MainWindow`
* Refactored the filter extraction logic to directly use `header.filter_text(i)` for better clarity. * Updated the filters list to store tuples of index and text, enhancing the data structure used. * Ensured that the `proxy_model.filters` is set directly, simplifying the code.
-rw-r--r--tidal_dl_ng/gui.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index 6cf1f41..57613f5 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -328,11 +328,13 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
header = self.tr_results.header()
filters: list[str] = []
for i in range(header.count()):
- # Use getattr to avoid attribute error
- filters.append(getattr(header, "filter_text", lambda x: "")(i))
- proxy_model = self.tr_results.model()
- if hasattr(proxy_model, "filters"):
- proxy_model.filters = filters
+ text: str = header.filter_text(i)
+
+ if text:
+ filters.append((i, text))
+
+ proxy_model: HumanProxyModel = self.tr_results.model()
+ proxy_model.filters = filters
def _init_tree_results(self, tree: QtWidgets.QTreeView, model: QtGui.QStandardItemModel) -> None:
"""Initialize the results tree view and its model.