From e91d32adb1a9dc4060ff65c9256ee1cbeed0f69e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 19 Jan 2010 16:15:48 +0100 Subject: Fix examples/declarative/plugins example --- examples/declarative/plugins/plugins.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml index 97c1b69..dbeb001 100644 --- a/examples/declarative/plugins/plugins.qml +++ b/examples/declarative/plugins/plugins.qml @@ -1,4 +1,5 @@ -import com.nokia.TimeExample 1.0 +import com.nokia.TimeExample 1.0 // import types from the plugin +import 'files' // import types from the 'files' directory Clock { // this class is defined in QML (files/Clock.qml) -- cgit v0.12 From 6ed0a9f4fe48bc5a3cca4cb00c1c0cd4b4bac7bb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 20 Jan 2010 09:05:58 +1000 Subject: Remove unnecessary semicolon --- src/declarative/qml/qmlworkerscript_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v0.12 From 5f62ae4520886dec8b3f077bc19b3527cae4eaec Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 20 Jan 2010 09:33:04 +1000 Subject: Make QmlGraphicsAnchors a NOCREATE type. Prevents the creation benchmark from qFataling. --- src/declarative/graphicsitems/qmlgraphicsanchors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- cgit v0.12 From 43d59c9c6efcf9a9dc65549a48969a66a5979367 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 20 Jan 2010 10:06:19 +1000 Subject: Avoid using QUrl::toString() in QmlPixmapCache. --- src/declarative/util/qmlpixmapcache.cpp | 49 +++++++++++++++++++-------------- src/declarative/util/qmlpixmapcache_p.h | 4 ++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 6f36cad..130d646 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -215,7 +215,7 @@ static QString toLocalFileOrQrc(const QUrl& url) return r; } -typedef QHash QmlPixmapReplyHash; +typedef QHash QmlPixmapReplyHash; static QmlPixmapReplyHash qmlActivePixmapReplies; class QmlPixmapReplyPrivate : public QObjectPrivate @@ -223,12 +223,12 @@ 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 +236,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 +265,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 +299,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 +336,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,9 +383,10 @@ 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)) { + 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(); @@ -400,13 +411,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); + 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,8 +434,7 @@ 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); + QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies.find(url); if (iter == qmlActivePixmapReplies.end()) return; 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); -- cgit v0.12 From 810074e299f7b2826fbfb8b224082f455eab94e5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 20 Jan 2010 10:18:20 +1000 Subject: Add support for aliases in test http server. Makes it possible to request many files with unique names, but serve a single file. --- tests/auto/declarative/shared/testhttpserver.cpp | 16 +++++++++++++++- tests/auto/declarative/shared/testhttpserver.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index 215f3c3..6c9d849 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -106,6 +106,15 @@ bool TestHTTPServer::serveDirectory(const QString &dir, Mode mode) return true; } +/* + Add an alias, so that if filename is requested and does not exist, + alias may be returned. +*/ +void TestHTTPServer::addAlias(const QString &filename, const QString &alias) +{ + aliases.insert(filename, alias); +} + bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body) { m_hasFailed = false; @@ -226,7 +235,12 @@ bool TestHTTPServer::reply(QTcpSocket *socket, const QByteArray &fileName) Mode mode = dirs.at(ii).second; QString dirFile = dir + QLatin1String("/") + QLatin1String(fileName); - + + if (!QFile::exists(dirFile)) { + if (aliases.contains(fileName)) + dirFile = dir + QLatin1String("/") + aliases.value(fileName); + } + QFile file(dirFile); if (file.open(QIODevice::ReadOnly)) { diff --git a/tests/auto/declarative/shared/testhttpserver.h b/tests/auto/declarative/shared/testhttpserver.h index 62fe7b4..2a8709f 100644 --- a/tests/auto/declarative/shared/testhttpserver.h +++ b/tests/auto/declarative/shared/testhttpserver.h @@ -61,6 +61,8 @@ public: bool wait(const QUrl &expect, const QUrl &reply, const QUrl &body); bool hasFailed() const; + void addAlias(const QString &filename, const QString &aliasName); + private slots: void newConnection(); void disconnected(); @@ -80,6 +82,8 @@ private: QByteArray bodyData; bool m_hasFailed; + QHash aliases; + QTcpServer server; }; -- cgit v0.12