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:
@@ -41,6 +41,9 @@ FakeMetaEnum::FakeMetaEnum(const QString &name)
|
|||||||
: m_name(name)
|
: m_name(name)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
bool FakeMetaEnum::isValid() const
|
||||||
|
{ return !m_name.isEmpty(); }
|
||||||
|
|
||||||
QString FakeMetaEnum::name() const
|
QString FakeMetaEnum::name() const
|
||||||
{ return m_name; }
|
{ return m_name; }
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public:
|
|||||||
FakeMetaEnum();
|
FakeMetaEnum();
|
||||||
explicit FakeMetaEnum(const QString &name);
|
explicit FakeMetaEnum(const QString &name);
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void QmlObjectValue::processMembers(MemberProcessor *processor) const
|
|||||||
|
|
||||||
const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
||||||
{
|
{
|
||||||
const QString typeName = prop.typeName();
|
QString typeName = prop.typeName();
|
||||||
|
|
||||||
// ### Verify type resolving.
|
// ### Verify type resolving.
|
||||||
QmlObjectValue *objectValue = engine()->cppQmlTypes().typeByCppName(typeName);
|
QmlObjectValue *objectValue = engine()->cppQmlTypes().typeByCppName(typeName);
|
||||||
@@ -276,9 +276,15 @@ const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// might be an enum
|
// might be an enum
|
||||||
int enumIndex = _metaObject->enumeratorIndex(prop.typeName());
|
const QmlObjectValue *base = this;
|
||||||
if (enumIndex != -1) {
|
const QStringList components = typeName.split(QLatin1String("::"));
|
||||||
const FakeMetaEnum &metaEnum = _metaObject->enumerator(enumIndex);
|
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());
|
value = new QmlEnumValue(metaEnum, engine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,6 +350,15 @@ bool QmlObjectValue::isEnum(const QString &typeName) const
|
|||||||
return _metaObject->enumeratorIndex(typeName) != -1;
|
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
|
bool QmlObjectValue::isWritable(const QString &propertyName) const
|
||||||
{
|
{
|
||||||
for (const QmlObjectValue *it = this; it; it = it->prototype()) {
|
for (const QmlObjectValue *it = this; it; it = it->prototype()) {
|
||||||
|
|||||||
@@ -490,13 +490,16 @@ public:
|
|||||||
bool isListProperty(const QString &name) const;
|
bool isListProperty(const QString &name) const;
|
||||||
bool isWritable(const QString &propertyName) const;
|
bool isWritable(const QString &propertyName) const;
|
||||||
bool isPointer(const QString &propertyName) const;
|
bool isPointer(const QString &propertyName) const;
|
||||||
bool isEnum(const QString &typeName) const;
|
|
||||||
bool hasLocalProperty(const QString &typeName) const;
|
bool hasLocalProperty(const QString &typeName) const;
|
||||||
bool hasProperty(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;
|
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:
|
protected:
|
||||||
const Value *findOrCreateSignature(int index, const LanguageUtils::FakeMetaMethod &method,
|
const Value *findOrCreateSignature(int index, const LanguageUtils::FakeMetaMethod &method,
|
||||||
QString *methodName) const;
|
QString *methodName) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user