summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcontextscriptclass.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-02 08:02:14 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-05 02:40:48 (GMT)
commit5b37c01aa721057ad0cbef16a79cf179e3c53934 (patch)
treebc09b0ffc8cfec17260b449634560082905be62d /src/declarative/qml/qmlcontextscriptclass.cpp
parenta712a6243be29dbfa49c3d1705c8b1babd8c7a1a (diff)
downloadQt-5b37c01aa721057ad0cbef16a79cf179e3c53934.zip
Qt-5b37c01aa721057ad0cbef16a79cf179e3c53934.tar.gz
Qt-5b37c01aa721057ad0cbef16a79cf179e3c53934.tar.bz2
Update to new QScriptDeclarativeClass API
Diffstat (limited to 'src/declarative/qml/qmlcontextscriptclass.cpp')
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp48
1 files changed, 6 insertions, 42 deletions
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
index d8ae4f0..4b149f7 100644
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ b/src/declarative/qml/qmlcontextscriptclass.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
-struct ContextData {
+struct ContextData : public QScriptDeclarativeClass::Object {
ContextData(QmlContext *c) : context(c) {}
QGuard<QmlContext> context;
};
@@ -69,11 +69,11 @@ QScriptValue QmlContextScriptClass::newContext(QmlContext *context)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
- return newObject(scriptEngine, this, (Object)new ContextData(context));
+ return newObject(scriptEngine, this, new ContextData(context));
}
QScriptClass::QueryFlags
-QmlContextScriptClass::queryProperty(const Object &object, const Identifier &name,
+QmlContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
{
Q_UNUSED(flags);
@@ -93,7 +93,6 @@ QmlContextScriptClass::queryProperty(const Object &object, const Identifier &nam
if (lastPropertyIndex != -1)
return QScriptClass::HandlesReadAccess;
- // ### Check for attached properties
if (ep->currentExpression && cp->imports && bindContext == ep->currentExpression->context()) {
QmlTypeNameCache::Data *data = cp->imports->data(name);
@@ -103,22 +102,6 @@ QmlContextScriptClass::queryProperty(const Object &object, const Identifier &nam
}
}
-#if 0
- QmlType *type = 0; ImportedNamespace *ns = 0;
- if (currentExpression && bindContext == currentExpression->context() &&
- propName.at(0).isUpper() && resolveType(bindContext->d_func()->imports, propName.toUtf8(), &type, 0, 0, 0, &ns)) {
-
- if (type || ns) {
- // Must be either an attached property, or an enum
- resolveData.object = bindContext->d_func()->defaultObjects.first();
- resolveData.type = type;
- resolveData.ns = ns;
- return QScriptClass::HandlesReadAccess;
- }
-
- }
-#endif
-
for (int ii = 0; ii < cp->defaultObjects.count(); ++ii) {
QScriptClass::QueryFlags rv =
ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags);
@@ -137,12 +120,10 @@ QmlContextScriptClass::queryProperty(const Object &object, const Identifier &nam
return 0;
}
-QScriptValue QmlContextScriptClass::property(const Object &object, const Identifier &name)
+QScriptValue QmlContextScriptClass::property(Object *object, const Identifier &name)
{
Q_UNUSED(object);
- Q_ASSERT(lastPropertyIndex != -1 || lastDefaultObject != -1);
-
QmlContext *bindContext = ((ContextData *)object)->context.data();
Q_ASSERT(bindContext);
@@ -150,18 +131,6 @@ QScriptValue QmlContextScriptClass::property(const Object &object, const Identif
QmlContextPrivate *cp = QmlContextPrivate::get(bindContext);
- // ### Check for attached properties
-#if 0
- if (resolveData.type || resolveData.ns) {
- QmlTypeNameBridge tnb = {
- resolveData.object,
- resolveData.type,
- resolveData.ns
- };
- return scriptEngine.newObject(typeNameClass, scriptEngine.newVariant(qVariantFromValue(tnb)));
- }
-#endif
-
if (lastData) {
if (lastData->type)
@@ -176,12 +145,7 @@ QScriptValue QmlContextScriptClass::property(const Object &object, const Identif
rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data());
} else {
QVariant value = cp->propertyValues.at(lastPropertyIndex);
- if (QmlMetaType::isObject(value.userType())) {
- rv = ep->objectClass->newQObject(QmlMetaType::toQObject(value));
- } else {
- // ### Shouldn't this be qScriptValueFromValue()
- rv = ep->scriptEngine.newVariant(value);
- }
+ return ep->scriptValueFromVariant(value);
}
ep->capturedProperties <<
@@ -200,7 +164,7 @@ QScriptValue QmlContextScriptClass::property(const Object &object, const Identif
}
}
-void QmlContextScriptClass::setProperty(const Object &object, const Identifier &name,
+void QmlContextScriptClass::setProperty(Object *object, const Identifier &name,
const QScriptValue &value)
{
Q_ASSERT(lastDefaultObject != -1);