summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-03-26 05:18:54 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-03-26 05:18:54 (GMT)
commitf16d60399b996b09b779d2a719b5e6e6b9a80903 (patch)
tree6fdb5a62ad77a5b59b57b65f284acf909a549139 /src
parentca90afcf32d9ba083b34f5cef3c7bde6300844f4 (diff)
downloadQt-f16d60399b996b09b779d2a719b5e6e6b9a80903.zip
Qt-f16d60399b996b09b779d2a719b5e6e6b9a80903.tar.gz
Qt-f16d60399b996b09b779d2a719b5e6e6b9a80903.tar.bz2
sourceWidth/sourceHeight -> sourceSize
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h3
4 files changed, 24 insertions, 47 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 8b93063..23a2350 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -267,28 +267,27 @@ qreal QDeclarativeImage::paintedHeight() const
*/
/*!
- \qmlproperty int Image::sourceWidth
- \qmlproperty int Image::sourceHeight
+ \qmlproperty QSize Image::sourceSize
- These properties are the size of the loaded image, in pixels.
+ This properties is the size of the loaded image, in pixels.
- If you set these properties explicitly, you can to control the storage
+ If you set this property explicitly, you can to control the storage
used by a loaded image. The image will be scaled down if its intrinsic size
- is greater than these values.
+ is greater than this value.
Unlike setting the width and height properties, which merely scale the painting
- of the image, these properties affect the number of pixels stored.
+ of the image, this property affects the number of pixels stored.
- \e{Changing these properties dynamically will lead to the image source being reloaded,
+ \e{Changing this property dynamically will lead to the image source being reloaded,
potentially even from the network if it is not in the disk cache.}
- If the source is an instrinsically scalable image (eg. SVG), these properties
- determine the size of the loaded image regardless of intrinsic size. You should
- avoid changing these properties dynamically - rendering an SVG is \e slow compared
+ If the source is an instrinsically scalable image (eg. SVG), this property
+ determines the size of the loaded image regardless of intrinsic size. You should
+ avoid changing this property dynamically - rendering an SVG is \e slow compared
to an image.
If the source is a non-scalable image (eg. JPEG), the loaded image will
- be no greater than these properties specify. For some formats (currently only JPEG),
+ be no greater than this property specifies. For some formats (currently only JPEG),
the whole image will never actually be loaded into memory.
*/
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();
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index 2653d0a..6c84456 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -59,8 +59,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageBase : public QDeclarativeItem
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
- Q_PROPERTY(int sourceWidth READ sourceWidth WRITE setSourceWidth NOTIFY sourceSizeChanged)
- Q_PROPERTY(int sourceHeight READ sourceHeight WRITE setSourceHeight NOTIFY sourceSizeChanged)
+ Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)
public:
~QDeclarativeImageBase();
@@ -74,10 +73,8 @@ public:
bool asynchronous() const;
void setAsynchronous(bool);
- void setSourceWidth(int);
- int sourceWidth() const;
- void setSourceHeight(int);
- int sourceHeight() const;
+ void setSourceSize(const QSize&);
+ QSize sourceSize() const;
Q_SIGNALS:
void sourceChanged(const QUrl &);
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
index cced228..de8c93a 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
@@ -68,7 +68,6 @@ public:
QDeclarativeImageBasePrivate()
: status(QDeclarativeImageBase::Null),
progress(0.0),
- sourcewidth(0), sourceheight(0),
pendingPixmapCache(false),
async(false)
{
@@ -79,7 +78,7 @@ public:
QDeclarativeImageBase::Status status;
QUrl url;
qreal progress;
- int sourcewidth, sourceheight;
+ QSize sourcesize;
bool pendingPixmapCache : 1;
bool async : 1;
};