Skip to content

Commit

Permalink
Adapt to life after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Koski committed Jun 17, 2024
1 parent 7d0fe1d commit e714182
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
10 changes: 9 additions & 1 deletion spinetoolbox/spine_db_editor/mvcmodels/compound_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 4 additions & 3 deletions spinetoolbox/spine_db_editor/mvcmodels/entity_tree_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion spinetoolbox/spine_db_editor/widgets/custom_qtreeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 6 additions & 9 deletions spinetoolbox/spine_db_editor/widgets/spine_db_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e714182

Please sign in to comment.