Skip to content

Commit ca3b7c1

Browse files
nmaarnioLKajan
authored andcommitted
add text inputs for numeric inputs (unit) and code input (value), connect dialog close/reject signal
1 parent c782829 commit ca3b7c1

File tree

2 files changed

+54
-27
lines changed

2 files changed

+54
-27
lines changed

arho_feature_template/gui/new_plan_regulation_group_form.ui

+22-5
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@
118118
<rect>
119119
<x>0</x>
120120
<y>0</y>
121-
<width>465</width>
122-
<height>435</height>
121+
<width>98</width>
122+
<height>28</height>
123123
</rect>
124124
</property>
125125
<layout class="QVBoxLayout" name="plan_regulations_layout">
@@ -157,8 +157,8 @@
157157
<rect>
158158
<x>0</x>
159159
<y>0</y>
160-
<width>727</width>
161-
<height>435</height>
160+
<width>98</width>
161+
<height>28</height>
162162
</rect>
163163
</property>
164164
</widget>
@@ -178,5 +178,22 @@
178178
</layout>
179179
</widget>
180180
<resources/>
181-
<connections/>
181+
<connections>
182+
<connection>
183+
<sender>button_box</sender>
184+
<signal>rejected()</signal>
185+
<receiver>Dialog</receiver>
186+
<slot>reject()</slot>
187+
<hints>
188+
<hint type="sourcelabel">
189+
<x>384</x>
190+
<y>513</y>
191+
</hint>
192+
<hint type="destinationlabel">
193+
<x>384</x>
194+
<y>267</y>
195+
</hint>
196+
</hints>
197+
</connection>
198+
</connections>
182199
</ui>

arho_feature_template/gui/new_plan_regulation_widget.py

+32-22
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
from qgis.gui import QgsDoubleSpinBox, QgsFileWidget, QgsSpinBox
99
from qgis.PyQt import uic
1010
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
1212

1313
if TYPE_CHECKING:
14-
from qgis.PyQt.QtWidgets import QLineEdit, QPushButton
14+
from qgis.PyQt.QtWidgets import QPushButton
1515

1616
ui_path = resources.files(__package__) / "new_plan_regulation_widget.ui"
1717
FormClass, _ = uic.loadUiType(ui_path)
@@ -80,35 +80,45 @@ def init_buttons(self):
8080

8181
def add_input_field(self, input_field_type: InputTypes):
8282
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)
8585
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)
8893
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)
92102

93103
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)
96106
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)
99109
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)
103113

104114
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)
107117
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)
110120

111121
if self.widgets.get(input_field_type) is None:
112-
self.widgets[input_field_type] = [widget]
122+
self.widgets[input_field_type] = [inputs]
113123
else:
114-
self.widgets[input_field_type].append(widget)
124+
self.widgets[input_field_type].append(inputs)

0 commit comments

Comments
 (0)