|
8 | 8 | from qgis.gui import QgsDoubleSpinBox, QgsFileWidget, QgsSpinBox
|
9 | 9 | from qgis.PyQt import uic
|
10 | 10 | from qgis.PyQt.QtCore import pyqtSignal
|
11 |
| -from qgis.PyQt.QtWidgets import QComboBox, QFormLayout, QMenu, QTextEdit, QWidget |
| 11 | +from qgis.PyQt.QtWidgets import QComboBox, QFormLayout, QHBoxLayout, QLineEdit, QMenu, QSizePolicy, QTextEdit, QWidget |
12 | 12 |
|
13 | 13 | if TYPE_CHECKING:
|
14 |
| - from qgis.PyQt.QtWidgets import QLineEdit, QPushButton |
| 14 | + from qgis.PyQt.QtWidgets import QPushButton |
15 | 15 |
|
16 | 16 | ui_path = resources.files(__package__) / "new_plan_regulation_widget.ui"
|
17 | 17 | FormClass, _ = uic.loadUiType(ui_path)
|
@@ -80,35 +80,45 @@ def init_buttons(self):
|
80 | 80 |
|
81 | 81 | def add_input_field(self, input_field_type: InputTypes):
|
82 | 82 | if input_field_type == InputTypes.TEXT_VALUE:
|
83 |
| - widget = QTextEdit() |
84 |
| - self.form_layout.addRow("Tekstiarvo", widget) |
| 83 | + inputs = QTextEdit() |
| 84 | + self.form_layout.addRow("Tekstiarvo", inputs) |
85 | 85 | elif input_field_type == InputTypes.NUMERIC_VALUE:
|
86 |
| - widget = QgsDoubleSpinBox() # Or QgsSpinBox? |
87 |
| - self.form_layout.addRow("Numeerinen arvo", widget) |
| 86 | + value_widget = QgsDoubleSpinBox() # Or QgsSpinBox? |
| 87 | + value_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) |
| 88 | + unit_widget = QLineEdit() |
| 89 | + inputs = QHBoxLayout() |
| 90 | + inputs.addWidget(value_widget) |
| 91 | + inputs.addWidget(unit_widget) |
| 92 | + self.form_layout.addRow("Numeerinen arvo", inputs) |
88 | 93 | elif input_field_type == InputTypes.CODE_VALUE:
|
89 |
| - widget = QComboBox() |
90 |
| - # TODO: widget.addItems() |
91 |
| - self.form_layout.addRow("Koodiarvo", widget) |
| 94 | + code_widget = QComboBox() |
| 95 | + code_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) |
| 96 | + value_widget = QLineEdit() |
| 97 | + inputs = QHBoxLayout() |
| 98 | + inputs.addWidget(code_widget) |
| 99 | + inputs.addWidget(value_widget) |
| 100 | + # TODO: inputs.addItems() |
| 101 | + self.form_layout.addRow("Koodiarvo", inputs) |
92 | 102 |
|
93 | 103 | elif input_field_type == InputTypes.TEXT_INFO:
|
94 |
| - widget = QTextEdit() |
95 |
| - self.form_layout.addRow("Lisätieto", widget) |
| 104 | + inputs = QTextEdit() |
| 105 | + self.form_layout.addRow("Lisätieto", inputs) |
96 | 106 | elif input_field_type == InputTypes.NUMERIC_INFO:
|
97 |
| - widget = QgsDoubleSpinBox() |
98 |
| - self.form_layout.addRow("Lisätieto", widget) |
| 107 | + inputs = QgsDoubleSpinBox() |
| 108 | + self.form_layout.addRow("Lisätieto", inputs) |
99 | 109 | elif input_field_type == InputTypes.CODE_INFO:
|
100 |
| - widget = QComboBox() |
101 |
| - # TODO: widget.addItems() |
102 |
| - self.form_layout.addRow("Lisätieto", widget) |
| 110 | + inputs = QComboBox() |
| 111 | + # TODO: inputs.addItems() |
| 112 | + self.form_layout.addRow("Lisätieto", inputs) |
103 | 113 |
|
104 | 114 | elif input_field_type == InputTypes.REGULATION_NUMBER:
|
105 |
| - widget = QgsSpinBox() |
106 |
| - self.form_layout.addRow("Määräysnumero", widget) |
| 115 | + inputs = QgsSpinBox() |
| 116 | + self.form_layout.addRow("Määräysnumero", inputs) |
107 | 117 | elif input_field_type == InputTypes.RELATED_FILE:
|
108 |
| - widget = QgsFileWidget() |
109 |
| - self.form_layout.addRow("Liiteasiakirja", widget) |
| 118 | + inputs = QgsFileWidget() |
| 119 | + self.form_layout.addRow("Liiteasiakirja", inputs) |
110 | 120 |
|
111 | 121 | if self.widgets.get(input_field_type) is None:
|
112 |
| - self.widgets[input_field_type] = [widget] |
| 122 | + self.widgets[input_field_type] = [inputs] |
113 | 123 | else:
|
114 |
| - self.widgets[input_field_type].append(widget) |
| 124 | + self.widgets[input_field_type].append(inputs) |
0 commit comments