Skip to content

Commit 224201c

Browse files
committed
add remove_item_by_text method to CodeComboBox class
1 parent f9a4664 commit 224201c

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

arho_feature_template/gui/components/code_combobox.py

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def set_value(self, value: str | None) -> None:
4949
if index != -1:
5050
self.setCurrentIndex(index)
5151

52+
def remove_item_by_text(self, text: str):
53+
index = self.findText(text)
54+
if index != -1:
55+
self.removeItem(index)
56+
5257

5358
class HierarchicalCodeComboBox(QComboBox):
5459
def __init__(self, parent=None):

arho_feature_template/gui/dialogs/plan_feature_form.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
self.show_regulation_group_library(0)
7474

7575
self.feature_type_of_underground.populate_from_code_layer(UndergroundTypeLayer)
76-
self.feature_type_of_underground.removeItem(0) # Remove NULL from combobox as underground data is required
76+
self.feature_type_of_underground.remove_item_by_text("NULL")
7777
self.feature_type_of_underground.setCurrentIndex(1) # Set default to Maanpäällinen (index 1)
7878

7979
# Initialize attributes from template

arho_feature_template/gui/dialogs/plan_regulation_group_form.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def __init__(self, regulation_group: RegulationGroup):
8484
self._initalize_regulation_from_config(config)
8585

8686
self.type_of_regulation_group.populate_from_code_layer(PlanRegulationGroupTypeLayer)
87-
self.type_of_regulation_group.removeItem(0) # Remove NULL from selections
88-
self.type_of_regulation_group.removeItem(0) # Remove Yleismääräykset from selections
87+
self.type_of_regulation_group.remove_item_by_text("NULL")
88+
self.type_of_regulation_group.remove_item_by_text("Yleismääräykset")
8989

9090
self.add_proposition_btn.clicked.connect(self.add_new_proposition)
9191
self.add_proposition_btn.setIcon(QgsApplication.getThemeIcon("mActionAdd.svg"))

0 commit comments

Comments
 (0)