Commit fc88340c authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Setup QmlEnumValues even if enum is non-local.

Change-Id: Ib7a3621c14b6dfbdf36c75abac282c08f47e55ca
Reviewed-on: http://codereview.qt.nokia.com/559

Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 5118e75b
......@@ -41,6 +41,9 @@ FakeMetaEnum::FakeMetaEnum(const QString &name)
: m_name(name)
{}
bool FakeMetaEnum::isValid() const
{ return !m_name.isEmpty(); }
QString FakeMetaEnum::name() const
{ return m_name; }
......
......@@ -53,6 +53,8 @@ public:
FakeMetaEnum();
explicit FakeMetaEnum(const QString &name);
bool isValid() const;
QString name() const;
void setName(const QString &name);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment