diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 01:16:33 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-20 01:16:33 (GMT) |
commit | a7506ce64ae9e80a202e0ffdaa86785d1d117c78 (patch) | |
tree | cd88679a8c075ad59b2a26d2661a632d00074f64 /src/declarative | |
parent | 91a2da396fb476401e3b2c55ca7672a8b462ceca (diff) | |
parent | 810074e299f7b2826fbfb8b224082f455eab94e5 (diff) | |
download | Qt-a7506ce64ae9e80a202e0ffdaa86785d1d117c78.zip Qt-a7506ce64ae9e80a202e0ffdaa86785d1d117c78.tar.gz Qt-a7506ce64ae9e80a202e0ffdaa86785d1d117c78.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsanchors.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlworkerscript_p.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlpixmapcache.cpp | 49 | ||||
-rw-r--r-- | src/declarative/util/qmlpixmapcache_p.h | 4 |
4 files changed, 34 insertions, 23 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/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/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<QString, QmlPixmapReply *> QmlPixmapReplyHash; +typedef QHash<QUrl, QmlPixmapReply *> 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); |