diff options
author | Chris Adams <christopher.adams@nokia.com> | 2011-07-14 15:40:30 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-18 09:25:04 +0200 |
commit | eaf52673ef38b4d7a14f9fb9f258d8f1c6097401 (patch) | |
tree | a607ea443865da0668029725283009cf17d2ffe1 /tests/auto/declarative/qdeclarativelanguage | |
parent | 36767e3fe1f0038441ae06ef5b5e1cb19a3738fa (diff) |
Add support for a vector4d type in QML
QVector4D is a value-type which is supported but was not able to be
constructed using a Qt object function. This commit allows properties
of vector4d type to be constructed, and adds a function to the global
Qt object and adds unit tests to ensure that it behaves correctly.
Task-number: QTBUG-18559
Change-Id: I96509a4f496b644d20fdb1d977d0afe430d89e13
Reviewed-on: http://codereview.qt.nokia.com/1626
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
4 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml index 9fe0ded459..2313499d19 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml @@ -21,6 +21,7 @@ MyTypeObject { boolProperty: true variantProperty: "Hello World!" vectorProperty: "10,1,2.2" + vector4Property: "10,1,2.2,2.3" urlProperty: "main.qml" objectProperty: MyTypeObject { intProperty: 8 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml index de476ae47f..f6f9a139dc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -12,5 +12,6 @@ QtObject { property variant test9: String("#FF008800") property variant test10: true property variant test11: false + property variant test12: "100,100,100,100" } diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index c11bc33eab..dad0e23ae3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -47,6 +47,7 @@ #include <QtGui/qmatrix.h> #include <QtGui/qcolor.h> #include <QtGui/qvector3d.h> +#include <QtGui/qvector4d.h> #include <QtDeclarative/qdeclarative.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtDeclarative/qdeclarativeparserstatus.h> @@ -224,6 +225,7 @@ class MyTypeObject : public QObject Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property) Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) @@ -442,6 +444,14 @@ public: vectorPropertyValue = v; } + QVector4D vector4PropertyValue; + QVector4D vector4Property() const { + return vector4PropertyValue; + } + void setVector4Property(const QVector4D &v) { + vector4PropertyValue = v; + } + QUrl urlPropertyValue; QUrl urlProperty() const { return urlPropertyValue; diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index dfaf3d1618..5e9bc418cc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -564,6 +564,7 @@ void tst_qdeclarativelanguage::assignBasicTypes() QCOMPARE(object->boolProperty(), true); QCOMPARE(object->variantProperty(), QVariant("Hello World!")); QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3)); QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); QVERIFY(object->objectProperty() != 0); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty()); @@ -610,6 +611,7 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QCOMPARE(object->property("test9").userType(), (int)QVariant::String); QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); QVERIFY(object->property("test1") == QVariant(1)); QVERIFY(object->property("test2") == QVariant((double)1.7)); @@ -622,6 +624,7 @@ void tst_qdeclarativelanguage::assignLiteralToVariant() QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); QVERIFY(object->property("test10") == QVariant(bool(true))); QVERIFY(object->property("test11") == QVariant(bool(false))); + QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); delete object; } |