|
2 | 2 |
|
3 | 3 | from collections import defaultdict
|
4 | 4 | from importlib import resources
|
5 |
| -from typing import TYPE_CHECKING |
| 5 | +from typing import TYPE_CHECKING, cast |
6 | 6 |
|
7 | 7 | from qgis.core import QgsApplication
|
8 | 8 | from qgis.gui import QgsDoubleSpinBox, QgsFileWidget, QgsSpinBox
|
|
42 | 42 | TEXT_VALUE_FIELD = "text_value"
|
43 | 43 | REGULATION_TYPE_ADDITIONAL_INFORMATION_ID = "regulation_type_additional_information_id"
|
44 | 44 |
|
| 45 | +# TO BE REPLACED |
| 46 | +ADDITIONAL_INFORMATION_TYPES_WITH_INPUT = ["kayttotarkoituskohdistus"] |
| 47 | + |
45 | 48 |
|
46 | 49 | class PlanRegulationWidget(QWidget, FormClass): # type: ignore
|
47 | 50 | """A widget representation of a plan regulation."""
|
@@ -74,7 +77,18 @@ def __init__(self, config: PlanRegulationConfig, parent=None):
|
74 | 77 | self.init_buttons()
|
75 | 78 |
|
76 | 79 | 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 |
78 | 92 |
|
79 | 93 | def init_value_fields(self):
|
80 | 94 | layout = QHBoxLayout()
|
@@ -187,10 +201,14 @@ def add_versioned_text_input(self, layout: QHBoxLayout):
|
187 | 201 | layout.addWidget(text_widget)
|
188 | 202 | self.form_layout.addRow("Kieliversioitu teksti", layout)
|
189 | 203 |
|
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) |
192 | 208 | 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 |
194 | 212 |
|
195 | 213 | def add_regulation_number(self):
|
196 | 214 | if not self.regulation_number_added:
|
|
0 commit comments