22
22
23
23
from arho_feature_template .core .models import PlanFeature , RegulationGroup , RegulationGroupLibrary
24
24
from arho_feature_template .gui .plan_regulation_group_widget import RegulationGroupWidget
25
+ from arho_feature_template .project .layers .code_layers import UndergroundTypeLayer
25
26
from arho_feature_template .project .layers .plan_layers import LandUseAreaLayer , PlanFeatureLayer
26
27
from arho_feature_template .qgis_plugin_tools .tools .resources import resources_path
27
28
30
31
from qgis .PyQt .QtWidgets import QWidget
31
32
32
33
from arho_feature_template .core .template_library_config import FeatureTemplate
34
+ from arho_feature_template .gui .code_combobox import CodeComboBox
33
35
34
36
ui_path = resources .files (__package__ ) / "template_attribute_form.ui"
35
37
FormClass , _ = uic .loadUiType (ui_path )
@@ -52,14 +54,18 @@ def __init__(
52
54
self .feature_layer_class = feature_layer_class
53
55
self .feature_name : QLineEdit
54
56
self .feature_description : QTextEdit
55
- self .feature_type_of_underground : QComboBox
57
+ self .feature_type_of_underground : CodeComboBox
56
58
self .plan_regulation_group_scrollarea : QScrollArea
57
59
self .plan_regulation_group_scrollarea_contents : QWidget
58
60
self .plan_regulation_group_libraries_combobox : QComboBox
59
61
self .plan_regulation_groups_tree : QTreeWidget
60
62
self .button_box : QDialogButtonBox
61
63
62
64
# INIT
65
+ self .feature_type_of_underground .populate_from_code_layer (UndergroundTypeLayer )
66
+ self .feature_type_of_underground .removeItem (0 ) # Remove NULL from combobox as underground data is required
67
+ self .feature_type_of_underground .setCurrentIndex (1 ) # Set default to Maanpäällinen (index 1)
68
+
63
69
self .regulation_group_widgets : list [RegulationGroupWidget ] = []
64
70
self .scroll_area_spacer = None
65
71
self .setWindowTitle (feature_template_config .name )
@@ -116,7 +122,7 @@ def init_plan_regulation_group_library(self, library: RegulationGroupLibrary):
116
122
def into_model (self ) -> PlanFeature :
117
123
return PlanFeature (
118
124
name = self .feature_name .text (),
119
- type_of_underground = self .feature_type_of_underground .currentIndex (),
125
+ type_of_underground_id = self .feature_type_of_underground .value (),
120
126
description = self .feature_description .toPlainText (),
121
127
geom = self .geom ,
122
128
feature_layer_class = self .feature_layer_class ,
0 commit comments