summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlengine.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
commit6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb (patch)
tree68d6c4928dbd91d50e08b5b9d09a1178dffad092 /src/declarative/qml/qmlengine.cpp
parent5d8ce4c43c3c2816cd5dca03ddd429f26b96d34d (diff)
parent7e94543a9b013b6b1140137ba64406b74a363afc (diff)
downloadQt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.zip
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.gz
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.bz2
Merge branch 'kinetic-declarativeui' of git://scm.dev.nokia.troll.no/qt/kinetic into kinetic-declarativeui-qfx
Diffstat (limited to 'src/declarative/qml/qmlengine.cpp')
-rw-r--r--src/declarative/qml/qmlengine.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 943d812..db229ba 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -42,6 +42,7 @@
#include <QMetaProperty>
#include <private/qmlengine_p.h>
#include <private/qmlcontext_p.h>
+#include <private/qobject_p.h>
#ifdef QT_SCRIPTTOOLS_LIB
#include <QScriptEngineDebugger>
@@ -595,6 +596,38 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
return d->networkAccessManager;
}
+QmlContext *QmlEngine::contextForObject(const QObject *object)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if(priv->declarativeData) {
+ return static_cast<QmlContextPrivate::ContextData *>(priv->declarativeData)->context;
+ } else {
+ return 0;
+ }
+}
+
+QmlContext *qmlContext(const QObject *obj)
+{
+ return QmlEngine::contextForObject(obj);
+}
+
+QmlEngine *qmlEngine(const QObject *obj)
+{
+ QmlContext *context = QmlEngine::contextForObject(obj);
+ return context?context->engine():0;
+}
+
+
+void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(object);
+ if(priv->declarativeData) {
+ qWarning("QmlEngine::setContextForObject(): Object already has a QmlContext");
+ return;
+ }
+ priv->declarativeData = &context->d_func()->contextData;
+}
+
/*! \internal */
QScriptEngine *QmlEngine::scriptEngine()
{