From 8fc6298d2878c2e447e8dbfb15b50cb5a250fdd4 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Wed, 15 May 2024 09:02:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Filter=20are=20AND=20and=20not=20OR?= =?UTF-8?q?=20linked.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/helper/gui.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tidal_dl_ng/helper/gui.py b/tidal_dl_ng/helper/gui.py index 82a44d8..0506491 100644 --- a/tidal_dl_ng/helper/gui.py +++ b/tidal_dl_ng/helper/gui.py @@ -177,6 +177,7 @@ class HumanProxyModel(QtCore.QSortFilterProxyModel): def filterAcceptsRow(self, source_row: int, source_parent: QtCore.QModelIndex) -> bool: model = self.sourceModel() source_index = model.index(source_row, 0, source_parent) + result: [bool] = [] # Show top level children for child_row in range(model.rowCount(source_index)): @@ -189,6 +190,11 @@ class HumanProxyModel(QtCore.QSortFilterProxyModel): ix = self.sourceModel().index(source_row, i, source_parent) data = ix.data() - return bool(text.lower() in str(data).lower()) + # Append results to list to enable an AND operator for filtering. + result.append(bool(text.lower() in str(data).lower())) - return True + # If no filter set, just set the result to True. + if not result: + result.append(True) + + return all(result)