summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp1
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h2
-rw-r--r--src/declarative/fx/qfximage.cpp33
-rw-r--r--src/declarative/fx/qfximage.h5
-rw-r--r--src/declarative/fx/qfximage_p.h4
-rw-r--r--src/declarative/qml/qmlcompiler.cpp5
6 files changed, 46 insertions, 4 deletions
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index e154268..7f0029d 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -645,6 +645,7 @@ void QmlXmlListModel::queryCompleted(int id, int size)
if (size > 0) {
d->data = d->qmlXmlQuery.modelData();
emit itemsInserted(0, d->size);
+ emit countChanged();
}
}
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index d9871ab..3b6ffb4 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -98,6 +98,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
public:
@@ -130,6 +131,7 @@ public:
signals:
void statusChanged(Status);
void progressChanged(qreal progress);
+ void countChanged();
public Q_SLOTS:
void reload();
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index f57782c..d19d620 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -301,9 +301,22 @@ void QFxImage::paintContents(QPainter &p)
p.restore();
} else if (!d->scaleGrid || d->scaleGrid->isNull()) {
if (width() != pix.width() || height() != pix.height()) {
+ qreal widthScale = width() / qreal(pix.width());
+ qreal heightScale = height() / qreal(pix.height());
+
QTransform scale;
- scale.scale(width() / qreal(pix.width()),
- height() / qreal(pix.height()));
+
+ if (d->preserveAspect) {
+ if (widthScale < heightScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * pix.height()) / 2);
+ } else if(heightScale < widthScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * pix.width()) / 2, 0);
+ }
+ }
+
+ scale.scale(widthScale, heightScale);
QTransform old = p.transform();
p.setWorldTransform(scale * old);
p.drawPixmap(0, 0, pix);
@@ -448,6 +461,22 @@ QUrl QFxImage::source() const
return d->url;
}
+bool QFxImage::preserveAspect() const
+{
+ Q_D(const QFxImage);
+ return d->preserveAspect;
+}
+
+void QFxImage::setPreserveAspect(bool p)
+{
+ Q_D(QFxImage);
+
+ if (p == d->preserveAspect)
+ return;
+ d->preserveAspect = p;
+ update();
+}
+
void QFxImage::setSource(const QUrl &url)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 378c20d..7b3445c 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -65,7 +65,7 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
Q_PROPERTY(bool tile READ isTiled WRITE setTiled)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false)
Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
-
+ Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect);
public:
QFxImage(QFxItem *parent=0);
~QFxImage();
@@ -85,6 +85,9 @@ public:
Status status() const;
qreal progress() const;
+ bool preserveAspect() const;
+ void setPreserveAspect(bool);
+
QUrl source() const;
virtual void setSource(const QUrl &url);
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index e4a3a90..de7ebe6 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -69,7 +69,8 @@ class QFxImagePrivate : public QFxItemPrivate
public:
QFxImagePrivate()
: scaleGrid(0), tiled(false), smooth(false), opaque(false),
- status(QFxImage::Idle), sciReply(0), progress(0.0)
+ preserveAspect(false), status(QFxImage::Idle), sciReply(0),
+ progress(0.0)
{
}
@@ -92,6 +93,7 @@ public:
bool tiled : 1;
bool smooth : 1;
bool opaque : 1;
+ bool preserveAspect : 1;
QFxImage::Status status;
QUrl url;
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 220c464..138be29 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -903,6 +903,11 @@ void QmlCompiler::genComponent(QmlParser::Object *obj)
genObject(root);
+ QmlInstruction def;
+ init.line = 0;
+ def.type = QmlInstruction::SetDefault;
+ output->bytecode << def;
+
output->bytecode[count - 1].createComponent.count =
output->bytecode.count() - count;