diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-02 09:31:12 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-05 02:40:50 (GMT) |
commit | 114adc64fe8deb7d59e608924355f64810f8fe64 (patch) | |
tree | 78c213ad20b7da939a0ea11c7afefa69c3e90fe6 /src/declarative/qml/qmlobjectscriptclass.cpp | |
parent | b4001abf71b3335cedfaf72ca3b7f25ea46be35c (diff) | |
download | Qt-114adc64fe8deb7d59e608924355f64810f8fe64.zip Qt-114adc64fe8deb7d59e608924355f64810f8fe64.tar.gz Qt-114adc64fe8deb7d59e608924355f64810f8fe64.tar.bz2 |
Fix attached properties/enums from ecmascript
Diffstat (limited to 'src/declarative/qml/qmlobjectscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 33fd409..7c7b13f 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -42,7 +42,9 @@ #include "qmlobjectscriptclass_p.h" #include <private/qmlengine_p.h> #include <private/qguard_p.h> +#include <private/qmlcontext_p.h> #include <private/qmldeclarativedata_p.h> +#include <private/qmltypenamescriptclass_p.h> QT_BEGIN_NAMESPACE @@ -94,10 +96,11 @@ QmlObjectScriptClass::queryProperty(Object *object, const Identifier &name, QScriptClass::QueryFlags QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, - QScriptClass::QueryFlags flags) + QScriptClass::QueryFlags flags, QueryMode mode) { Q_UNUSED(flags); lastData = 0; + lastTNData = 0; if (name == m_destroyId.identifier || name == m_toStringId.identifier) @@ -107,6 +110,22 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, return 0; QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine); + + if (mode == IncludeAttachedProperties) { + QmlContext *evalContext = enginePrivate->currentExpression->context(); + QmlContextPrivate *cp = QmlContextPrivate::get(evalContext); + // ### Check for attached properties + + if (cp->imports) { + QmlTypeNameCache::Data *data = cp->imports->data(name); + if (data) { + lastTNData = data; + return QScriptClass::HandlesReadAccess; + } + } + + } + QmlPropertyCache *cache = 0; QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj); if (ddata) @@ -150,7 +169,14 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); - if (lastData->flags & QmlPropertyCache::Data::IsFunction) { + if (lastTNData) { + + if (lastTNData->type) + return enginePriv->typeNameClass->newObject(obj, lastTNData->type); + else + return enginePriv->typeNameClass->newObject(obj, lastTNData->typeNamespace); + + } else if (lastData->flags & QmlPropertyCache::Data::IsFunction) { // ### Optimize QScriptValue sobj = scriptEngine->newQObject(obj); return sobj.property(toString(name)); |