diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-06-14 10:18:45 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-21 04:13:17 +0200 |
commit | 09b605ddcc33575316211156ff5979aa92e7e1fd (patch) | |
tree | 61141ac9323983a1ddbbad7602db0687b8d11a5c /tests | |
parent | 58f3f50c43f021ebfe214062562498d02b6f2071 (diff) |
Enable literal Qt enum assignment to enum properties.
Assigning Qt global enums to enum properties was previously handled as
a binding, rather than a literal assignment.
Change-Id: If6bb65f63b34f4e10c0636221ddadb11f7025735
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/testtypes.h | 27 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 6 |
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml index 28a340128d..697278e0b7 100644 --- a/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml +++ b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml @@ -2,6 +2,8 @@ import Test 1.0 MyTypeObject { flagProperty: "FlagVal1 | FlagVal3" enumProperty: "EnumVal2" + qtEnumProperty: Qt.RichText + mirroredEnumProperty: Qt.AlignHCenter stringProperty: "Hello World!" uintProperty: 10 intProperty: -19 @@ -25,4 +27,10 @@ MyTypeObject { urlProperty: "main.qml?with%3cencoded%3edata" objectProperty: MyTypeObject { intProperty: 8 } + + property bool qtEnumTriggeredChange: false + onQtEnumPropertyChanged: qtEnumTriggeredChange = true + + property bool mirroredEnumTriggeredChange: false + onMirroredEnumPropertyChanged: mirroredEnumTriggeredChange = true } diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index b601a545de..f84e42f231 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -209,6 +209,7 @@ class MyTypeObject : public QObject { Q_OBJECT Q_ENUMS(MyEnum) + Q_ENUMS(MyMirroredEnum) Q_FLAGS(MyFlags) Q_PROPERTY(QString id READ id WRITE setId) @@ -217,6 +218,8 @@ class MyTypeObject : public QObject Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty NOTIFY flagPropertyChanged) Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty NOTIFY enumPropertyChanged) Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty) + Q_PROPERTY(Qt::TextFormat qtEnumProperty READ qtEnumProperty WRITE setQtEnumProperty NOTIFY qtEnumPropertyChanged) + Q_PROPERTY(MyMirroredEnum mirroredEnumProperty READ mirroredEnumProperty WRITE setMirroredEnumProperty NOTIFY mirroredEnumPropertyChanged) Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged) Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty NOTIFY uintPropertyChanged) Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) @@ -298,6 +301,28 @@ public: return EnumVal1; } + Qt::TextFormat qtEnumPropertyValue; + Qt::TextFormat qtEnumProperty() const { + return qtEnumPropertyValue; + } + void setQtEnumProperty(Qt::TextFormat v) { + qtEnumPropertyValue = v; + emit qtEnumPropertyChanged(); + } + + enum MyMirroredEnum { + MirroredEnumVal1 = Qt::AlignLeft, + MirroredEnumVal2 = Qt::AlignRight, + MirroredEnumVal3 = Qt::AlignHCenter }; + MyMirroredEnum mirroredEnumPropertyValue; + MyMirroredEnum mirroredEnumProperty() const { + return mirroredEnumPropertyValue; + } + void setMirroredEnumProperty(MyMirroredEnum v) { + mirroredEnumPropertyValue = v; + emit mirroredEnumPropertyChanged(); + } + QString stringPropertyValue; QString stringProperty() const { return stringPropertyValue; @@ -515,6 +540,8 @@ signals: void objectPropertyChanged(); void flagPropertyChanged(); void enumPropertyChanged(); + void qtEnumPropertyChanged(); + void mirroredEnumPropertyChanged(); void stringPropertyChanged(); void uintPropertyChanged(); void intPropertyChanged(); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index c6b0dd66cc..e32489635b 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -579,6 +579,8 @@ void tst_qqmllanguage::assignBasicTypes() QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->qtEnumProperty(), Qt::RichText); + QCOMPARE(object->mirroredEnumProperty(), MyTypeObject::MirroredEnumVal3); QCOMPARE(object->stringProperty(), QString("Hello World!")); QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); @@ -606,6 +608,10 @@ void tst_qqmllanguage::assignBasicTypes() MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty()); QVERIFY(child != 0); QCOMPARE(child->intProperty(), 8); + + //these used to go via script. Ensure they no longer do + QCOMPARE(object->property("qtEnumTriggeredChange").toBool(), false); + QCOMPARE(object->property("mirroredEnumTriggeredChange").toBool(), false); } // Test edge case type assignments |