aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-03-07 10:21:53 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-04-08 07:42:08 +0000
commit7a303424f2095c53889f8102f115ec38013ef8d9 (patch)
tree883debcf88b5a9ce3da8acef37b86fc865f79294 /tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml
parent74313fd30a79e6f26734127157870c4491331501 (diff)
Add TableModelColumn
This allows us to support simple object rows by default, which we expect to be the most common use case for TableModel. Complex rows are supported, but with a limited subset of functionality. Things that could be improved: - Would be nice if we could get arbitrary/dynamic properties like ListModel has, without the complex code that comes with it. That way we could get rid of all of the role properties and users could have their own custom roles. The limitation of only having built-in roles becomes too restrictive very quickly. Change-Id: Icbdb6b39665851c55c69c0b79e0aa523c5d46dfe Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml')
-rw-r--r--tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml25
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml b/tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml
index 5f849c3350..ebfe4ed930 100644
--- a/tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml
+++ b/tests/auto/qml/qqmltablemodel/data/setDataThroughDelegate.qml
@@ -41,11 +41,11 @@ Item {
signal shouldModifyInvalidType()
function modify() {
- shouldModify();
+ shouldModify()
}
function modifyInvalidRole() {
- shouldModifyInvalidRole();
+ shouldModifyInvalidRole()
}
function modifyInvalidType() {
@@ -54,37 +54,24 @@ Item {
TableView {
anchors.fill: parent
- model: TableModel {
+ model: TestModel {
id: testModel
- objectName: "testModel"
- rows: [
- [
- { name: "John" },
- { age: 22 }
- ],
- [
- { name: "Oliver" },
- { age: 33 }
- ]
- ]
}
delegate: Text {
id: textItem
- // TODO: this is currently random when no roleDataProvider handles it
- // we should allow roleDataProvider to be used to handle specific roles only
text: model.display
Connections {
target: root
enabled: column === 1
- onShouldModify: model.age = 18
+ onShouldModify: model.display = 18
}
Connections {
target: root
enabled: column === 0
- // Invalid: should be "name".
+ // Invalid: should be "display".
onShouldModifyInvalidRole: model.age = 100
}
@@ -92,7 +79,7 @@ Item {
target: root
enabled: column === 1
// Invalid: should be string.
- onShouldModifyInvalidType: model.age = "Whoops"
+ onShouldModifyInvalidType: model.display = "Whoops"
}
}
}