summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecontextscriptclass.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-03 23:39:52 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-03 23:39:52 (GMT)
commit651f4336392f86cb5820e3e3cccdc56ec3a0efe8 (patch)
tree4435c8348f40a4a2be184063cc5a5197f61a650e /src/declarative/qml/qdeclarativecontextscriptclass.cpp
parentf53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13 (diff)
parent5ac068602871b78eb4b58634d58e6b8898acbf8d (diff)
downloadQt-651f4336392f86cb5820e3e3cccdc56ec3a0efe8.zip
Qt-651f4336392f86cb5820e3e3cccdc56ec3a0efe8.tar.gz
Qt-651f4336392f86cb5820e3e3cccdc56ec3a0efe8.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative/qml/qdeclarativecontextscriptclass.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 7deed0b..d6305d8 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -50,10 +50,11 @@
QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ ContextData() : overrideObject(0), isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
QDeclarativeGuard<QDeclarativeContext> context;
QDeclarativeGuard<QObject> scopeObject;
+ QObject *overrideObject;
bool isSharedContext;
QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
@@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr
return data->getContext(engine);
}
+QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ QObject *rv = data->overrideObject;
+ data->overrideObject = override;
+ return rv;
+}
+
QScriptClass::QueryFlags
QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
@@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &
if (!bindContext)
return 0;
+ QObject *overrideObject = ((ContextData *)object)->overrideObject;
+ if (overrideObject) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(overrideObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject |
+ QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = overrideObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
bool includeTypes = true;
while (bindContext) {
QScriptClass::QueryFlags rv =