aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/listview/tst_listview.qml
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-09-21 16:29:39 -0500
committerMichael Brasser <michael.brasser@live.com>2017-10-24 14:35:53 +0000
commitecf6a2a3658fa17cd4c34f1dd5acc1904f8b4314 (patch)
treeca0d487899e9a38132260b0a27ee44f5421025c2 /tests/auto/qmltest/listview/tst_listview.qml
parentf23ee3368ea62930587358d2dff9ec2cb70668f1 (diff)
Allow assigning functions in ListElement
As an alternative to using eval with a string. This allows code such as: // model ListElement { action: function() { doSomething() } } // delegate MouseArea { onClicked: model.action() } [ChangeLog][ListModel] Support assignment of function declarations in ListElement, to allow for models with actions. Change-Id: I50d188ab30f43b2b8a47f48ceb4281d3ca55bd44 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qmltest/listview/tst_listview.qml')
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index 65f736f305..d5f67e2c41 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -151,6 +151,15 @@ Item {
}
}
+ ListView {
+ id: viewWithActionModel
+ property string funcResult
+ model: ListModel { ListElement { friendlyText: "one"; action: function(text) { viewWithActionModel.funcResult = text } } }
+ delegate: Item {
+ Component.onCompleted: action(model.friendlyText)
+ }
+ }
+
Component {
id: delegateModelAfterCreateComponent
Rectangle {
@@ -340,5 +349,9 @@ Item {
singleElementList.heightForDelegate = 200;
compare(singleElementList.contentHeightOnDelegateResize, 200);
}
+
+ function test_viewWithAction() {
+ compare(viewWithActionModel.funcResult, "one")
+ }
}
}