diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-26 05:18:54 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-26 05:18:54 (GMT) |
commit | f16d60399b996b09b779d2a719b5e6e6b9a80903 (patch) | |
tree | 6fdb5a62ad77a5b59b57b65f284acf909a549139 /src/declarative/graphicsitems/qdeclarativeimagebase.cpp | |
parent | ca90afcf32d9ba083b34f5cef3c7bde6300844f4 (diff) | |
download | Qt-f16d60399b996b09b779d2a719b5e6e6b9a80903.zip Qt-f16d60399b996b09b779d2a719b5e6e6b9a80903.tar.gz Qt-f16d60399b996b09b779d2a719b5e6e6b9a80903.tar.bz2 |
sourceWidth/sourceHeight -> sourceSize
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeimagebase.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeimagebase.cpp | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 3b75a85..b8d67ff 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -116,41 +116,23 @@ void QDeclarativeImageBase::setSource(const QUrl &url) load(); } -void QDeclarativeImageBase::setSourceWidth(int w) +void QDeclarativeImageBase::setSourceSize(const QSize& size) { Q_D(QDeclarativeImageBase); - if (d->sourcewidth == w) + if (d->sourcesize == size) return; - d->sourcewidth = w; + d->sourcesize = size; emit sourceSizeChanged(); if (isComponentComplete()) load(); } -int QDeclarativeImageBase::sourceWidth() const +QSize QDeclarativeImageBase::sourceSize() const { Q_D(const QDeclarativeImageBase); - return d->sourcewidth <= 0 ? implicitWidth() : d->sourcewidth; + return d->sourcesize.isValid() ? d->sourcesize : QSize(implicitWidth(),implicitHeight()); } -void QDeclarativeImageBase::setSourceHeight(int h) -{ - Q_D(QDeclarativeImageBase); - if (d->sourceheight == h) - return; - d->sourceheight = h; - emit sourceSizeChanged(); - if (isComponentComplete()) - load(); -} - -int QDeclarativeImageBase::sourceHeight() const -{ - Q_D(const QDeclarativeImageBase); - return d->sourceheight <= 0 ? implicitHeight() : d->sourceheight; -} - - void QDeclarativeImageBase::load() { Q_D(QDeclarativeImageBase); @@ -169,8 +151,8 @@ void QDeclarativeImageBase::load() update(); } else { d->status = Loading; - int reqwidth = d->sourcewidth; - int reqheight = d->sourceheight; + int reqwidth = d->sourcesize.width(); + int reqheight = d->sourcesize.width(); QSize impsize; QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { @@ -205,7 +187,7 @@ void QDeclarativeImageBase::load() if (d->status == Loading) d->status = Ready; - if (d->sourcewidth <= 0 || d->sourceheight <= 0) + if (!d->sourcesize.isValid()) emit sourceSizeChanged(); } else { d->status = Error; @@ -228,7 +210,7 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; QSize impsize; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcewidth, d->sourceheight) != QDeclarativePixmapReply::Ready) + if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) d->status = Error; setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); @@ -238,7 +220,7 @@ void QDeclarativeImageBase::requestFinished() d->progress = 1.0; emit statusChanged(d->status); emit progressChanged(1.0); - if (d->sourcewidth <= 0 || d->sourceheight <= 0) + if (!d->sourcesize.isValid()) emit sourceSizeChanged(); pixmapChange(); update(); |