diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 04:08:18 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 04:08:18 (GMT) |
commit | c895bdc921630f769c616a145167bac9a300f72d (patch) | |
tree | 160ec625536838dda944372e83f286e8c22910bd /src/declarative | |
parent | eebbdab90153126fa3c72c527084980f9a4c580f (diff) | |
parent | b2c73bd42242f3da15560ed49f20697a1280f86f (diff) | |
download | Qt-c895bdc921630f769c616a145167bac9a300f72d.zip Qt-c895bdc921630f769c616a145167bac9a300f72d.tar.gz Qt-c895bdc921630f769c616a145167bac9a300f72d.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
21 files changed, 236 insertions, 101 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 4948633..93055fc 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Anchors,QmlGraphicsAnchors) +QML_DEFINE_NOCREATE_TYPE(QmlGraphicsAnchors) //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 1b35442..b3a3905 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -119,7 +119,9 @@ HEADERS += \ $$PWD/qmlvaluetypescriptclass_p.h \ $$PWD/qmltypenamescriptclass_p.h \ $$PWD/qmllistscriptclass_p.h \ - $$PWD/qmlworkerscript_p.h + $$PWD/qmlworkerscript_p.h \ + $$PWD/qmlscriptclass_p.h \ + $$PWD/qmlguard_p.h QT += sql diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp index 5b602b9..da57452 100644 --- a/src/declarative/qml/qmlbindingvme.cpp +++ b/src/declarative/qml/qmlbindingvme.cpp @@ -383,8 +383,14 @@ inline void subscribe(QObject *o, int notifyIndex, QmlBindingVME::Config::Subscription *s = config->subscriptions + subIndex; if (o != s->source || notifyIndex != s->notifyIndex) { if (s->source) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(s->source, s->notifyIndex, config->target, config->targetSlot + subIndex); +#else + // QTBUG-6781 + QMetaObject::disconnect(s->source, s->notifyIndex, + config->target, config->targetSlot + subIndex); +#endif s->source = o; s->notifyIndex = notifyIndex; if (s->source && s->notifyIndex != -1) diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 71b77d5..eecc611 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -77,7 +77,7 @@ struct ContextData : public QScriptDeclarativeClass::Object { via QtScript. */ QmlContextScriptClass::QmlContextScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), lastScopeObject(0), lastContext(0), lastData(0), lastPropertyIndex(-1), lastDefaultObject(-1) { } @@ -196,7 +196,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje return 0; } -QmlContextScriptClass::Value +QmlContextScriptClass::ScriptValue QmlContextScriptClass::property(Object *object, const Identifier &name) { Q_UNUSED(object); diff --git a/src/declarative/qml/qmlcontextscriptclass_p.h b/src/declarative/qml/qmlcontextscriptclass_p.h index f652371..f98d44f 100644 --- a/src/declarative/qml/qmlcontextscriptclass_p.h +++ b/src/declarative/qml/qmlcontextscriptclass_p.h @@ -54,16 +54,13 @@ // #include "qmltypenamecache_p.h" - -#include <QtScript/qscriptclass.h> - -#include <private/qscriptdeclarativeclass_p.h> +#include "qmlscriptclass_p.h" QT_BEGIN_NAMESPACE class QmlEngine; class QmlContext; -class QmlContextScriptClass : public QScriptDeclarativeClass +class QmlContextScriptClass : public QmlScriptClass { public: QmlContextScriptClass(QmlEngine *); @@ -77,7 +74,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index b5e7c2d..122eb07 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -64,6 +64,7 @@ #include "qmlglobal_p.h" #include "qmlworkerscript_p.h" #include "qmlcomponent_p.h" +#include "qmlscriptclass_p.h" #include <qfxperf_p_p.h> @@ -1056,9 +1057,8 @@ QVariant QmlEnginePrivate::scriptValueToVariant(const QScriptValue &val) } } -QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) -: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)), - engine(bindengine) +QmlScriptClass::QmlScriptClass(QScriptEngine *engine) +: QScriptDeclarativeClass(engine) { } diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 490a4ce..13c1afb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -308,16 +308,6 @@ public: }; -class QmlScriptClass : public QScriptClass -{ -public: - QmlScriptClass(QmlEngine *); - - static QVariant toVariant(QmlEngine *, const QScriptValue &); -protected: - QmlEngine *engine; -}; - QT_END_NAMESPACE #endif // QMLENGINE_P_H diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index cd6f582..c00e552 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -641,9 +641,16 @@ void QmlExpressionPrivate::clearGuards() for (int ii = 0; ii < data->guardListLength; ++ii) { if (data->guardList[ii].data()) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } } @@ -684,9 +691,16 @@ void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::Captu } } else if(data->guardList[ii].data() && !data->guardList[ii].isDuplicate) { // Cache miss +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } /* else { // Cache miss, but nothing to do @@ -732,9 +746,16 @@ void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::Captu for (int ii = properties.count(); ii < data->guardListLength; ++ii) { if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } } diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index 4b8b056..441c410 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -53,7 +53,7 @@ struct ListData : public QScriptDeclarativeClass::Object { }; QmlListScriptClass::QmlListScriptClass(QmlEngine *e) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(e)), engine(e) +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(e)), engine(e) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); Q_UNUSED(scriptEngine); @@ -100,7 +100,7 @@ QmlListScriptClass::queryProperty(Object *object, const Identifier &name, } } -QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identifier &name) +QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h index 43ca929..0c6c5b2 100644 --- a/src/declarative/qml/qmllistscriptclass_p.h +++ b/src/declarative/qml/qmllistscriptclass_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include <private/qscriptdeclarativeclass_p.h> +#include <private/qmlscriptclass_p.h> QT_BEGIN_NAMESPACE class QmlEngine; -class QmlListScriptClass : public QScriptDeclarativeClass +class QmlListScriptClass : public QmlScriptClass { public: QmlListScriptClass(QmlEngine *); @@ -70,7 +70,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); private: PersistentIdentifier m_lengthId; diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 485d240..86f0afc 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -69,7 +69,10 @@ struct ObjectData : public QScriptDeclarativeClass::Object { QtScript for QML. */ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), methods(bindEngine), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) + methods(bindEngine), +#endif lastData(0), engine(bindEngine) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -192,13 +195,13 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, return 0; } -QmlObjectScriptClass::Value +QmlObjectScriptClass::ScriptValue QmlObjectScriptClass::property(Object *object, const Identifier &name) { return property(toQObject(object), name); } -QmlObjectScriptClass::Value +QmlObjectScriptClass::ScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -226,10 +229,15 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) if (lastData->flags & QmlPropertyCache::Data::IsVMEFunction) { return Value(scriptEngine, ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex)); } else { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) // Uncomment to use QtScript method call logic // QScriptValue sobj = scriptEngine->newQObject(obj); // return Value(scriptEngine, sobj.property(toString(name))); return Value(scriptEngine, methods.newMethod(obj, lastData)); +#else + QScriptValue sobj = scriptEngine->newQObject(obj); + return Value(scriptEngine, sobj.property(toString(name))); +#endif } } else { if (enginePriv->captureProperties && !(lastData->flags & QmlPropertyCache::Data::IsConstant)) { @@ -428,6 +436,8 @@ QStringList QmlObjectScriptClass::propertyNames(Object *object) return cache->propertyNames(); } +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) + struct MethodData : public QScriptDeclarativeClass::Object { MethodData(QObject *o, const QmlPropertyCache::Data &d) : object(o), data(d) {} @@ -665,5 +675,7 @@ QmlObjectMethodScriptClass::Value QmlObjectMethodScriptClass::call(Object *o, QS return Value(); } +#endif + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h index 025e491..36ba44f 100644 --- a/src/declarative/qml/qmlobjectscriptclass_p.h +++ b/src/declarative/qml/qmlobjectscriptclass_p.h @@ -56,9 +56,7 @@ #include "qmlpropertycache_p.h" #include "qmltypenamecache_p.h" -#include <QtScript/qscriptclass.h> - -#include <private/qscriptdeclarativeclass_p.h> +#include <private/qmlscriptclass_p.h> QT_BEGIN_NAMESPACE @@ -67,6 +65,7 @@ class QScriptContext; class QScriptEngine; class QmlContext; +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) class Q_AUTOTEST_EXPORT QmlObjectMethodScriptClass : public QScriptDeclarativeClass { public: @@ -80,8 +79,9 @@ protected: private: QmlEngine *engine; }; +#endif -class Q_AUTOTEST_EXPORT QmlObjectScriptClass : public QScriptDeclarativeClass +class Q_AUTOTEST_EXPORT QmlObjectScriptClass : public QmlScriptClass { public: QmlObjectScriptClass(QmlEngine *); @@ -101,7 +101,9 @@ public: QScriptClass::QueryFlags flags, QmlContext *evalContext, QueryHints hints = 0); - Value property(QObject *, const Identifier &); + + ScriptValue property(QObject *, const Identifier &); + void setProperty(QObject *, const Identifier &name, const QScriptValue &, QmlContext *evalContext = 0); virtual QStringList propertyNames(Object *); @@ -110,13 +112,15 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual bool isQObject() const; virtual QObject *toQObject(Object *, bool *ok = 0); private: +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QmlObjectMethodScriptClass methods; +#endif QmlTypeNameCache::Data *lastTNData; QmlPropertyCache::Data *lastData; diff --git a/src/declarative/qml/qmlscriptclass_p.h b/src/declarative/qml/qmlscriptclass_p.h new file mode 100644 index 0000000..4fee59d --- /dev/null +++ b/src/declarative/qml/qmlscriptclass_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLSCRIPTCLASS_P_H +#define QMLSCRIPTCLASS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtScript/qscriptclass.h> +#include <private/qscriptdeclarativeclass_p.h> + +QT_BEGIN_NAMESPACE + +class QmlEngine; +class QmlScriptClass : public QScriptDeclarativeClass +{ +public: + QmlScriptClass(QScriptEngine *); + + static QVariant toVariant(QmlEngine *, const QScriptValue &); + +#if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) + struct Value : public QScriptValue { + Value() : QScriptValue() {} + Value(QScriptEngine *engine, int v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, uint v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, bool v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, double v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, float v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, const QString &v) : QScriptValue(engine, v) {} + Value(QScriptEngine *, const QScriptValue &v) : QScriptValue(v) {} + }; + + typedef QScriptValue ScriptValue; +#else + typedef Value QScriptValue; +#endif +}; + +QT_END_NAMESPACE + +#endif // QMLSCRIPTCLASS_P_H diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp index 3c57223..14c8652 100644 --- a/src/declarative/qml/qmltypenamescriptclass.cpp +++ b/src/declarative/qml/qmltypenamescriptclass.cpp @@ -62,7 +62,7 @@ struct TypeNameData : public QScriptDeclarativeClass::Object { }; QmlTypeNameScriptClass::QmlTypeNameScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), object(0), type(0) { } @@ -139,7 +139,8 @@ QmlTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name, return 0; } -QmlTypeNameScriptClass::Value QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) +QmlTypeNameScriptClass::ScriptValue +QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) { QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); diff --git a/src/declarative/qml/qmltypenamescriptclass_p.h b/src/declarative/qml/qmltypenamescriptclass_p.h index 702930f..cf8c621 100644 --- a/src/declarative/qml/qmltypenamescriptclass_p.h +++ b/src/declarative/qml/qmltypenamescriptclass_p.h @@ -56,14 +56,14 @@ #include <QtScript/qscriptclass.h> -#include <private/qscriptdeclarativeclass_p.h> +#include <private/qmlscriptclass_p.h> QT_BEGIN_NAMESPACE class QmlEngine; class QmlType; class QmlTypeNameCache; -class QmlTypeNameScriptClass : public QScriptDeclarativeClass +class QmlTypeNameScriptClass : public QmlScriptClass { public: QmlTypeNameScriptClass(QmlEngine *); @@ -77,7 +77,7 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp index 90de6e7..5e222a1 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass.cpp +++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp @@ -53,7 +53,7 @@ struct QmlValueTypeReference : public QScriptDeclarativeClass::Object { }; QmlValueTypeScriptClass::QmlValueTypeScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) { } @@ -98,7 +98,7 @@ QmlValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name, return rv; } -QmlValueTypeScriptClass::Value QmlValueTypeScriptClass::property(Object *obj, const Identifier &) +QmlValueTypeScriptClass::ScriptValue QmlValueTypeScriptClass::property(Object *obj, const Identifier &) { QmlValueTypeReference *ref = static_cast<QmlValueTypeReference *>(obj); diff --git a/src/declarative/qml/qmlvaluetypescriptclass_p.h b/src/declarative/qml/qmlvaluetypescriptclass_p.h index 9214987..09af967 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass_p.h +++ b/src/declarative/qml/qmlvaluetypescriptclass_p.h @@ -52,15 +52,15 @@ // // We mean it. // -#include <QtScript/qscriptclass.h> -#include <private/qscriptdeclarativeclass_p.h> + +#include <private/qmlscriptclass_p.h> QT_BEGIN_NAMESPACE class QmlEngine; class QmlValueType; -class QmlValueTypeScriptClass : public QScriptDeclarativeClass +class QmlValueTypeScriptClass : public QmlScriptClass { public: QmlValueTypeScriptClass(QmlEngine *); @@ -70,7 +70,7 @@ public: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual QVariant toVariant(Object *, bool *ok = 0); diff --git a/src/declarative/qml/qmlworkerscript_p.h b/src/declarative/qml/qmlworkerscript_p.h index 1c70f2d..f0ef7c9 100644 --- a/src/declarative/qml/qmlworkerscript_p.h +++ b/src/declarative/qml/qmlworkerscript_p.h @@ -118,7 +118,7 @@ class QmlWorkerListModelAgent; class QmlWorkerListModel : public QListModelInterface { Q_OBJECT - Q_PROPERTY(int count READ count NOTIFY countChanged); + Q_PROPERTY(int count READ count NOTIFY countChanged) public: QmlWorkerListModel(QObject * = 0); diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index cd4a120..de6ee2e 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -265,7 +265,6 @@ struct ModelNode QmlListModel *modelCache; ModelObject *objectCache; - bool isArray; }; QT_END_NAMESPACE @@ -281,7 +280,6 @@ void ModelNode::setObjectValue(const QScriptValue& valuemap) { ModelNode *value = new ModelNode; QScriptValue v = it.value(); if (v.isArray()) { - value->isArray = true; value->setListValue(v); } else { value->values << v.toVariant(); @@ -298,7 +296,6 @@ void ModelNode::setListValue(const QScriptValue& valuelist) { ModelNode *value = new ModelNode; QScriptValue v = it.value(); if (v.isArray()) { - value->isArray = true; value->setListValue(v); } else if (v.isObject()) { value->setObjectValue(v); @@ -370,29 +367,27 @@ QVariant QmlListModel::valueForNode(ModelNode *node) const { QObject *rv = 0; - if (node->isArray) { + if (!node->properties.isEmpty()) { + // Object + rv = node->object(this); + } else if (node->values.count() == 0) { + // Invalid + return QVariant(); + } else if (node->values.count() == 1) { + // Value + QVariant &var = node->values[0]; + ModelNode *valueNode = qvariant_cast<ModelNode *>(var); + if (valueNode) { + if (!valueNode->properties.isEmpty()) + rv = valueNode->object(this); + else + rv = valueNode->model(this); + } else { + return var; + } + } else if (node->values.count() > 1) { // List rv = node->model(this); - } else { - if (!node->properties.isEmpty()) { - // Object - rv = node->object(this); - } else if (node->values.count() == 0) { - // Invalid - return QVariant(); - } else if (node->values.count() == 1) { - // Value - QVariant &var = node->values[0]; - ModelNode *valueNode = qvariant_cast<ModelNode *>(var); - if (valueNode) { - if (!valueNode->properties.isEmpty()) - rv = valueNode->object(this); - else - rv = valueNode->model(this); - } else { - return var; - } - } } if (rv) @@ -938,7 +933,7 @@ static void dump(ModelNode *node, int ind) } ModelNode::ModelNode() -: modelCache(0), objectCache(0), isArray(false) +: modelCache(0), objectCache(0) { } diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 6f36cad..8836c06 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -60,6 +60,13 @@ QT_BEGIN_NAMESPACE +#if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) +static uint qHash(const QUrl &u) +{ + return qHash(u.toString()); +} +#endif + class QmlImageReader : public QThread { Q_OBJECT @@ -215,20 +222,20 @@ static QString toLocalFileOrQrc(const QUrl& url) return r; } -typedef QHash<QString, QmlPixmapReply *> QmlPixmapReplyHash; -static QmlPixmapReplyHash qmlActivePixmapReplies; +typedef QHash<QUrl, QmlPixmapReply *> QmlPixmapReplyHash; +Q_GLOBAL_STATIC(QmlPixmapReplyHash, qmlActivePixmapReplies); class QmlPixmapReplyPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlPixmapReply) public: - QmlPixmapReplyPrivate(const QString &url, QNetworkReply *r) - : QObjectPrivate(), refCount(1), urlKey(url), reply(r), status(QmlPixmapReply::Loading) { + QmlPixmapReplyPrivate(const QUrl &u, QNetworkReply *r) + : QObjectPrivate(), refCount(1), url(u), reply(r), status(QmlPixmapReply::Loading) { } int refCount; - QString urlKey; + QUrl url; QNetworkReply *reply; QPixmap pixmap; // ensure reference to pixmap so QPixmapCache does not discard QImage image; @@ -236,8 +243,8 @@ public: }; -QmlPixmapReply::QmlPixmapReply(const QString &key, QNetworkReply *reply) - : QObject(*new QmlPixmapReplyPrivate(key, reply), 0) +QmlPixmapReply::QmlPixmapReply(const QUrl &url, QNetworkReply *reply) + : QObject(*new QmlPixmapReplyPrivate(url, reply), 0) { Q_D(QmlPixmapReply); @@ -265,14 +272,22 @@ QmlPixmapReply::~QmlPixmapReply() delete d->reply; } +const QUrl &QmlPixmapReply::url() const +{ + Q_D(const QmlPixmapReply); + return d->url; +} + void QmlPixmapReply::networkRequestDone() { Q_D(QmlPixmapReply); if (d->reply->error()) { d->pixmap = QPixmap(); d->status = Error; - QPixmapCache::insert(d->urlKey, d->pixmap); - qWarning() << "Network error loading" << d->urlKey << d->reply->errorString(); + QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100)); + QString strKey = QString::fromLatin1(key.constData(), key.count()); + QPixmapCache::insert(strKey, d->pixmap); + qWarning() << "Network error loading" << d->url << d->reply->errorString(); emit finished(); } else { qmlImageReader()->read(this); @@ -291,9 +306,11 @@ bool QmlPixmapReply::event(QEvent *event) d->pixmap = QPixmap::fromImage(de->image); d->image = QImage(); } else { - qWarning() << "Error decoding" << d->urlKey; + qWarning() << "Error decoding" << d->url; } - QPixmapCache::insert(d->urlKey, d->pixmap); + QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100)); + QString strKey = QString::fromLatin1(key.constData(), key.count()); + QPixmapCache::insert(strKey, d->pixmap); emit finished(); } return true; @@ -326,7 +343,7 @@ bool QmlPixmapReply::release(bool defer) Q_ASSERT(d->refCount > 0); --d->refCount; if (d->refCount == 0) { - qmlActivePixmapReplies.remove(d->urlKey); + qmlActivePixmapReplies()->remove(d->url); if (defer) deleteLater(); else @@ -373,16 +390,17 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) } #endif - QString key = url.toString(); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(key); - if (QPixmapCache::find(key, pixmap)) { - if (iter != qmlActivePixmapReplies.end()) { + QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); + QString strKey = QString::fromLatin1(key.constData(), key.count()); + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (QPixmapCache::find(strKey, pixmap)) { + if (iter != qmlActivePixmapReplies()->end()) { status = (*iter)->status(); (*iter)->release(); } else { status = pixmap->isNull() ? QmlPixmapReply::Error : QmlPixmapReply::Ready; } - } else if (iter != qmlActivePixmapReplies.end()) { + } else if (iter != qmlActivePixmapReplies()->end()) { status = QmlPixmapReply::Loading; } @@ -400,13 +418,12 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) */ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) { - QString key = url.toString(); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(key); - if (iter == qmlActivePixmapReplies.end()) { + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter == qmlActivePixmapReplies()->end()) { QNetworkRequest req(url); req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - QmlPixmapReply *item = new QmlPixmapReply(key, engine->networkAccessManager()->get(req)); - iter = qmlActivePixmapReplies.insert(key, item); + QmlPixmapReply *item = new QmlPixmapReply(url, engine->networkAccessManager()->get(req)); + iter = qmlActivePixmapReplies()->insert(url, item); } else { (*iter)->addRef(); } @@ -424,9 +441,8 @@ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) */ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) { - QString key = url.toString(); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(key); - if (iter == qmlActivePixmapReplies.end()) + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter == qmlActivePixmapReplies()->end()) return; QmlPixmapReply *reply = *iter; @@ -441,7 +457,7 @@ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) */ int QmlPixmapCache::pendingRequests() { - return qmlActivePixmapReplies.count(); + return qmlActivePixmapReplies()->count(); } #include <qmlpixmapcache.moc> diff --git a/src/declarative/util/qmlpixmapcache_p.h b/src/declarative/util/qmlpixmapcache_p.h index 4dcafcf..711e902 100644 --- a/src/declarative/util/qmlpixmapcache_p.h +++ b/src/declarative/util/qmlpixmapcache_p.h @@ -59,12 +59,14 @@ class Q_DECLARATIVE_EXPORT QmlPixmapReply : public QObject { Q_OBJECT public: - QmlPixmapReply(const QString &key, QNetworkReply *reply); + QmlPixmapReply(const QUrl &url, QNetworkReply *reply); ~QmlPixmapReply(); enum Status { Ready, Error, Unrequested, Loading, Decoding }; Status status() const; + const QUrl &url() const; + Q_SIGNALS: void finished(); void downloadProgress(qint64, qint64); |