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.
This commit is contained in:
+6
-4
@@ -328,10 +328,12 @@ 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"):
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user