Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Näytä kaavakohteen lyhyt nimi valikoissa #195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions arho_feature_template/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ def from_config_data(cls, data: dict) -> RegulationGroup:
id_=None,
)

def __str__(self):
return " - ".join(part for part in (self.short_name, self.name) if part)


@dataclass
class PlanFeature:
Expand Down
6 changes: 2 additions & 4 deletions arho_feature_template/gui/dialogs/plan_feature_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ def show_regulation_group_library(self, i: int):
library = self.regulation_group_libraries[i]
for category in library.regulation_group_categories:
category_item = self.regulation_groups_selection_widget.add_item_to_tree(category.name)
for group_definition in category.regulation_groups:
_ = self.regulation_groups_selection_widget.add_item_to_tree(
group_definition.name, group_definition, category_item
)
for group in category.regulation_groups:
_ = self.regulation_groups_selection_widget.add_item_to_tree(str(group), group, category_item)

def into_model(self) -> PlanFeature:
return PlanFeature(
Expand Down
11 changes: 2 additions & 9 deletions arho_feature_template/gui/docks/regulation_groups_dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,9 @@ def initialize_regulation_groups(self, regulation_group_library: RegulationGroup
self.selected_group = None

def add_regulation_group_to_list(self, group: RegulationGroup):
short_name = group.short_name if group.short_name else ""
name = group.name if group.name else ""
if short_name and name:
text = f"{short_name} - {name}"
elif short_name:
text = short_name
else:
text = name
text = str(group)
item = QListWidgetItem(text)
item.setToolTip(name)
item.setToolTip(text)
item.setData(Qt.UserRole, group)
self.regulation_group_list.addItem(item)

Expand Down
Loading