diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 04:07:07 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 04:07:07 (GMT) |
commit | b2c73bd42242f3da15560ed49f20697a1280f86f (patch) | |
tree | eaf7e461f26f63f039ac89d64f17137634bb3c30 | |
parent | 28ec928bfd1bb4fb5bf6fb6a7445db4f52a36a0c (diff) | |
parent | 63fe6b6d3ff66067b8309c6111c49c6a41620e55 (diff) | |
download | Qt-b2c73bd42242f3da15560ed49f20697a1280f86f.zip Qt-b2c73bd42242f3da15560ed49f20697a1280f86f.tar.gz Qt-b2c73bd42242f3da15560ed49f20697a1280f86f.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 45 | ||||
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp | 22 | ||||
-rw-r--r-- | tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 5 |
3 files changed, 31 insertions, 41 deletions
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 48e8975..8836c06 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -223,7 +223,7 @@ static QString toLocalFileOrQrc(const QUrl& url) } typedef QHash<QUrl, QmlPixmapReply *> QmlPixmapReplyHash; -static QmlPixmapReplyHash qmlActivePixmapReplies; +Q_GLOBAL_STATIC(QmlPixmapReplyHash, qmlActivePixmapReplies); class QmlPixmapReplyPrivate : public QObjectPrivate { @@ -343,7 +343,7 @@ bool QmlPixmapReply::release(bool defer) Q_ASSERT(d->refCount > 0); --d->refCount; if (d->refCount == 0) { - qmlActivePixmapReplies.remove(d->url); + qmlActivePixmapReplies()->remove(d->url); if (defer) deleteLater(); else @@ -392,15 +392,15 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); if (QPixmapCache::find(strKey, pixmap)) { - if (iter != qmlActivePixmapReplies.end()) { + 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; } @@ -418,12 +418,12 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) */ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); - 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(url, engine->networkAccessManager()->get(req)); - iter = qmlActivePixmapReplies.insert(url, item); + iter = qmlActivePixmapReplies()->insert(url, item); } else { (*iter)->addRef(); } @@ -441,8 +441,8 @@ QmlPixmapReply *QmlPixmapCache::request(QmlEngine *engine, const QUrl &url) */ void QmlPixmapCache::cancel(const QUrl& url, QObject *obj) { - QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); - if (iter == qmlActivePixmapReplies.end()) + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); + if (iter == qmlActivePixmapReplies()->end()) return; QmlPixmapReply *reply = *iter; @@ -457,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/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index b43b699..0986d20 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -150,12 +150,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; - QTest::newRow("listprop1c") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.count}" << 3 << ""; QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; - - QTest::newRow("list-0-items") << "{append({'foo':[]});get(0).foo.count}" << 0 << ""; - QTest::newRow("list-1-item") << "{append({'foo':[1]});get(0).foo.count}" << 1 << ""; - QTest::newRow("list-multi-items") << "{append({'foo':[1,2,3]});get(0).foo.count}" << 3 << ""; } void tst_QmlListModel::dynamic() |