blob: 218884aca7df8eaebee052fee795910e7d8bc401 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// SPDX-License-Identifier: Unlicense
import QtQuick 2.12
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.6
ListView {
id: control
required property var tags // tag definitions
property bool editing: false
clip: true
focus: true
keyNavigationEnabled: true
highlightMoveDuration: 0
highlightResizeDuration: 0
onCurrentIndexChanged: editing = false
ScrollBar.vertical: ScrollBar { anchors.right: parent.right }
delegate: Event {
// 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',
}))
width: control.width
editing: control.editing && ListView.isCurrentItem
highlighted: ListView.isCurrentItem
Connections {
enabled: ListView.currentIndex === index
function onHeightChanged() {
control.positionViewAtIndex(index, ListView.Contain)
}
}
onClicked: {
control.currentIndex = index
control.forceActiveFocus()
}
}
}
|