summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlpropertycache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qmlpropertycache.cpp')
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 89d66b1..7efeb82 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -54,7 +54,6 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p)
propType = qMetaTypeId<QVariant>();
coreIndex = p.propertyIndex();
notifyIndex = p.notifySignalIndex();
- name = QString::fromUtf8(p.name());
if (p.isConstant())
flags |= Data::IsConstant;
@@ -80,11 +79,6 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p)
void QmlPropertyCache::Data::load(const QMetaMethod &m)
{
- name = QString::fromUtf8(m.signature());
- int parenIdx = name.indexOf(QLatin1Char('('));
- Q_ASSERT(parenIdx != -1);
- name = name.left(parenIdx);
-
coreIndex = m.methodIndex();
flags |= Data::IsFunction;
}
@@ -224,4 +218,31 @@ QmlPropertyCache::property(const QString &str) const
return stringCache.value(str);
}
+QString QmlPropertyCache::Data::name(QObject *object)
+{
+ if (!object)
+ return QString();
+
+ return name(object->metaObject());
+}
+
+QString QmlPropertyCache::Data::name(const QMetaObject *metaObject)
+{
+ if (!metaObject || coreIndex == -1)
+ return QString();
+
+ if (flags & IsFunction) {
+ QMetaMethod m = metaObject->method(coreIndex);
+
+ QString name = QString::fromUtf8(m.signature());
+ int parenIdx = name.indexOf(QLatin1Char('('));
+ if (parenIdx != -1)
+ name = name.left(parenIdx);
+ return name;
+ } else {
+ QMetaProperty p = metaObject->property(coreIndex);
+ return QString::fromUtf8(p.name());
+ }
+}
+
QT_END_NAMESPACE