fuzbal/Events.qml
Timotej Lazar cb76fedcbc
Implement event model in C++
Filtering events in JS is too slow with >20,000 events. This moves the
event data model into C++.
2021-09-16 20:33:05 +02:00

48 lines
1.3 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 events 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()
}
}
}