diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:12:16 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:12:16 (GMT) |
commit | 7b0d764f37fa4009dc1556666eb8a141164fb0e0 (patch) | |
tree | 3d5d1c0f5aadc2f3e2a5eccacd2fc2f32b21e385 /src/declarative/graphicsitems | |
parent | bac82138b76ac9f6a0603fa454f6660d139287d0 (diff) | |
parent | 16ae00c689faac5d7af312ae31d7f715dc6e0745 (diff) | |
download | Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.zip Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.gz Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative/graphicsitems')
4 files changed, 44 insertions, 21 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 420ed90..be9d8bd 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeborderimage_p_p.h" #include <qdeclarativeengine.h> +#include <qdeclarativeinfo.h> #include <QNetworkRequest> #include <QNetworkReply> @@ -218,7 +219,8 @@ void QDeclarativeBorderImage::load() } } else { QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); d->pendingPixmapCache = true; @@ -230,8 +232,10 @@ void QDeclarativeBorderImage::load() setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -338,7 +342,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl); d->sciPendingPixmapCache = true; @@ -367,8 +372,10 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -386,11 +393,18 @@ void QDeclarativeBorderImage::requestFinished() QSize impsize; if (d->url.path().endsWith(QLatin1String(".sci"))) { d->sciPendingPixmapCache = false; - QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + if (QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { + d->status = Error; + qmlInfo(this) << errorString; + } } else { d->pendingPixmapCache = false; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 3acafe8..c3f8195 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeimagebase_p_p.h" #include <qdeclarativeengine.h> +#include <qdeclarativeinfo.h> #include <qdeclarativepixmapcache_p.h> #include <QFile> @@ -154,7 +155,8 @@ void QDeclarativeImageBase::load() int reqwidth = d->sourcesize.width(); int reqheight = d->sourcesize.height(); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url, reqwidth, reqheight); d->pendingPixmapCache = true; @@ -191,6 +193,7 @@ void QDeclarativeImageBase::load() emit sourceSizeChanged(); } else { d->status = Error; + qmlInfo(this) << errorString; } d->progress = 1.0; emit statusChanged(d->status); @@ -210,8 +213,11 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; QSize impsize; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3b39fa4..a95c930 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -45,6 +45,7 @@ #include <qdeclarativeinfo.h> #include <qdeclarativepixmapcache_p.h> +#include <QSet> #include <QTextLayout> #include <QTextLine> #include <QTextDocument> @@ -75,14 +76,19 @@ protected: if (type == QTextDocument::ImageResource) { QPixmap pm; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, 0, true, 0, 0); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, false, 0, 0); if (status == QDeclarativePixmapReply::Ready) return pm; - if (status != QDeclarativePixmapReply::Error) { + if (status == QDeclarativePixmapReply::Error) { + if (!errors.contains(url)) { + errors.insert(url); + qmlInfo(parent()) << errorString; + } + } else { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); outstanding++; - static_cast<QDeclarativeText*>(parent())->reloadWithResources(); } } @@ -93,13 +99,17 @@ private slots: void requestFinished() { outstanding--; - static_cast<QDeclarativeText*>(parent())->reloadWithResources(); + if (outstanding == 0) + static_cast<QDeclarativeText*>(parent())->reloadWithResources(); } private: int outstanding; + static QSet<QUrl> errors; }; +QSet<QUrl> QTextDocumentWithImageResources::errors; + /*! \qmlclass Text QDeclarativeText \since 4.7 @@ -958,17 +968,13 @@ void QDeclarativeText::reloadWithResources() Q_D(QDeclarativeText); if (!d->richText) return; - if (resourcesLoading()!=0) - return; - emit resourcesLoadingChanged(); d->doc->setHtml(d->text); d->updateLayout(); d->markImgDirty(); } /*! - \qmlproperty int Text::resourcesLoading - This property is the number of resources (images) that are being loaded asynchronously. + Returns the number of resources (images) that are being loaded asynchronously. */ int QDeclarativeText::resourcesLoading() const { @@ -976,7 +982,6 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } - void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index fcad898..4fd5e3a 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -72,7 +72,6 @@ class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapModeChanged) Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? - Q_PROPERTY(int resourcesLoading READ resourcesLoading NOTIFY resourcesLoadingChanged) public: QDeclarativeText(QDeclarativeItem *parent=0); @@ -139,7 +138,7 @@ public: virtual void componentComplete(); - int resourcesLoading() const; + int resourcesLoading() const; // mainly for testing Q_SIGNALS: void textChanged(const QString &text); @@ -153,7 +152,6 @@ Q_SIGNALS: void wrapModeChanged(); void textFormatChanged(TextFormat textFormat); void elideModeChanged(TextElideMode mode); - void resourcesLoadingChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); |