From f9a466441072cd752fafac024ef5fe0cc56fea7b Mon Sep 17 00:00:00 2001 From: Niko Aarnio Date: Thu, 20 Feb 2025 12:14:04 +0200 Subject: [PATCH 1/2] =?UTF-8?q?remove=20yleism=C3=A4=C3=A4r=C3=A4ykset=20f?= =?UTF-8?q?rom=20new=20regulation=20group=20type=20selection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arho_feature_template/gui/dialogs/plan_regulation_group_form.py | 1 + 1 file changed, 1 insertion(+) 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..cfd461a 100644 --- a/arho_feature_template/gui/dialogs/plan_regulation_group_form.py +++ b/arho_feature_template/gui/dialogs/plan_regulation_group_form.py @@ -85,6 +85,7 @@ def __init__(self, regulation_group: RegulationGroup): 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.removeItem(0) # Remove Yleismääräykset from selections self.add_proposition_btn.clicked.connect(self.add_new_proposition) self.add_proposition_btn.setIcon(QgsApplication.getThemeIcon("mActionAdd.svg")) From 224201cd5b75b81cad2b55706c6a2a98f0041c9f Mon Sep 17 00:00:00 2001 From: Niko Aarnio Date: Fri, 21 Feb 2025 12:24:47 +0200 Subject: [PATCH 2/2] add remove_item_by_text method to CodeComboBox class --- arho_feature_template/gui/components/code_combobox.py | 5 +++++ arho_feature_template/gui/dialogs/plan_feature_form.py | 2 +- .../gui/dialogs/plan_regulation_group_form.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) 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 cfd461a..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,8 +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.removeItem(0) # Remove Yleismääräykset 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"))