From 926155a45d40ba38f1f525751708d89438477bb9 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 1 Mar 2010 14:51:29 +1000 Subject: Fix reload() when keys are not specified, and add extra tests. --- src/declarative/util/qdeclarativexmllistmodel.cpp | 21 +++- .../tst_qdeclarativexmllistmodel.cpp | 130 ++++++++++++++------- 2 files changed, 108 insertions(+), 43 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 386df46..162a669 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -709,8 +709,24 @@ void QDeclarativeXmlListModel::reload() d->qmlXmlQuery.abort(); d->queryId = -1; - if (d->size < 0) + int count = d->size; + if (count < 0) d->size = 0; + bool hasKeys = false; + for (int i=0; iroleObjects.count(); i++) { + if (d->roleObjects[i]->isKey()) { + hasKeys = true; + break; + } + } + if (!hasKeys) { + d->data.clear(); + d->size = 0; + if (count > 0) { + emit itemsRemoved(0, count); + emit countChanged(); + } + } if (d->src.isEmpty() && d->xml.isEmpty()) return; @@ -782,9 +798,10 @@ void QDeclarativeXmlListModel::queryCompleted(int id, int size) d->data = d->qmlXmlQuery.modelData(); QList removed = d->qmlXmlQuery.removedItemRanges(); + QList inserted = d->qmlXmlQuery.insertedItemRanges(); + for (int i=0; i inserted = d->qmlXmlQuery.insertedItemRanges(); for (int i=0; i(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 9); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); QList roles; roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; - QHash data = listModel->data(3, roles); + QHash data = model->data(3, roles); QVERIFY(data.count() == 4); QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot")); QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog")); QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9); QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium")); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::missingFields() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model2.qml")); - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 9); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); QList roles; roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3 << Qt::UserRole + 4; - QHash data = listModel->data(5, roles); + QHash data = model->data(5, roles); QVERIFY(data.count() == 5); QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("")); QCOMPARE(data.value(Qt::UserRole+4).toString(), QLatin1String("")); - data = listModel->data(7, roles); + data = model->data(7, roles); QVERIFY(data.count() == 5); QCOMPARE(data.value(Qt::UserRole+2).toString(), QLatin1String("")); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::cdata() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 5); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); QList roles; roles << Qt::UserRole + 2; - QHash data = listModel->data(2, roles); + QHash data = model->data(2, roles); QVERIFY(data.count() == 1); QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String(""))); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::attributes() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 5); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); QList roles; roles << Qt::UserRole; - QHash data = listModel->data(2, roles); + QHash data = model->data(2, roles); QVERIFY(data.count() == 1); QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::roles() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 9); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); - QList roles = listModel->roles(); + QList roles = model->roles(); QCOMPARE(roles.count(), 4); - QCOMPARE(listModel->toString(roles.at(0)), QLatin1String("name")); - QCOMPARE(listModel->toString(roles.at(1)), QLatin1String("type")); - QCOMPARE(listModel->toString(roles.at(2)), QLatin1String("age")); - QCOMPARE(listModel->toString(roles.at(3)), QLatin1String("size")); + QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); + QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); + QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); + QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::roleErrors() @@ -207,13 +208,13 @@ void tst_qdeclarativexmllistmodel::roleErrors() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml")); QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5) An XmlRole query must not start with '/'").toUtf8().constData()); //### make sure we receive all expected warning messages. - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 9); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); QList roles; roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; - QHash data = listModel->data(3, roles); + QHash data = model->data(3, roles); QVERIFY(data.count() == 4); //### should any of these return valid values? @@ -224,21 +225,47 @@ void tst_qdeclarativexmllistmodel::roleErrors() QEXPECT_FAIL("", "QT-2456", Continue); QCOMPARE(data.value(Qt::UserRole+3), QVariant()); - delete listModel; + delete model; } void tst_qdeclarativexmllistmodel::uniqueRoleNames() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml")); QTest::ignoreMessage(QtWarningMsg, QString("QML XmlRole (" + QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5) \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); - QDeclarativeXmlListModel *listModel = qobject_cast(component.create()); - QVERIFY(listModel != 0); - QTRY_COMPARE(listModel->count(), 9); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); - QList roles = listModel->roles(); + QList roles = model->roles(); QCOMPARE(roles.count(), 1); - delete listModel; + delete model; +} + +void tst_qdeclarativexmllistmodel::reload() +{ + // If no keys are used, the model should be rebuilt from scratch when + // reload() is called. + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeXmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + model->reload(); + QTRY_COMPARE(spyCount.count(), 1); + QTRY_COMPARE(spyInsert.count(), 1); + QTRY_COMPARE(spyRemove.count(), 1); + + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 9); + + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 9); } void tst_qdeclarativexmllistmodel::useKeys() @@ -368,12 +395,33 @@ void tst_qdeclarativexmllistmodel::useKeys_data() << (QList() << qMakePair(0, 1)) << (QList() << qMakePair(0, 1)); - QTest::newRow("add and remove simultaneously") + QTest::newRow("add and remove simultaneously, in different spots") << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) << modelData << (QList() << qMakePair(1, 1)) << (QList() << qMakePair(0, 1) << qMakePair(2,2)); + + QTest::newRow("insert at start, remove at end i.e. rss feed") + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(1, 2)); + + QTest::newRow("remove at start, insert at end") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << (QList() << qMakePair(0, 2)); + + QTest::newRow("all data has changed") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(0, 2)); } void tst_qdeclarativexmllistmodel::noKeysValueChanges() -- cgit v0.12 From 8095b3074a47ff317cafdce5e8a8f955bf8c97fa Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 1 Mar 2010 14:57:51 +1000 Subject: Make compile following QDeclarativePropertyChanges. --- .../tst_qdeclarativeproperty.cpp | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index a3aefe3..c72c9e7 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -466,7 +466,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() } { - QDeclarativeMetaProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); + QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); QGuard binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -488,7 +488,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::SignalProperty); + QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -496,19 +496,19 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyCategory(), QDeclarativeMetaProperty::InvalidProperty); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(prop.binding() == 0); - QVERIFY(prop.setBinding(binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(prop.signalExpression() == 0); - QVERIFY(prop.setSignalExpression(expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); - QVERIFY(prop.signalExpression() == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } @@ -764,7 +764,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() } { - QDeclarativeMetaProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); + QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); QGuard binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext())); binding->setTarget(prop); @@ -786,7 +786,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); QCOMPARE(prop.connectNotifier(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); - QCOMPARE(prop.type(), QDeclarativeMetaProperty::SignalProperty); + QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); @@ -794,19 +794,19 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.isResettable(), false); QCOMPARE(prop.isValid(), true); QCOMPARE(prop.object(), &dobject); - QCOMPARE(prop.propertyCategory(), QDeclarativeMetaProperty::InvalidProperty); + QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(prop.binding() == 0); - QVERIFY(prop.setBinding(binding) == 0); + QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding) == 0); QVERIFY(binding == 0); - QVERIFY(prop.signalExpression() == 0); - QVERIFY(prop.setSignalExpression(expression) == 0); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); - QVERIFY(prop.signalExpression() == expression); + QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); - QCOMPARE(prop.valueTypeCoreIndex(), -1); + QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; } @@ -845,13 +845,13 @@ void tst_qdeclarativeproperty::name() { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onPropertyWithNotifyChanged"); + QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal")); } { QObject o; - QDeclarativeMetaProperty p(&o, "onPropertyWithNotifyChanged"); + QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.name(), QString()); } @@ -948,11 +948,11 @@ void tst_qdeclarativeproperty::read() // Automatic signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onPropertyWithNotifyChanged"); + QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == p.setSignalExpression(new QDeclarativeExpression())); - QVERIFY(0 != p.signalExpression()); + QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); } @@ -1066,15 +1066,15 @@ void tst_qdeclarativeproperty::write() // Automatic signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onPropertyWithNotifyChanged"); + QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == p.setSignalExpression(new QDeclarativeExpression())); - QVERIFY(0 != p.signalExpression()); + QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression())); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 != p.signalExpression()); + QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p)); } // Value-type property @@ -1210,7 +1210,7 @@ void tst_qdeclarativeproperty::reset() // Automatic signal property { PropertyObject o; - QDeclarativeMetaProperty p(&o, "onPropertyWithNotifyChanged"); + QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.isResettable(), false); QCOMPARE(p.reset(), false); -- cgit v0.12 From 1c9908d6d31326dbeed9d23b4f3ac3c8446d91b5 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 1 Mar 2010 15:34:59 +1000 Subject: Fix position of image in detail view in flickr-mobile --- demos/declarative/flickr/mobile/ImageDetails.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 8749b4c..c51371c 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -66,10 +66,7 @@ Flipable { Image { id: bigImage; source: container.photoUrl; scale: slider.value - // Center image if it is smaller than the flickable area. - x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0 - y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0 - smooth: !flickable.moving + anchors.centerIn: parent; smooth: !flickable.moving onStatusChanged : { // Default scale shows the entire image. if (status == 1 && width != 0) { -- cgit v0.12 From bec22cbfb255da34afe99c4cec30fc13cc40d900 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 1 Mar 2010 16:30:29 +1000 Subject: Small optimizations. --- src/declarative/graphicsitems/qdeclarativeflickable_p_p.h | 6 ++++-- src/declarative/graphicsitems/qdeclarativeitem.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index 1ff4f92..ad7a04d 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -134,8 +134,10 @@ public: Velocity(QDeclarativeFlickablePrivate *p) : parent(p) {} virtual void setValue(qreal v) { - QDeclarativeTimeLineValue::setValue(v); - parent->updateVelocity(); + if (v != value()) { + QDeclarativeTimeLineValue::setValue(v); + parent->updateVelocity(); + } } QDeclarativeFlickablePrivate *parent; }; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index c282808..f48c761 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1730,8 +1730,12 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, if (d->_anchors) d->_anchors->d_func()->updateMe(); - if (transformOrigin() != QDeclarativeItem::TopLeft) - setTransformOriginPoint(d->computeTransformOrigin()); + if (transformOrigin() != QDeclarativeItem::TopLeft + && (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) { + QPointF origin = d->computeTransformOrigin(); + if (transformOriginPoint() != origin) + setTransformOriginPoint(origin); + } if (newGeometry.x() != oldGeometry.x()) emit xChanged(); -- cgit v0.12 From d5449c3cc85624b50e6a6fcabc6ad96b79d4bd0a Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 1 Mar 2010 16:31:32 +1000 Subject: Keep image centered in ImageDetails. --- demos/declarative/flickr/mobile/ImageDetails.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 8749b4c..55061db 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -66,9 +66,7 @@ Flipable { Image { id: bigImage; source: container.photoUrl; scale: slider.value - // Center image if it is smaller than the flickable area. - x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0 - y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0 + anchors.centerIn: parent smooth: !flickable.moving onStatusChanged : { // Default scale shows the entire image. -- cgit v0.12