forked from qt-creator/qt-creator
QmlJS: Setup QmlEnumValues even if enum is non-local.
Change-Id: Ib7a3621c14b6dfbdf36c75abac282c08f47e55ca Reviewed-on: http://codereview.qt.nokia.com/559 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -227,7 +227,7 @@ void QmlObjectValue::processMembers(MemberProcessor *processor) const
|
||||
|
||||
const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
||||
{
|
||||
const QString typeName = prop.typeName();
|
||||
QString typeName = prop.typeName();
|
||||
|
||||
// ### Verify type resolving.
|
||||
QmlObjectValue *objectValue = engine()->cppQmlTypes().typeByCppName(typeName);
|
||||
@@ -276,10 +276,16 @@ const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
||||
}
|
||||
|
||||
// might be an enum
|
||||
int enumIndex = _metaObject->enumeratorIndex(prop.typeName());
|
||||
if (enumIndex != -1) {
|
||||
const FakeMetaEnum &metaEnum = _metaObject->enumerator(enumIndex);
|
||||
value = new QmlEnumValue(metaEnum, engine());
|
||||
const QmlObjectValue *base = this;
|
||||
const QStringList components = typeName.split(QLatin1String("::"));
|
||||
if (components.size() == 2) {
|
||||
base = engine()->cppQmlTypes().typeByCppName(components.first());
|
||||
typeName = components.last();
|
||||
}
|
||||
if (base) {
|
||||
const FakeMetaEnum &metaEnum = base->getEnum(typeName);
|
||||
if (metaEnum.isValid())
|
||||
value = new QmlEnumValue(metaEnum, engine());
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -344,6 +350,15 @@ bool QmlObjectValue::isEnum(const QString &typeName) const
|
||||
return _metaObject->enumeratorIndex(typeName) != -1;
|
||||
}
|
||||
|
||||
FakeMetaEnum QmlObjectValue::getEnum(const QString &typeName) const
|
||||
{
|
||||
const int index = _metaObject->enumeratorIndex(typeName);
|
||||
if (index == -1)
|
||||
return FakeMetaEnum();
|
||||
|
||||
return _metaObject->enumerator(index);
|
||||
}
|
||||
|
||||
bool QmlObjectValue::isWritable(const QString &propertyName) const
|
||||
{
|
||||
for (const QmlObjectValue *it = this; it; it = it->prototype()) {
|
||||
|
||||
@@ -490,13 +490,16 @@ public:
|
||||
bool isListProperty(const QString &name) const;
|
||||
bool isWritable(const QString &propertyName) const;
|
||||
bool isPointer(const QString &propertyName) const;
|
||||
bool isEnum(const QString &typeName) const;
|
||||
bool hasLocalProperty(const QString &typeName) const;
|
||||
bool hasProperty(const QString &typeName) const;
|
||||
bool enumContainsKey(const QString &enumName, const QString &enumKeyName) const;
|
||||
QStringList keysForEnum(const QString &enumName) const;
|
||||
bool hasChildInPackage() const;
|
||||
|
||||
LanguageUtils::FakeMetaEnum getEnum(const QString &typeName) const;
|
||||
|
||||
// deprecated
|
||||
bool isEnum(const QString &typeName) const;
|
||||
QStringList keysForEnum(const QString &enumName) const;
|
||||
bool enumContainsKey(const QString &enumName, const QString &enumKeyName) const;
|
||||
protected:
|
||||
const Value *findOrCreateSignature(int index, const LanguageUtils::FakeMetaMethod &method,
|
||||
QString *methodName) const;
|
||||
|
||||
Reference in New Issue
Block a user