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>
This commit is contained in:
parent
7edd8ee9a6
commit
8fda8d16df
|
@ -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--) {
|
||||
|
|
|
@ -171,6 +171,10 @@ void tst_qdeclarativelistmodel::static_types_data()
|
|||
QTest::newRow("enum")
|
||||
<< "ListElement { foo: Text.AlignHCenter }"
|
||||
<< QVariant(double(QSGText::AlignHCenter));
|
||||
|
||||
QTest::newRow("Qt enum")
|
||||
<< "ListElement { foo: Qt.AlignBottom }"
|
||||
<< QVariant(double(Qt::AlignBottom));
|
||||
}
|
||||
|
||||
void tst_qdeclarativelistmodel::static_types()
|
||||
|
|
Loading…
Reference in New Issue