From cb76fedcbc8e419e2b945baa56ac3f986a9e79a3 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 1 Sep 2021 17:13:51 +0200 Subject: Implement event model in C++ Filtering events in JS is too slow with >20,000 events. This moves the event data model into C++. --- Tags.qml | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'Tags.qml') diff --git a/Tags.qml b/Tags.qml index 7d3f0ce..9e64cff 100644 --- a/Tags.qml +++ b/Tags.qml @@ -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 - - Flow { - spacing: 5 - Layout.fillWidth: true - - 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 + Keys.forwardTo: Array.from({ length: buttons.count }, (_, i) => buttons.itemAt(i)) + + spacing: 5 + + 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 } } } -- cgit v1.3