diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-02-11 04:52:34 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-02-12 04:58:22 (GMT) |
commit | 1d2b1b31166e029e009f08877ef95f95e58a03a4 (patch) | |
tree | ae2ce1a9465f885ff6e24b583fe7330c74a9dd78 /src/declarative/qml/qmlengine.cpp | |
parent | 4b740bdf8cbaaf97541a821c28bae075067343d3 (diff) | |
download | Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.zip Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.tar.gz Qt-1d2b1b31166e029e009f08877ef95f95e58a03a4.tar.bz2 |
Cleanup public QmlMetaType API
Remove some unnecessary methods from the QmlMetaType class
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 372821e..cdbe5f3 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1085,9 +1085,10 @@ QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine) QScriptValue QmlEnginePrivate::scriptValueFromVariant(const QVariant &val) { - if (QmlMetaType::isObject(val.userType())) { - QObject *rv = *(QObject **)val.constData(); - return objectClass->newQObject(rv); + bool objOk; + QObject *obj = QmlMetaType::toQObject(val, &objOk); + if (objOk) { + return objectClass->newQObject(obj); } else { return qScriptValueFromValue(&scriptEngine, val); } @@ -1598,9 +1599,20 @@ bool QmlEnginePrivate::isQmlList(int t) const return m_qmlLists.contains(t) || QmlMetaType::isQmlList(t); } -bool QmlEnginePrivate::isObject(int t) +bool QmlEnginePrivate::isQObject(int t) { - return m_compositeTypes.contains(t) || QmlMetaType::isObject(t); + return m_compositeTypes.contains(t) || QmlMetaType::isQObject(t); +} + +QObject *QmlEnginePrivate::toQObject(const QVariant &v, bool *ok) const +{ + int t = v.userType(); + if (m_compositeTypes.contains(t)) { + if (ok) *ok = true; + return *(QObject **)(v.constData()); + } else { + return QmlMetaType::toQObject(v, ok); + } } int QmlEnginePrivate::qmlListType(int t) const @@ -1628,7 +1640,8 @@ const QMetaObject *QmlEnginePrivate::rawMetaObjectForType(int t) const if (iter != m_compositeTypes.end()) { return (*iter)->root; } else { - return QmlMetaType::rawMetaObjectForType(t); + QmlType *type = QmlMetaType::qmlType(t); + return type?type->baseMetaObject():0; } } @@ -1638,7 +1651,8 @@ const QMetaObject *QmlEnginePrivate::metaObjectForType(int t) const if (iter != m_compositeTypes.end()) { return (*iter)->root; } else { - return QmlMetaType::metaObjectForType(t); + QmlType *type = QmlMetaType::qmlType(t); + return type?type->metaObject():0; } } |