Skip to content

Commit 5ef652b

Browse files
committed
show short name before heading for regulation groups in tree and list views
1 parent 261e550 commit 5ef652b

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

arho_feature_template/core/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ def from_config_data(cls, data: dict) -> RegulationGroup:
513513
id_=None,
514514
)
515515

516+
def __str__(self):
517+
return " - ".join(part for part in (self.short_name, self.name) if part)
518+
516519

517520
@dataclass
518521
class PlanFeature:

arho_feature_template/gui/dialogs/plan_feature_form.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ def show_regulation_group_library(self, i: int):
129129
library = self.regulation_group_libraries[i]
130130
for category in library.regulation_group_categories:
131131
category_item = self.regulation_groups_selection_widget.add_item_to_tree(category.name)
132-
for group_definition in category.regulation_groups:
133-
_ = self.regulation_groups_selection_widget.add_item_to_tree(
134-
group_definition.name, group_definition, category_item
135-
)
132+
for group in category.regulation_groups:
133+
_ = self.regulation_groups_selection_widget.add_item_to_tree(str(group), group, category_item)
136134

137135
def into_model(self) -> PlanFeature:
138136
return PlanFeature(

arho_feature_template/gui/docks/regulation_groups_dock.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,9 @@ def initialize_regulation_groups(self, regulation_group_library: RegulationGroup
7474
self.selected_group = None
7575

7676
def add_regulation_group_to_list(self, group: RegulationGroup):
77-
short_name = group.short_name if group.short_name else ""
78-
name = group.name if group.name else ""
79-
if short_name and name:
80-
text = f"{short_name} - {name}"
81-
elif short_name:
82-
text = short_name
83-
else:
84-
text = name
77+
text = str(group)
8578
item = QListWidgetItem(text)
86-
item.setToolTip(name)
79+
item.setToolTip(text)
8780
item.setData(Qt.UserRole, group)
8881
self.regulation_group_list.addItem(item)
8982

0 commit comments

Comments
 (0)