diff --git a/arho_feature_template/gui/components/code_combobox.py b/arho_feature_template/gui/components/code_combobox.py index b4a8e83..243e22a 100644 --- a/arho_feature_template/gui/components/code_combobox.py +++ b/arho_feature_template/gui/components/code_combobox.py @@ -49,6 +49,11 @@ def set_value(self, value: str | None) -> None: if index != -1: self.setCurrentIndex(index) + def remove_item_by_text(self, text: str): + index = self.findText(text) + if index != -1: + self.removeItem(index) + class HierarchicalCodeComboBox(QComboBox): def __init__(self, parent=None): diff --git a/arho_feature_template/gui/dialogs/plan_feature_form.py b/arho_feature_template/gui/dialogs/plan_feature_form.py index d945fd8..37ec004 100644 --- a/arho_feature_template/gui/dialogs/plan_feature_form.py +++ b/arho_feature_template/gui/dialogs/plan_feature_form.py @@ -73,7 +73,7 @@ def __init__( self.show_regulation_group_library(0) self.feature_type_of_underground.populate_from_code_layer(UndergroundTypeLayer) - self.feature_type_of_underground.removeItem(0) # Remove NULL from combobox as underground data is required + self.feature_type_of_underground.remove_item_by_text("NULL") self.feature_type_of_underground.setCurrentIndex(1) # Set default to Maanpäällinen (index 1) # Initialize attributes from template diff --git a/arho_feature_template/gui/dialogs/plan_regulation_group_form.py b/arho_feature_template/gui/dialogs/plan_regulation_group_form.py index 4053060..7123ac8 100644 --- a/arho_feature_template/gui/dialogs/plan_regulation_group_form.py +++ b/arho_feature_template/gui/dialogs/plan_regulation_group_form.py @@ -84,7 +84,8 @@ def __init__(self, regulation_group: RegulationGroup): self._initalize_regulation_from_config(config) self.type_of_regulation_group.populate_from_code_layer(PlanRegulationGroupTypeLayer) - self.type_of_regulation_group.removeItem(0) # Remove NULL from selections + self.type_of_regulation_group.remove_item_by_text("NULL") + self.type_of_regulation_group.remove_item_by_text("Yleismääräykset") self.add_proposition_btn.clicked.connect(self.add_new_proposition) self.add_proposition_btn.setIcon(QgsApplication.getThemeIcon("mActionAdd.svg"))