summaryrefslogtreecommitdiff
path: root/Event.qml
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.si>2021-09-11 17:16:57 +0200
committerTimotej Lazar <timotej.lazar@araneo.si>2021-09-16 20:33:50 +0200
commit4ef0c49825c044edd972d1ffc59455db34bd20f4 (patch)
tree894be8d67f829474b99e793b52b6ef3c4a5abe90 /Event.qml
parent1eee2fc2b5a50928c9583cc4c0ebdf520912c851 (diff)
Event: reset values on editing start
Diffstat (limited to 'Event.qml')
-rw-r--r--Event.qml24
1 files changed, 12 insertions, 12 deletions
diff --git a/Event.qml b/Event.qml
index 7bad6d5..da5c194 100644
--- a/Event.qml
+++ b/Event.qml
@@ -8,6 +8,8 @@ import 'util.js' as Util
// This is the delegate for event list items.
ItemDelegate {
+ id: control
+
required property var model
required property int index
required property int time
@@ -29,15 +31,6 @@ ItemDelegate {
radius: border.width
}
- // Set inputs to current model values.
- function reset() {
- for (var i = 0; i < fields.length; i++) {
- const child = inputs.itemAt(i)
- if (child && child.item)
- child.item.set(model.values[fields[i].name])
- }
- }
-
// Store current inputs in model.
function store() {
var values = {}
@@ -46,7 +39,6 @@ ItemDelegate {
model.values = values
}
- Component.onCompleted: reset()
onEditingChanged: {
if (editing)
forceActiveFocus()
@@ -75,7 +67,7 @@ ItemDelegate {
var str = ''
for (var i = 0; i < inputs.count; i++) {
const field = inputs.model[i]
- const value = inputs.itemAt(i).item.value
+ const value = model.values[field.name]
if (value && field.type !== 'TextArea')
str += (field.type === 'Bool' ? field.name : value) + ' '
}
@@ -88,7 +80,7 @@ ItemDelegate {
}
}
- // Event‐specific input fields.
+ // Inputs for event‐specific fields.
GridLayout {
flow: GridLayout.TopToBottom
rows: inputs.count
@@ -110,8 +102,16 @@ ItemDelegate {
id: inputs
delegate: Loader {
source: 'qrc:/Fields/' + modelData.type + '.qml'
+
Layout.fillHeight: true
Layout.fillWidth: true
+
+ // Set input value to what is in the model each time the control is expanded.
+ onVisibleChanged: {
+ if (item && visible)
+ item.set(control.model.values[modelData.name])
+ }
+
Binding {
target: item; property: 'model'
value: modelData