diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-07-27 10:19:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-28 11:27:26 +0200 |
commit | 8fda8d16df9744b69a97020e3aae1ad40ff1f538 (patch) | |
tree | 62c35beb1b536a632f24afb402d3cb8908463747 /src | |
parent | 7edd8ee9a6885e57715c50be1dd402d9bd5118c8 (diff) |
Allow Qt enum values in ListElement.
Task-number: QTBUG-16547
Change-Id: Id215cea5cdaaaef8ff8a06a0bde682f95c91e416
Reviewed-by: Aaron Kennedy
Reviewed-on: http://codereview.qt.nokia.com/2227
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 0f0acba9a0..a0b1d8f176 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -2294,16 +2294,23 @@ bool QDeclarativeCompiler::testQualifiedEnumAssignment(const QMetaProperty &prop return true; } +struct StaticQtMetaObject : public QObject +{ + static const QMetaObject *get() + { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; } +}; + // Similar logic to above, but not knowing target property. int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const { int dot = script.indexOf('.'); if (dot > 0) { + const QByteArray &scope = script.left(dot); QDeclarativeType *type = 0; - unit->imports().resolveType(script.left(dot), &type, 0, 0, 0, 0); - if (!type) + unit->imports().resolveType(scope, &type, 0, 0, 0, 0); + if (!type && scope != "Qt") return -1; - const QMetaObject *mo = type->metaObject(); + const QMetaObject *mo = type ? type->metaObject() : StaticQtMetaObject::get(); const char *key = script.constData() + dot+1; int i = mo->enumeratorCount(); while (i--) { |