diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-03-11 08:21:15 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-03-11 08:21:15 (GMT) |
commit | 327c36acdba0422e93d99dc71cb3f5238d326977 (patch) | |
tree | d85c7b186af9a9324bb4acc5e36d630966876fee /src/declarative/qml/qdeclarativecontextscriptclass.cpp | |
parent | b9f8c1491550fe671d1809481ad7f70737034a3b (diff) | |
parent | 16e8cc808ae7087aadd95855c97d715941711b45 (diff) | |
download | Qt-327c36acdba0422e93d99dc71cb3f5238d326977.zip Qt-327c36acdba0422e93d99dc71cb3f5238d326977.tar.gz Qt-327c36acdba0422e93d99dc71cb3f5238d326977.tar.bz2 |
Merge remote branch 'origin/4.7' into 4.7-lighthouse
Conflicts:
src/gui/kernel/qapplication.cpp
src/gui/kernel/qapplication_p.h
src/gui/kernel/qwidget.cpp
Diffstat (limited to 'src/declarative/qml/qdeclarativecontextscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecontextscriptclass.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 7deed0b..5fcf4e2 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 = @@ -236,8 +262,9 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) } } - ep->capturedProperties << - QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + if (ep->captureProperties) + ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + return Value(scriptEngine, rv); } else if(lastDefaultObject != -1) { |