Filtering events in JS is too slow with >20,000 events. This moves the event data model into C++.
48 lines
1.3 KiB
QML
48 lines
1.3 KiB
QML
// 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()
|
||
}
|
||
}
|
||
}
|