// SPDX-License-Identifier: Unlicense import QtQuick 2.12 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.6 import 'util.js' as Util // This is the delegate for event list items. Pane { id: control property int time property alias tag: tag.text property alias fields: inputs.model property bool editing: false signal remove clip: true height: visible ? stuff.height + 2*padding : 0 // TODO fix filtering and remove this padding: 2 // set to current value or default function reset() { for (var i = 0; i < fields.count; i++) { const child = inputs.itemAt(i) if (child && child.item) child.item.set(fields.get(i).value) } } function store() { for (var i = 0; i < fields.count; i++) fields.setProperty(i, 'value', inputs.itemAt(i).item.value) } // Pass keys to each field input in order. Keys.forwardTo: Array.from({ length: inputs.count }, (_, i) => inputs.itemAt(i).item) Behavior on height { NumberAnimation { duration: 50 } } ColumnLayout { id: stuff anchors { left: parent.left; right: parent.right; margins: 5 } RowLayout { Label { text: new Date(time).toISOString().substr(12, 9) font.pixelSize: 10 Layout.alignment: Qt.AlignBaseline } Label { id: tag font.weight: Font.DemiBold Layout.alignment: Qt.AlignBaseline } Label { text: { var str = '' for (var i = 0; i < fields.count; i++) { const field = fields.get(i) if (field.value && field.type !== 'TextArea') str += (field.type === 'Bool' ? field.name : field.value) + ' ' } return str } elide: Text.ElideRight textFormat: Text.PlainText Layout.fillWidth: true Layout.alignment: Qt.AlignBaseline } } // Event‐specific inputs. GridLayout { id: fieldset flow: GridLayout.TopToBottom rows: inputs.count columnSpacing: 10 visible: editing // Labels. Repeater { model: inputs.model delegate: Label { text: Util.addShortcut(model.name, model.key) Layout.alignment: Qt.AlignRight } } // Inputs. Repeater { id: inputs delegate: Loader { source: 'qrc:/Fields/' + model.type + '.qml' Layout.fillHeight: true Layout.fillWidth: true Binding { target: item; property: 'definition' value: model } } } } } }