2021-06-14 19:09:53 +02:00
|
|
|
|
// SPDX-License-Identifier: Unlicense
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
import QtQuick.Layouts 1.6
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: control
|
|
|
|
|
|
2021-09-01 17:13:51 +02:00
|
|
|
|
required property var tags // tag definitions
|
2021-06-14 19:09:53 +02:00
|
|
|
|
property bool editing: false
|
|
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
focus: true
|
|
|
|
|
keyNavigationEnabled: true
|
|
|
|
|
highlightMoveDuration: 0
|
|
|
|
|
highlightResizeDuration: 0
|
|
|
|
|
|
|
|
|
|
onCurrentIndexChanged: editing = false
|
|
|
|
|
|
2021-09-01 17:13:51 +02:00
|
|
|
|
ScrollBar.vertical: ScrollBar { anchors.right: parent.right }
|
2021-06-14 19:09:53 +02:00
|
|
|
|
|
|
|
|
|
delegate: Event {
|
2021-09-01 17:13:51 +02:00
|
|
|
|
// If field definitions are missing for this event’s tag, use
|
|
|
|
|
// Text for all field types unless where the value is bool.
|
|
|
|
|
fields: tags[model.tag] ? tags[model.tag].fields :
|
|
|
|
|
Object.entries(model.values).map(value => ({
|
|
|
|
|
'name': value[0],
|
|
|
|
|
'type': typeof(value[1]) === 'boolean' ? 'Bool' : 'Text',
|
|
|
|
|
}))
|
2021-06-14 19:09:53 +02:00
|
|
|
|
|
|
|
|
|
width: control.width
|
|
|
|
|
editing: control.editing && ListView.isCurrentItem
|
2021-09-01 17:13:51 +02:00
|
|
|
|
highlighted: ListView.isCurrentItem
|
2021-06-14 19:09:53 +02:00
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
enabled: ListView.currentIndex === index
|
|
|
|
|
function onHeightChanged() {
|
|
|
|
|
control.positionViewAtIndex(index, ListView.Contain)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-01 17:13:51 +02:00
|
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
|
control.currentIndex = index
|
|
|
|
|
control.forceActiveFocus()
|
2021-06-14 19:09:53 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|