diff options
| author | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-01 17:13:51 +0200 |
|---|---|---|
| committer | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-16 20:33:05 +0200 |
| commit | cb76fedcbc8e419e2b945baa56ac3f986a9e79a3 (patch) | |
| tree | e29be52e4372d3d6e5bfe7056d7af1e1cc0ae2bc /Tags.qml | |
| parent | e9b70c585c6bf1fa68a594a8755d90c017e6260c (diff) | |
Implement event model in C++
Filtering events in JS is too slow with >20,000 events. This moves the
event data model into C++.
Diffstat (limited to 'Tags.qml')
| -rw-r--r-- | Tags.qml | 44 |
1 files changed, 17 insertions, 27 deletions
@@ -2,44 +2,34 @@ import QtQuick 2.12 import QtQuick.Controls 2.13 -import QtQuick.Layouts 1.6 import 'util.js' as Util // Tag list. -Page { +Flow { id: control - property alias model: tags.model + property alias model: buttons.model - signal clicked(string tag, var fields) + signal clicked(string tag) + // Try passing key to each field input in order. Keys.enabled: enabled - Keys.onPressed: { - for (var i = 0; i < model.length; i++) { - const tag = model[i] - if (tag.key === event.text) { - clicked(tag.tag, tag.fields) - return - } - } - event.accepted = false - } - - RowLayout { - width: parent.width + Keys.forwardTo: Array.from({ length: buttons.count }, (_, i) => buttons.itemAt(i)) - Flow { - spacing: 5 - Layout.fillWidth: true + spacing: 5 - Repeater { - id: tags - delegate: Button { - text: Util.addShortcut(modelData.tag, modelData.key) - onClicked: control.clicked(modelData.tag, modelData.fields) - focusPolicy: Qt.NoFocus - implicitWidth: implicitContentWidth + 2*padding + Repeater { + id: buttons + delegate: Button { + text: Util.addShortcut(modelData.tag, modelData.key) + focusPolicy: Qt.NoFocus + implicitWidth: implicitContentWidth + 2*padding + onClicked: control.clicked(modelData.tag) + Keys.onPressed: { + if (event.text === modelData.key) { + clicked() + event.accepted = true } } } |
