Implement event model in C++
Filtering events in JS is too slow with >20,000 events. This moves the event data model into C++.
This commit is contained in:
parent
e9b70c585c
commit
cb76fedcbc
14 changed files with 375 additions and 342 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue