aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/testtypes.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-08-08 14:53:45 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-09 05:57:33 +0200
commitf09517bd9c907698a05ee92ccf158a06db3340b8 (patch)
treec8bae3c214f06c1293d3f0706960f7139dc999db /tests/auto/qml/qqmlecmascript/testtypes.cpp
parent9c2ab7af355d0132af771f8784e42c13d1f49183 (diff)
Ensure that copy sequences can be passed as arguments
Previously, automatic conversion from JS array to sequence copy resource was not performed in the case where the array was passed as a parameter to a QObject function invocation. This commit adds code to check if the parameter type is a sequence type - and if so, and if the value is a variantlist, we convert it to a sequence of the appropriate type. Change-Id: I3cc3e2f95604bc71d1d8d237e1acffa1e03b78ba Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index 9669e371de..a0bdbb6156 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -225,35 +225,17 @@ public:
{
return stringList;
}
- Q_INVOKABLE QList<int> integers(QVariant v) const
+ Q_INVOKABLE QList<int> integers(QList<int> v) const
{
- QList<int> intList;
- QList<QVariant> vList = v.toList();
- for (int i=0 ; i < vList.size() ; ++i) {
- int iv = vList[i].toInt();
- intList.append(iv);
- }
- return intList;
+ return v;
}
- Q_INVOKABLE QList<qreal> reals(QVariant v) const
+ Q_INVOKABLE QList<qreal> reals(QList<qreal> v) const
{
- QList<qreal> realList;
- QList<QVariant> vList = v.toList();
- for (int i=0 ; i < vList.size() ; ++i) {
- qreal fv = vList[i].toReal();
- realList.append(fv);
- }
- return realList;
+ return v;
}
- Q_INVOKABLE QList<bool> bools(QVariant v) const
+ Q_INVOKABLE QList<bool> bools(QList<bool> v) const
{
- QList<bool> boolList;
- QList<QVariant> vList = v.toList();
- for (int i=0 ; i < vList.size() ; ++i) {
- bool bv = vList[i].toBool();
- boolList.append(bv);
- }
- return boolList;
+ return v;
}
};