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 /Fields | |
| 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 'Fields')
| -rw-r--r-- | Fields/Bool.qml | 5 | ||||
| -rw-r--r-- | Fields/Enum.qml | 16 | ||||
| -rw-r--r-- | Fields/Text.qml | 8 | ||||
| -rw-r--r-- | Fields/TextArea.qml | 6 |
4 files changed, 17 insertions, 18 deletions
diff --git a/Fields/Bool.qml b/Fields/Bool.qml index ccb0758..f6cd184 100644 --- a/Fields/Bool.qml +++ b/Fields/Bool.qml @@ -4,14 +4,13 @@ import QtQuick 2.12 import QtQuick.Controls 2.13 Row { - id: control width: parent.width - property var definition + property var model property alias value: input.checked Keys.onPressed: { - if (event.text === definition.key) { + if (event.text === model.key) { value = !value event.accepted = true } diff --git a/Fields/Enum.qml b/Fields/Enum.qml index 30712b6..cb49b3b 100644 --- a/Fields/Enum.qml +++ b/Fields/Enum.qml @@ -8,13 +8,13 @@ import '../util.js' as Util Column { id: control - property var definition + property var model property int index: -1 - readonly property string value: index >= 0 ? definition.values.get(index).name : '' + readonly property string value: index >= 0 ? model.values[index].name : '' function set(val) { - for (var i = 0; i < definition.values.count; i++) { - if (definition.values.get(i).name === val) { + for (var i = 0; i < model.values.length; i++) { + if (model.values[i].name === val) { index = i return true } @@ -23,8 +23,8 @@ Column { } Keys.onPressed: { - for (var i = 0; i < definition.values.count; i++) { - if (definition.values.get(i).key === event.text) { + for (var i = 0; i < model.values.length; i++) { + if (model.values[i].key === event.text) { index = (index === i ? -1 : i) event.accepted = true break @@ -39,7 +39,7 @@ Column { ButtonGroup { id: buttons } Repeater { - model: definition.values + model: control.model.values delegate: Button { ButtonGroup.group: buttons checkable: true @@ -52,7 +52,7 @@ Column { rightPadding: leftPadding onClicked: control.index = (control.index === index ? -1 : index) - text: Util.addShortcut(name, key) + text: Util.addShortcut(modelData.name, modelData.key) } } } diff --git a/Fields/Text.qml b/Fields/Text.qml index 49d7ad2..b4e4dbf 100644 --- a/Fields/Text.qml +++ b/Fields/Text.qml @@ -6,11 +6,11 @@ import QtQuick.Controls 2.13 Label { id: control - property var definition + property var model property alias value: control.text Keys.onPressed: { - if (event.text === definition.key) { + if (event.text === model.key) { popup.open() event.accepted = true } @@ -23,8 +23,8 @@ Label { Popup { id: popup - width: control.width - height: control.height + width: parent.width + height: parent.height padding: 0 onOpened: { diff --git a/Fields/TextArea.qml b/Fields/TextArea.qml index 20cfeff..7be3564 100644 --- a/Fields/TextArea.qml +++ b/Fields/TextArea.qml @@ -6,11 +6,11 @@ import QtQuick.Controls 2.13 Label { id: control - property var definition + property var model property alias value: control.text Keys.onPressed: { - if (event.text === definition.key) { + if (event.text === model.key) { popup.open() event.accepted = true } @@ -23,7 +23,7 @@ Label { Popup { id: popup - width: control.width + width: parent.width height: input.height padding: 0 |
