Skip to content

Commit 01f7f5b

Browse files
committed
read additional information from given PlanRegulationDefinition in template form
1 parent 5238732 commit 01f7f5b

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

arho_feature_template/gui/plan_regulation_widget.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections import defaultdict
44
from importlib import resources
5-
from typing import TYPE_CHECKING
5+
from typing import TYPE_CHECKING, cast
66

77
from qgis.core import QgsApplication
88
from qgis.gui import QgsDoubleSpinBox, QgsFileWidget, QgsSpinBox
@@ -42,6 +42,9 @@
4242
TEXT_VALUE_FIELD = "text_value"
4343
REGULATION_TYPE_ADDITIONAL_INFORMATION_ID = "regulation_type_additional_information_id"
4444

45+
# TO BE REPLACED
46+
ADDITIONAL_INFORMATION_TYPES_WITH_INPUT = ["kayttotarkoituskohdistus"]
47+
4548

4649
class PlanRegulationWidget(QWidget, FormClass): # type: ignore
4750
"""A widget representation of a plan regulation."""
@@ -74,7 +77,18 @@ def __init__(self, config: PlanRegulationConfig, parent=None):
7477
self.init_buttons()
7578

7679
def populate_from_definition(self, definition: PlanRegulationDefinition):
77-
pass
80+
# Additional information
81+
for info in definition.additional_information:
82+
info_type: str = cast("str", info["type"])
83+
layout = self.add_additional_info(info_type)
84+
if info_type in ADDITIONAL_INFORMATION_TYPES_WITH_INPUT:
85+
info_value_widget = QLineEdit()
86+
layout.addWidget(info_value_widget)
87+
value = info.get("value")
88+
if value:
89+
info_value_widget.setText(value)
90+
91+
# TODO: Other saved information from PlanRegulationDefinition
7892

7993
def init_value_fields(self):
8094
layout = QHBoxLayout()
@@ -187,10 +201,14 @@ def add_versioned_text_input(self, layout: QHBoxLayout):
187201
layout.addWidget(text_widget)
188202
self.form_layout.addRow("Kieliversioitu teksti", layout)
189203

190-
def add_additional_info(self, info_type):
191-
info_type_label = QLineEdit(info_type)
204+
def add_additional_info(self, info_type: str) -> QHBoxLayout:
205+
layout = QHBoxLayout()
206+
info_name = get_additional_information_name(info_type)
207+
info_type_label = QLineEdit(info_name)
192208
info_type_label.setReadOnly(True)
193-
self.form_layout.addRow("Lisätiedonlaji", info_type_label)
209+
layout.addWidget(info_type_label)
210+
self.form_layout.addRow("Lisätiedonlaji", layout)
211+
return layout
194212

195213
def add_regulation_number(self):
196214
if not self.regulation_number_added:

0 commit comments

Comments
 (0)