QmlObjectValue: Add convenience functionality.

Added
hasLocalProperty()
hasProperty()
keysForEnum()

Reviewed-by: Christian Kamm
This commit is contained in:
Christian Kamm
2010-11-11 10:46:19 +01:00
parent ba39234627
commit 806c8a563d
2 changed files with 31 additions and 0 deletions

View File

@@ -963,6 +963,25 @@ bool QmlObjectValue::isPointer(const QString &propertyName) const
return false;
}
bool QmlObjectValue::hasLocalProperty(const QString &typeName) const
{
int idx = _metaObject->propertyIndex(typeName);
if (idx == -1)
return false;
return true;
}
bool QmlObjectValue::hasProperty(const QString &propertyName) const
{
for (const FakeMetaObject *iter = _metaObject; iter; iter = iter->superClass()) {
int propIdx = iter->propertyIndex(propertyName);
if (propIdx != -1) {
return true;
}
}
return false;
}
bool QmlObjectValue::enumContainsKey(const QString &enumName, const QString &enumKeyName) const
{
int idx = _metaObject->enumeratorIndex(enumName);
@@ -976,6 +995,15 @@ bool QmlObjectValue::enumContainsKey(const QString &enumName, const QString &enu
return false;
}
QStringList QmlObjectValue::keysForEnum(const QString &enumName) const
{
int idx = _metaObject->enumeratorIndex(enumName);
if (idx == -1)
return QStringList();
const FakeMetaEnum &fme = _metaObject->enumerator(idx);
return fme.keys();
}
// Returns true if this object is in a package or if there is an object that
// has this one in its prototype chain and is itself in a package.
bool QmlObjectValue::hasChildInPackage() const