feat(StatusQ): Added ModelChangeGuard utility to prevent altering models
This commit is contained in:
parent
aff97d741e
commit
bb2e03bd88
|
@ -61,15 +61,36 @@ QtObject {
|
||||||
]
|
]
|
||||||
|
|
||||||
readonly property ListModel permissionsModel: ListModel {
|
readonly property ListModel permissionsModel: ListModel {
|
||||||
Component.onCompleted: append(permissionsModelData)
|
readonly property ModelChangeGuard guard: ModelChangeGuard {
|
||||||
|
model: root.permissionsModel
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
append(permissionsModelData)
|
||||||
|
guard.enabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var shortPermissionsModel: ListModel {
|
readonly property var shortPermissionsModel: ListModel {
|
||||||
Component.onCompleted: append(shortPermissionsModelData)
|
readonly property ModelChangeGuard guard: ModelChangeGuard {
|
||||||
|
model: root.shortPermissionsModel
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
append(shortPermissionsModelData)
|
||||||
|
guard.enabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var longPermissionsModel: ListModel {
|
readonly property var longPermissionsModel: ListModel {
|
||||||
Component.onCompleted: append(longPermissionsModelData)
|
readonly property ModelChangeGuard guard: ModelChangeGuard {
|
||||||
|
model: root.longPermissionsModel
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
append(longPermissionsModelData)
|
||||||
|
guard.enabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createHoldingsModel1() {
|
function createHoldingsModel1() {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import QtQml 2.15
|
||||||
|
|
||||||
|
ModelChangeTracker {
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
onRevisionChanged: {
|
||||||
|
throw new Error("The model is assumed to be immutable.")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import QtQml 2.14
|
import QtQml 2.15
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
property var model
|
property var model
|
||||||
|
|
||||||
readonly property alias revision: d.revision
|
readonly property alias revision: d.revision
|
||||||
|
property alias enabled: d.enabled
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
d.revision = 0
|
d.revision = 0
|
||||||
|
|
|
@ -2,6 +2,7 @@ module StatusQ.Core.Utils
|
||||||
|
|
||||||
EmojiJSON 1.0 emojiList.js
|
EmojiJSON 1.0 emojiList.js
|
||||||
JSONListModel 0.1 JSONListModel.qml
|
JSONListModel 0.1 JSONListModel.qml
|
||||||
|
ModelChangeGuard 0.1 ModelChangeGuard.qml
|
||||||
ModelChangeTracker 0.1 ModelChangeTracker.qml
|
ModelChangeTracker 0.1 ModelChangeTracker.qml
|
||||||
ModelsComparator 0.1 ModelsComparator.qml
|
ModelsComparator 0.1 ModelsComparator.qml
|
||||||
XSS 1.0 xss.js
|
XSS 1.0 xss.js
|
||||||
|
|
Loading…
Reference in New Issue