From e714182ce4662f1fa5ef8cb6173f31c36bef7732 Mon Sep 17 00:00:00 2001 From: Henrik Koski Date: Mon, 17 Jun 2024 14:55:32 +0300 Subject: [PATCH] Adapt to life after merge Re #2008 --- .../spine_db_editor/mvcmodels/compound_models.py | 10 +++++++++- .../mvcmodels/entity_tree_models.py | 7 ++++--- .../spine_db_editor/widgets/custom_qtreeview.py | 2 +- .../spine_db_editor/widgets/spine_db_editor.py | 15 ++++++--------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/spinetoolbox/spine_db_editor/mvcmodels/compound_models.py b/spinetoolbox/spine_db_editor/mvcmodels/compound_models.py index e514c8600..5ce0f7bed 100644 --- a/spinetoolbox/spine_db_editor/mvcmodels/compound_models.py +++ b/spinetoolbox/spine_db_editor/mvcmodels/compound_models.py @@ -51,9 +51,17 @@ def __init__(self, parent, db_mngr, *db_maps): handle_items_updated=self.handle_items_updated, owner=self, ) - self.dock = None + self._dock = None self._column_filters = {self.header[column]: False for column in range(self.columnCount())} + @property + def dock(self): + return self._dock + + @dock.setter + def dock(self, value): + self._dock = value + def _make_header(self): raise NotImplementedError() diff --git a/spinetoolbox/spine_db_editor/mvcmodels/entity_tree_models.py b/spinetoolbox/spine_db_editor/mvcmodels/entity_tree_models.py index e093b2f4f..1c41095ab 100644 --- a/spinetoolbox/spine_db_editor/mvcmodels/entity_tree_models.py +++ b/spinetoolbox/spine_db_editor/mvcmodels/entity_tree_models.py @@ -22,7 +22,6 @@ def __init__(self, *args, **kwargs): self.db_editor.qsettings.value("appSettings/hideEmptyClasses", defaultValue="false") == "true" ) self._hidden_items = set() - self._se = False def has_hidden_items(self): return bool(len(self._hidden_items)) @@ -76,14 +75,16 @@ def hide_empty_classes(self, hide_empty_classes): self.root_item.refresh_child_map() def hide_classes(self, classes): - """This should make every item from selection have hidden=True and refresh the tree""" + """Sets selected classes as hidden and refreshes the tree""" for item in classes: item.hidden = True self._hidden_items.add(item) self.root_item.refresh_child_map() def show_hidden_classes(self): - """This should make every item have hidden=False and refresh the tree""" + """Sets all classes as not hidden and refreshes the tree + (empty classes remain hidden if Hide empty classes is enabled) + """ for item in self._hidden_items: item.hidden = False self._hidden_items.clear() diff --git a/spinetoolbox/spine_db_editor/widgets/custom_qtreeview.py b/spinetoolbox/spine_db_editor/widgets/custom_qtreeview.py index c08bae5cd..3faf0f7f5 100644 --- a/spinetoolbox/spine_db_editor/widgets/custom_qtreeview.py +++ b/spinetoolbox/spine_db_editor/widgets/custom_qtreeview.py @@ -164,7 +164,7 @@ def color_dock(self, color): dock = self.parent().parent() self._spine_db_editor.set_dock_tab_color(dock, color) text = "CLASSES HIDDEN" if color else None - self._spine_db_editor.rename_dock(dock, text) + self._spine_db_editor.rename_dock(dock, "Entity tree", text) def toggle_hide_empty_classes(self): self.model().hide_empty_classes = self._hide_empty_classes_action.isChecked() diff --git a/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py b/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py index 23913a492..ed7123b7f 100644 --- a/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py +++ b/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py @@ -886,21 +886,18 @@ def set_dock_tab_color(dock, color): def handle_column_filters(self, model): if not model.dock: return + original_name = table_name_from_item_type(model.item_type) if not any(model.column_filters.values()): # Back to defaults - model.dock.setWindowTitle(table_name_from_item_type(model.item_type)) + self.rename_dock(model.dock, original_name) self.set_dock_tab_color(model.dock, None) return - self.set_dock_tab_color(model.dock, QColor("paleturquoise")) - table_name = table_name_from_item_type(model.item_type) - table_name += ( - f" [COLUMN FILTERS: {', '.join([name for name, active in model.column_filters.items() if active])}]" - ) - model.dock.setWindowTitle(table_name) + self.set_dock_tab_color(model.dock, QColor("lightcyan")) + text = f"COLUMN FILTERS: {', '.join([name for name, active in model.column_filters.items() if active])}" + self.rename_dock(model.dock, original_name, text) @staticmethod - def rename_dock(dock, text=None): - name = "Entity tree" + def rename_dock(dock, name, text=None): if text: name += " [" + text + "]" dock.setWindowTitle(name)