From 8fbff4dffd53546e4c3acecd0a9700a7ad970c83 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 13:48:33 +1000 Subject: Test more ListView. --- tests/auto/declarative/listview/tst_listview.cpp | 94 ++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp index 6bf1080..b8f87b7 100644 --- a/tests/auto/declarative/listview/tst_listview.cpp +++ b/tests/auto/declarative/listview/tst_listview.cpp @@ -70,6 +70,8 @@ private slots: void qAbstractItemModel_moved(); void enforceRange(); + void spacing(); + void sections(); private: template void items(); @@ -264,6 +266,13 @@ void tst_QmlGraphicsListView::items() listview->decrementCurrentIndex(); QCOMPARE(listview->currentIndex(), 0); + // set an empty model and confirm that items are destroyed + T model2; + ctxt->setContextProperty("testModel", &model2); + + int itemCount = findItems(viewport, "wrapper").count(); + QVERIFY(itemCount == 0); + delete canvas; } @@ -632,6 +641,91 @@ void tst_QmlGraphicsListView::enforceRange() delete canvas; } +void tst_QmlGraphicsListView::spacing() +{ + QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QVERIFY(listview != 0); + + QmlGraphicsItem *viewport = listview->viewport(); + QVERIFY(viewport != 0); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->y() == i*20); + } + + listview->setSpacing(10); + + // Confirm items positioned correctly + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->y() == i*30); + } + + listview->setSpacing(0); + + // Confirm items positioned correctly + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->y() == i*20); + } + + delete canvas; +} + +void tst_QmlGraphicsListView::sections() +{ + QmlView *canvas = createView(SRCDIR "/data/listview-sections.qml"); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QVERIFY(listview != 0); + + QmlGraphicsItem *viewport = listview->viewport(); + QVERIFY(viewport != 0); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + QVERIFY(item); + QCOMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); + } + + delete canvas; +} + void tst_QmlGraphicsListView::qListModelInterface_items() { items(); -- cgit v0.12 From 7d290c0a38f325a3c024a38bcd5da94877d7fd64 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 14:51:40 +1000 Subject: Loader cleanup and testing. --- .../graphicsitems/qmlgraphicsloader.cpp | 89 ++++++++++++---------- .../graphicsitems/qmlgraphicsloader_p.h | 1 - .../graphicsitems/qmlgraphicsloader_p_p.h | 5 +- tests/auto/declarative/qfxloader/tst_qfxloader.cpp | 13 +++- 4 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index 4d463ab..d42e559 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -45,7 +45,8 @@ QT_BEGIN_NAMESPACE QmlGraphicsLoaderPrivate::QmlGraphicsLoaderPrivate() -: item(0), component(0), ownComponent(false), resizeMode(QmlGraphicsLoader::SizeLoaderToItem) + : item(0), component(0), ownComponent(false) + , resizeMode(QmlGraphicsLoader::SizeLoaderToItem) { } @@ -53,6 +54,36 @@ QmlGraphicsLoaderPrivate::~QmlGraphicsLoaderPrivate() { } +void QmlGraphicsLoaderPrivate::clear() +{ + if (ownComponent) { + delete component; + component = 0; + ownComponent = false; + } + source = QUrl(); + + delete item; + item = 0; +} + +void QmlGraphicsLoaderPrivate::initResize() +{ + Q_Q(QmlGraphicsLoader); + + QmlGraphicsItem *resizeItem = 0; + if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) + resizeItem = item; + else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader) + resizeItem = q; + if (resizeItem) { + QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); + QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); + } + _q_updateSize(); +} + + QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QmlGraphicsLoader) /*! @@ -74,6 +105,17 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QmlGraphicsLoader) MouseRegion { anchors.fill: parent; onClicked: pageLoader.source = "Page1.qml" } } \endcode + + If the Loader source is changed, any previous items instantiated + will be destroyed. Setting \c source to an empty string + will destroy the currently instantiated items, freeing resources + and leaving the Loader empty. For example: + + \code + pageLoader.source = "" + \endcode + + unloads "Page1.qml" and frees resources consumed by it. */ /*! @@ -102,7 +144,7 @@ QmlGraphicsLoader::~QmlGraphicsLoader() This property holds the URL of the QML component to instantiate. - \sa status, progress + \sa sourceComponent, status, progress */ QUrl QmlGraphicsLoader::source() const { @@ -116,12 +158,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url) if (d->source == url) return; - if (d->ownComponent) { - delete d->component; - d->component = 0; - } - delete d->item; - d->item = 0; + d->clear(); d->source = url; if (d->source.isEmpty()) { @@ -164,7 +201,7 @@ void QmlGraphicsLoader::setSource(const QUrl &url) } \endqml - \sa source + \sa source, progress */ QmlComponent *QmlGraphicsLoader::sourceComponent() const @@ -179,13 +216,7 @@ void QmlGraphicsLoader::setSourceComponent(QmlComponent *comp) if (comp == d->component) return; - d->source = QUrl(); - if (d->ownComponent) { - delete d->component; - d->component = 0; - } - delete d->item; - d->item = 0; + d->clear(); d->component = comp; d->ownComponent = false; @@ -233,16 +264,7 @@ void QmlGraphicsLoaderPrivate::_q_sourceLoaded() if (item) { item->setParentItem(q); // item->setFocus(true); - QmlGraphicsItem *resizeItem = 0; - if (resizeMode == QmlGraphicsLoader::SizeLoaderToItem) - resizeItem = item; - else if (resizeMode == QmlGraphicsLoader::SizeItemToLoader) - resizeItem = q; - if (resizeItem) { - QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); - QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); - } - _q_updateSize(); + initResize(); } } else { delete obj; @@ -340,20 +362,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode) } d->resizeMode = mode; - - if (d->item) { - QmlGraphicsItem *resizeItem = 0; - if (d->resizeMode == SizeLoaderToItem) - resizeItem = d->item; - else if (d->resizeMode == SizeItemToLoader) - resizeItem = this; - if (resizeItem) { - connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); - connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); - } - - d->_q_updateSize(); - } + d->initResize(); } void QmlGraphicsLoaderPrivate::_q_updateSize() diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h index 8cd1819..ad516b4 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h @@ -63,7 +63,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem Q_PROPERTY(QmlGraphicsItem *item READ item NOTIFY itemChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - //### sourceItem public: QmlGraphicsLoader(QmlGraphicsItem *parent=0); diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h index 23fedb7..cd7316d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsloader_p_p.h @@ -67,10 +67,13 @@ public: QmlGraphicsLoaderPrivate(); ~QmlGraphicsLoaderPrivate(); + void clear(); + void initResize(); + QUrl source; QmlGraphicsItem *item; QmlComponent *component; - bool ownComponent; + bool ownComponent : 1; QmlGraphicsLoader::ResizeMode resizeMode; void _q_sourceLoaded(); diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp index 9a8f8f1..9a3da90 100644 --- a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp +++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp @@ -110,14 +110,21 @@ void tst_qfxloader::component() void tst_qfxloader::clear() { - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/")); + QmlComponent component(&engine, QByteArray( + "import Qt 4.6\n" + " Loader { id: loader\n" + " source: 'Rect120x60.qml'\n" + " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" + " }") + , QUrl("file://" SRCDIR "/")); QmlGraphicsLoader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast(loader)->children().count(), 1); - loader->setSource(QUrl("")); + QTest::qWait(500); + QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); QCOMPARE(static_cast(loader)->children().count(), 0); @@ -136,7 +143,7 @@ void tst_qfxloader::urlToComponent() "}" ) , QUrl("file://" SRCDIR "/")); QmlGraphicsLoader *loader = qobject_cast(component.create()); - QTest::qWait(1000); + QTest::qWait(500); QVERIFY(loader != 0); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); -- cgit v0.12 From 5343b49bbff4d813da1faf3fc4fc406441faccf0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 14:55:39 +1000 Subject: Fix flicking endpoint adjustment with variable height items. --- .../graphicsitems/qmlgraphicsflickable.cpp | 98 ++++++++++++---------- .../graphicsitems/qmlgraphicslistview.cpp | 6 +- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 19c5abc..aa3de26 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -185,17 +185,17 @@ void QmlGraphicsFlickablePrivate::flickX(qreal velocity) { Q_Q(QmlGraphicsFlickable); qreal maxDistance = -1; - if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks. - velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity; // -ve velocity means list is moving up if (velocity > 0) { - if (_moveX.value() < q->minXExtent()) - maxDistance = qAbs(q->minXExtent() -_moveX.value() + (overShoot?30:0)); - flickTargetX = q->minXExtent(); + const qreal minX = q->minXExtent(); + if (_moveX.value() < minX) + maxDistance = qAbs(minX -_moveX.value() + (overShoot?30:0)); + flickTargetX = minX; } else { - if (_moveX.value() > q->maxXExtent()) - maxDistance = qAbs(q->maxXExtent() - _moveX.value()) + (overShoot?30:0); - flickTargetX = q->maxXExtent(); + const qreal maxX = q->maxXExtent(); + if (_moveX.value() > maxX) + maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?30:0); + flickTargetX = maxX; } if (maxDistance > 0) { qreal v = velocity; @@ -225,13 +225,15 @@ void QmlGraphicsFlickablePrivate::flickY(qreal velocity) qreal maxDistance = -1; // -ve velocity means list is moving up if (velocity > 0) { - if (_moveY.value() < q->minYExtent()) - maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0)); - flickTargetY = q->minYExtent(); + const qreal minY = q->minYExtent(); + if (_moveY.value() < minY) + maxDistance = qAbs(minY -_moveY.value() + (overShoot?30:0)); + flickTargetY = minY; } else { - if (_moveY.value() > q->maxYExtent()) - maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0); - flickTargetY = q->maxYExtent(); + const qreal maxY = q->maxYExtent(); + if (_moveY.value() > maxY) + maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?30:0); + flickTargetY = maxY; } if (maxDistance > 0) { qreal v = velocity; @@ -261,8 +263,6 @@ void QmlGraphicsFlickablePrivate::fixupX() if (!q->xflick() || _moveX.timeLine()) return; - vTime = timeline.time(); - if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) { timeline.reset(_moveX); if (_moveX.value() != q->minXExtent()) @@ -275,6 +275,8 @@ void QmlGraphicsFlickablePrivate::fixupX() } else { flicked = false; } + + vTime = timeline.time(); } void QmlGraphicsFlickablePrivate::fixupY() @@ -283,8 +285,6 @@ void QmlGraphicsFlickablePrivate::fixupY() if (!q->yflick() || _moveY.timeLine()) return; - vTime = timeline.time(); - if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) { timeline.reset(_moveY); if (_moveY.value() != q->minYExtent()) @@ -297,6 +297,8 @@ void QmlGraphicsFlickablePrivate::fixupY() } else { flicked = false; } + + vTime = timeline.time(); } void QmlGraphicsFlickablePrivate::updateBeginningEnd() @@ -447,6 +449,7 @@ void QmlGraphicsFlickable::setViewportX(qreal pos) Q_D(QmlGraphicsFlickable); pos = qRound(pos); d->timeline.reset(d->_moveX); + d->vTime = d->timeline.time(); if (-pos != d->_moveX.value()) { d->_moveX.setValue(-pos); viewportMoved(); @@ -464,6 +467,7 @@ void QmlGraphicsFlickable::setViewportY(qreal pos) Q_D(QmlGraphicsFlickable); pos = qRound(pos); d->timeline.reset(d->_moveY); + d->vTime = d->timeline.time(); if (-pos != d->_moveY.value()) { d->_moveY.setValue(-pos); viewportMoved(); @@ -491,6 +495,7 @@ void QmlGraphicsFlickable::setInteractive(bool interactive) d->interactive = interactive; if (!interactive && d->flicked) { d->timeline.clear(); + d->vTime = d->timeline.time(); d->flicked = false; emit flickingChanged(); emit flickEnded(); @@ -837,56 +842,57 @@ void QmlGraphicsFlickable::viewportMoved() Q_D(QmlGraphicsFlickable); int elapsed = QmlGraphicsItemPrivate::elapsed(d->velocityTime); + if (!elapsed) + return; - if (elapsed) { - qreal prevY = d->lastFlickablePosition.x(); - qreal prevX = d->lastFlickablePosition.y(); - d->velocityTimeline.clear(); - if (d->pressed) { - qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed; - qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed; - d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing); - } else { - if (d->timeline.time() != d->vTime) { - qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime); - qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime); - d->horizontalVelocity.setValue(horizontalVelocity); - d->verticalVelocity.setValue(verticalVelocity); - } - d->vTime = d->timeline.time(); + qreal prevY = d->lastFlickablePosition.x(); + qreal prevX = d->lastFlickablePosition.y(); + d->velocityTimeline.clear(); + if (d->pressed) { + qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed; + qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed; + d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing); + } else { + if (d->timeline.time() > d->vTime) { + qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime); + qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime); + d->horizontalVelocity.setValue(horizontalVelocity); + d->verticalVelocity.setValue(verticalVelocity); } } - d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value()); QmlGraphicsItemPrivate::restart(d->velocityTime); - d->updateBeginningEnd(); + d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value()); - if (d->flicked) { + if (d->flicked && d->timeline.time() > d->vTime) { // Near an end and it seems that the extent has changed? // Recalculate the flick so that we don't end up in an odd position. if (d->velocityY > 0) { const qreal minY = minYExtent(); - if (minY - d->_moveY.value() < height()/3 && minY != d->flickTargetY) + if (minY - d->_moveY.value() < height()/2 && minY != d->flickTargetY) d->flickY(-d->verticalVelocity.value()); - } else { + } else if (d->velocityY < 0) { const qreal maxY = maxYExtent(); - if (d->_moveY.value() - maxY < height()/3 && maxY != d->flickTargetY) + if (d->_moveY.value() - maxY < height()/2 && maxY != d->flickTargetY) d->flickY(-d->verticalVelocity.value()); } if (d->velocityX > 0) { const qreal minX = minXExtent(); - if (minX - d->_moveX.value() < height()/3 && minX != d->flickTargetX) + if (minX - d->_moveX.value() < height()/2 && minX != d->flickTargetX) d->flickX(-d->horizontalVelocity.value()); - } else { + } else if (d->velocityX < 0) { const qreal maxX = maxXExtent(); - if (d->_moveX.value() - maxX < height()/3 && maxX != d->flickTargetX) + if (d->_moveX.value() - maxX < height()/2 && maxX != d->flickTargetX) d->flickX(-d->horizontalVelocity.value()); } } + + d->vTime = d->timeline.time(); + d->updateBeginningEnd(); } void QmlGraphicsFlickable::cancelFlick() diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index efe047a..5adb9cf 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -815,8 +815,9 @@ void QmlGraphicsListViewPrivate::fixupY() if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { if (currentItem && highlight && currentItem->position() != highlight->position()) { moveReason = Mouse; - timeline.clear(); + timeline.reset(_moveY); timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200); + vTime = timeline.time(); } } } @@ -830,8 +831,9 @@ void QmlGraphicsListViewPrivate::fixupX() if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { if (currentItem && highlight && currentItem->position() != highlight->position()) { moveReason = Mouse; - timeline.clear(); + timeline.reset(_moveX); timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), 200); + vTime = timeline.time(); } } } -- cgit v0.12 From b8e788865cae90122e51ad1a2649d0891370fb3d Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 5 Nov 2009 15:05:03 +1000 Subject: use FreeMono.ttf --- examples/declarative/fonts/fonts.qml | 3 +-- examples/declarative/fonts/fonts/Fontin-Bold.ttf | Bin 30916 -> 0 bytes examples/declarative/fonts/fonts/FreeMono.ttf | Bin 0 -> 267400 bytes .../declarative/qmlfontloader/data/Fontin-Bold.ttf | Bin 30916 -> 0 bytes tests/auto/declarative/qmlfontloader/data/FreeMono.ttf | Bin 0 -> 267400 bytes .../declarative/qmlfontloader/tst_qmlfontloader.cpp | 4 ++-- 6 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 examples/declarative/fonts/fonts/Fontin-Bold.ttf create mode 100644 examples/declarative/fonts/fonts/FreeMono.ttf delete mode 100644 tests/auto/declarative/qmlfontloader/data/Fontin-Bold.ttf create mode 100644 tests/auto/declarative/qmlfontloader/data/FreeMono.ttf diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 80d82ad..c7af666 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -8,8 +8,7 @@ Rectangle { FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/Fontin-Bold.ttf" } - /* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */ + FontLoader { id: localFont; source: "fonts/FreeMono.ttf" } FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } FontLoader { id: webFont2; source: "http://wrong.address.org" } diff --git a/examples/declarative/fonts/fonts/Fontin-Bold.ttf b/examples/declarative/fonts/fonts/Fontin-Bold.ttf deleted file mode 100644 index f6a33b0..0000000 Binary files a/examples/declarative/fonts/fonts/Fontin-Bold.ttf and /dev/null differ diff --git a/examples/declarative/fonts/fonts/FreeMono.ttf b/examples/declarative/fonts/fonts/FreeMono.ttf new file mode 100644 index 0000000..d7ce52d Binary files /dev/null and b/examples/declarative/fonts/fonts/FreeMono.ttf differ diff --git a/tests/auto/declarative/qmlfontloader/data/Fontin-Bold.ttf b/tests/auto/declarative/qmlfontloader/data/Fontin-Bold.ttf deleted file mode 100644 index f6a33b0..0000000 Binary files a/tests/auto/declarative/qmlfontloader/data/Fontin-Bold.ttf and /dev/null differ diff --git a/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf b/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf new file mode 100644 index 0000000..d7ce52d Binary files /dev/null and b/tests/auto/declarative/qmlfontloader/data/FreeMono.ttf differ diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp index 23f7025..a5ab13d 100644 --- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp +++ b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp @@ -97,13 +97,13 @@ void tst_qmlfontloader::namedFont() void tst_qmlfontloader::localFont() { - QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/Fontin-Bold.ttf\" }"; + QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/FreeMono.ttf\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("Fontin")); + QTRY_COMPARE(fontObject->name(), QString("FreeMono")); QTRY_VERIFY(fontObject->status() == QmlFontLoader::Ready); } -- cgit v0.12 From 5c488b43a87cfdb146bcc5564faa229c979b8292 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 5 Nov 2009 15:15:18 +1000 Subject: update text visuals --- .../visual/qfxtext/font/data-MAC/plaintext.0.png | Bin 94120 -> 103016 bytes .../visual/qfxtext/font/data-MAC/plaintext.qml | 166 ++++++++++---------- .../visual/qfxtext/font/data-MAC/richtext.0.png | Bin 121122 -> 136499 bytes .../visual/qfxtext/font/data-MAC/richtext.qml | 170 ++++++++++----------- .../declarative/visual/qfxtext/font/plaintext.qml | 15 +- .../declarative/visual/qfxtext/font/richtext.qml | 15 +- 6 files changed, 192 insertions(+), 174 deletions(-) diff --git a/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.0.png b/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.0.png index 50d56dc..a54a327 100644 Binary files a/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.0.png and b/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.0.png differ diff --git a/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.qml b/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.qml index 63e20d4..266c9a3 100644 --- a/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.qml +++ b/tests/auto/declarative/visual/qfxtext/font/data-MAC/plaintext.qml @@ -6,239 +6,239 @@ VisualTest { } Frame { msec: 16 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 32 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 48 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 64 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 80 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 96 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 112 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 128 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 144 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 160 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 176 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 192 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 208 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 224 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 240 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 256 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 272 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 288 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 304 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 320 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 336 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 352 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 368 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 384 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 400 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 416 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 432 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 448 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 464 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 480 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 496 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 512 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 528 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 544 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 560 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 576 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 592 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 608 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 624 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 640 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 656 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 672 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 688 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 704 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 720 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 736 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 752 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 768 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 784 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 800 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 816 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 832 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 848 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 864 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 880 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 896 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 912 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 928 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 944 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 960 @@ -246,59 +246,59 @@ VisualTest { } Frame { msec: 976 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 992 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1008 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1024 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1040 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1056 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1072 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1088 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1104 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1120 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1136 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1152 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1168 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1184 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Key { type: 6 @@ -310,42 +310,42 @@ VisualTest { } Frame { msec: 1200 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1216 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1232 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1248 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1264 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1280 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1296 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1312 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1328 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } Frame { msec: 1344 - hash: "d553014bc56a46787e30459b0f44f57a" + hash: "9f3d0a505dec1982d9b405be72c265f8" } } diff --git a/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.0.png b/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.0.png index 2910670..c2ddee1 100644 Binary files a/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.0.png and b/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.0.png differ diff --git a/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.qml b/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.qml index d55ad90..e971809 100644 --- a/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.qml +++ b/tests/auto/declarative/visual/qfxtext/font/data-MAC/richtext.qml @@ -6,239 +6,239 @@ VisualTest { } Frame { msec: 16 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 32 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 48 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 64 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 80 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 96 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 112 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 128 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 144 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 160 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 176 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 192 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 208 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 224 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 240 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 256 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 272 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 288 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 304 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 320 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 336 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 352 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 368 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 384 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 400 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 416 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 432 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 448 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 464 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 480 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 496 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 512 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 528 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 544 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 560 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 576 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 592 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 608 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 624 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 640 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 656 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 672 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 688 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 704 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 720 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 736 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 752 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 768 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 784 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 800 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 816 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 832 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 848 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 864 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 880 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 896 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 912 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 928 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 944 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 960 @@ -246,51 +246,51 @@ VisualTest { } Frame { msec: 976 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 992 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1008 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1024 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1040 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1056 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1072 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1088 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1104 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1120 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1136 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1152 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Key { type: 6 @@ -302,58 +302,58 @@ VisualTest { } Frame { msec: 1168 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1184 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1200 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1216 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1232 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1248 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1264 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1280 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1296 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1312 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1328 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1344 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1360 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } Frame { msec: 1376 - hash: "dfea78484b840b8cab690e277b960723" + hash: "259cc9829171ea866dac4ffe8ef6b489" } } diff --git a/tests/auto/declarative/visual/qfxtext/font/plaintext.qml b/tests/auto/declarative/visual/qfxtext/font/plaintext.qml index c58b95c..f219e09 100644 --- a/tests/auto/declarative/visual/qfxtext/font/plaintext.qml +++ b/tests/auto/declarative/visual/qfxtext/font/plaintext.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: s; width: 800; height: 800; color: "lightsteelblue" + id: s; width: 800; height: 1000; color: "lightsteelblue" property string text: "The quick brown fox jumps over the lazy dog." Column { @@ -16,7 +16,7 @@ Rectangle { text: s.text; font.pointSize: 25 } Text { - text: s.text; color: "red" + text: s.text; color: "red"; smooth: true } Text { text: s.text; font.capitalization: "AllUppercase" @@ -25,7 +25,7 @@ Rectangle { text: s.text; font.underline: true } Text { - text: s.text; font.overline: true + text: s.text; font.overline: true; smooth: true } Text { text: s.text; font.strikeout: true @@ -72,5 +72,14 @@ Rectangle { Text { text: s.text; elide: Text.ElideRight; width: 200 } + Text { + text: s.text; elide: Text.ElideLeft; width: 200; wrap: true + } + Text { + text: s.text; elide: Text.ElideMiddle; width: 200; wrap: true + } + Text { + text: s.text; elide: Text.ElideRight; width: 200; wrap: true + } } } diff --git a/tests/auto/declarative/visual/qfxtext/font/richtext.qml b/tests/auto/declarative/visual/qfxtext/font/richtext.qml index 390527a..00a9749 100644 --- a/tests/auto/declarative/visual/qfxtext/font/richtext.qml +++ b/tests/auto/declarative/visual/qfxtext/font/richtext.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - id: s; width: 800; height: 800; color: "lightsteelblue" + id: s; width: 800; height: 1000; color: "lightsteelblue" property string text: "The quick brown fox jumps over the lazy dog." Column { @@ -16,7 +16,7 @@ Rectangle { text: s.text; font.pointSize: 25 } Text { - text: s.text; color: "red" + text: s.text; color: "red"; smooth: true } Text { text: s.text; font.capitalization: "AllUppercase" @@ -25,7 +25,7 @@ Rectangle { text: s.text; font.underline: true } Text { - text: s.text; font.overline: true + text: s.text; font.overline: true; smooth: true } Text { text: s.text; font.strikeout: true @@ -72,5 +72,14 @@ Rectangle { Text { text: s.text; elide: Text.ElideRight; width: 200 } + Text { + text: s.text; elide: Text.ElideLeft; width: 200; wrap: true + } + Text { + text: s.text; elide: Text.ElideMiddle; width: 200; wrap: true + } + Text { + text: s.text; elide: Text.ElideRight; width: 200; wrap: true + } } } -- cgit v0.12 From e1f01000ec127dd5a949eabf9b436f649597bf01 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 15:16:51 +1000 Subject: Add listview test file. --- .../listview/data/listview-sections.qml | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/auto/declarative/listview/data/listview-sections.qml diff --git a/tests/auto/declarative/listview/data/listview-sections.qml b/tests/auto/declarative/listview/data/listview-sections.qml new file mode 100644 index 0000000..56700be --- /dev/null +++ b/tests/auto/declarative/listview/data/listview-sections.qml @@ -0,0 +1,59 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + resources: [ + Component { + id: myDelegate + Item { + id: wrapper + objectName: "wrapper" + height: ListView.prevSection != ListView.section ? 40 : 20; + width: 240 + Rectangle { + y: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0 + height: 20 + width: parent.width + color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white" + Text { + text: index + } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 120 + id: textNumber + objectName: "textNumber" + text: number + } + Text { + x: 200 + text: wrapper.y + } + } + Rectangle { + color: "#99bb99" + height: wrapper.ListView.prevSection != wrapper.ListView.section ? 20 : 0 + width: parent.width + visible: wrapper.ListView.prevSection != wrapper.ListView.section ? true : false + Text { text: wrapper.ListView.section } + } + } + } + ] + ListView { + id: list + objectName: "list" + width: 240 + height: 320 + model: testModel + delegate: myDelegate + sectionExpression: "Math.floor(index/5)" + } +} -- cgit v0.12 From 34dcd4a715ca3f43901c245322e7c42dea646b8d Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 5 Nov 2009 15:41:40 +1000 Subject: fillmode visual test --- .../visual/fillmode/data-MAC/fillmode.0.png | Bin 0 -> 26099 bytes .../visual/fillmode/data-MAC/fillmode.qml | 279 +++++++++++++++++++++ .../visual/fillmode/data/fillmode.0.png | Bin 0 -> 26099 bytes .../declarative/visual/fillmode/data/fillmode.qml | 279 +++++++++++++++++++++ tests/auto/declarative/visual/fillmode/face.png | Bin 0 -> 905 bytes .../auto/declarative/visual/fillmode/fillmode.qml | 16 ++ 6 files changed, 574 insertions(+) create mode 100644 tests/auto/declarative/visual/fillmode/data-MAC/fillmode.0.png create mode 100644 tests/auto/declarative/visual/fillmode/data-MAC/fillmode.qml create mode 100644 tests/auto/declarative/visual/fillmode/data/fillmode.0.png create mode 100644 tests/auto/declarative/visual/fillmode/data/fillmode.qml create mode 100644 tests/auto/declarative/visual/fillmode/face.png create mode 100644 tests/auto/declarative/visual/fillmode/fillmode.qml diff --git a/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.0.png b/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.0.png new file mode 100644 index 0000000..9c9ceae Binary files /dev/null and b/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.0.png differ diff --git a/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.qml b/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.qml new file mode 100644 index 0000000..7ac6f51 --- /dev/null +++ b/tests/auto/declarative/visual/fillmode/data-MAC/fillmode.qml @@ -0,0 +1,279 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 32 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 48 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 64 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 80 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 96 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 112 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 128 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 144 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 160 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 176 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 192 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 208 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 224 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 240 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 256 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 272 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 288 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 304 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 320 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 336 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 352 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 368 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 384 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 400 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 416 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 432 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 448 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 464 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 480 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 496 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 512 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 528 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 544 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 560 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 576 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 592 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 608 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 624 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 640 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 656 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 672 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 688 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 704 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Key { + type: 6 + key: 16777249 + modifiers: 0 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 720 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 736 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 752 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 768 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 784 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 800 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 816 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 832 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 848 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 864 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 880 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 896 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 912 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 928 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 944 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 960 + image: "fillmode.0.png" + } + Frame { + msec: 976 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 992 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1008 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1024 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1040 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1056 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } +} diff --git a/tests/auto/declarative/visual/fillmode/data/fillmode.0.png b/tests/auto/declarative/visual/fillmode/data/fillmode.0.png new file mode 100644 index 0000000..9c9ceae Binary files /dev/null and b/tests/auto/declarative/visual/fillmode/data/fillmode.0.png differ diff --git a/tests/auto/declarative/visual/fillmode/data/fillmode.qml b/tests/auto/declarative/visual/fillmode/data/fillmode.qml new file mode 100644 index 0000000..58af8e8 --- /dev/null +++ b/tests/auto/declarative/visual/fillmode/data/fillmode.qml @@ -0,0 +1,279 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 32 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 48 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 64 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 80 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 96 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 112 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 128 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 144 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 160 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 176 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 192 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 208 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 224 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 240 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 256 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 272 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 288 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 304 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 320 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 336 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 352 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 368 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 384 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 400 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 416 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 432 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 448 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 464 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 480 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 496 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 512 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 528 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 544 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 560 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 576 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 592 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 608 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 624 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 640 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 656 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 672 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 688 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 704 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Key { + type: 6 + key: 16777249 + modifiers: 67108864 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 720 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 736 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 752 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 768 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 784 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 800 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 816 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 832 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 848 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 864 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 880 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 896 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 912 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 928 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 944 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 960 + image: "fillmode.0.png" + } + Frame { + msec: 976 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 992 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1008 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1024 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1040 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } + Frame { + msec: 1056 + hash: "c8cb8d51ca04231dc272133faaf2fb6d" + } +} diff --git a/tests/auto/declarative/visual/fillmode/face.png b/tests/auto/declarative/visual/fillmode/face.png new file mode 100644 index 0000000..9623b1a Binary files /dev/null and b/tests/auto/declarative/visual/fillmode/face.png differ diff --git a/tests/auto/declarative/visual/fillmode/fillmode.qml b/tests/auto/declarative/visual/fillmode/fillmode.qml new file mode 100644 index 0000000..8450bf2 --- /dev/null +++ b/tests/auto/declarative/visual/fillmode/fillmode.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +Rectangle { + id: screen; width: 750; height: 600; color: "gray" + property string source: "face.png" + + Grid { + columns: 3 + Image { width: 250; height: 300; source: screen.source; fillMode: Image.Stretch } + Image { width: 250; height: 300; source: screen.source; fillMode: Image.PreserveAspectFit; smooth: true } + Image { width: 250; height: 300; source: screen.source; fillMode: Image.PreserveAspectCrop } + Image { width: 250; height: 300; source: screen.source; fillMode: Image.Tile; smooth: true } + Image { width: 250; height: 300; source: screen.source; fillMode: Image.TileHorizontally } + Image { width: 250; height: 300; source: screen.source; fillMode: Image.TileVertically } + } +} -- cgit v0.12 From cec070f3905bcf6127e4e14236d5c61f09e3a61f Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 5 Nov 2009 15:59:53 +1000 Subject: Document the vector3d type in QML Task-number: QTBUG-5334 Reviewed-by: Aaron Kennedy --- doc/src/declarative/basictypes.qdoc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 80ec211..0551443 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -233,4 +233,25 @@ \endqml \c Child1, \c Child2 and \c Child3 will all be added to the children list in the order in which they appear. + + \target basicqmlvector3d + \section1 vector3d + + A \c vector3d is specified in \c "x,y,z" format: + + \qml + Rotation { angle: 60; axis: "0,1,0" } + \endqml + + or with the \c{Qt.vector3d()} helper function: + + \qml + Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) } + \endqml + + or as separate \c x, \c y, and \c z components: + + \qml + Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 } + \endqml */ -- cgit v0.12 From a1f47211146629f702457150235da4475c1163ed Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 5 Nov 2009 16:46:17 +1000 Subject: qmlsystempalette autotests --- src/declarative/util/qmlsystempalette.cpp | 26 +--- src/declarative/util/qmlsystempalette_p.h | 13 +- tests/auto/declarative/declarative.pro | 1 + .../qmlsystempalette/qmlsystempalette.pro | 5 + .../qmlsystempalette/tst_qmlsystempalette.cpp | 154 +++++++++++++++++++++ 5 files changed, 171 insertions(+), 28 deletions(-) create mode 100644 tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro create mode 100644 tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp index bb3ec70..4ddc82d 100644 --- a/src/declarative/util/qmlsystempalette.cpp +++ b/src/declarative/util/qmlsystempalette.cpp @@ -256,39 +256,23 @@ QColor QmlSystemPalette::highlightedText() const } /*! - \qmlproperty color SystemPalette::lighter -*/ -QColor QmlSystemPalette::lighter(const QColor& color) const -{ - return color.lighter(); -} - -/*! - \qmlproperty color SystemPalette::darker -*/ -QColor QmlSystemPalette::darker(const QColor& color) const -{ - return color.darker(); -} - -/*! - \qmlproperty QPalette::ColorGroup SystemPalette::colorGroup + \qmlproperty QmlSystemPalette::ColorGroup SystemPalette::colorGroup The color group of the palette. It can be Active, Inactive or Disabled. Active is the default. \sa QPalette::ColorGroup */ -QPalette::ColorGroup QmlSystemPalette::colorGroup() const +QmlSystemPalette::ColorGroup QmlSystemPalette::colorGroup() const { Q_D(const QmlSystemPalette); - return d->group; + return (QmlSystemPalette::ColorGroup)d->group; } -void QmlSystemPalette::setColorGroup(QPalette::ColorGroup colorGroup) +void QmlSystemPalette::setColorGroup(QmlSystemPalette::ColorGroup colorGroup) { Q_D(QmlSystemPalette); - d->group = colorGroup; + d->group = (QPalette::ColorGroup)colorGroup; emit paletteChanged(); } diff --git a/src/declarative/util/qmlsystempalette_p.h b/src/declarative/util/qmlsystempalette_p.h index e87534e..6abbfe0 100644 --- a/src/declarative/util/qmlsystempalette_p.h +++ b/src/declarative/util/qmlsystempalette_p.h @@ -56,9 +56,10 @@ class QmlSystemPalettePrivate; class Q_DECLARATIVE_EXPORT QmlSystemPalette : public QObject { Q_OBJECT + Q_ENUMS(ColorGroup) Q_DECLARE_PRIVATE(QmlSystemPalette) - Q_PROPERTY(QPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) + Q_PROPERTY(QmlSystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) @@ -78,6 +79,8 @@ public: QmlSystemPalette(QObject *parent=0); ~QmlSystemPalette(); + enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled }; + QColor window() const; QColor windowText() const; @@ -97,12 +100,8 @@ public: QColor highlight() const; QColor highlightedText() const; - QPalette::ColorGroup colorGroup() const; - void setColorGroup(QPalette::ColorGroup); - - // FIXME: Move to utility class? - Q_INVOKABLE QColor lighter(const QColor&) const; - Q_INVOKABLE QColor darker(const QColor&) const; + QmlSystemPalette::ColorGroup colorGroup() const; + void setColorGroup(QmlSystemPalette::ColorGroup); Q_SIGNALS: void paletteChanged(); diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index b9f59d6..1625a15 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -30,6 +30,7 @@ SUBDIRS += \ qmlpixmapcache \ # Cover qmlpropertymap \ # Cover qmlqt \ # Cover + qmlsystempalette \ # Cover qmltimer \ # Cover qmlxmllistmodel \ # Cover repeater \ # Cover diff --git a/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro b/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro new file mode 100644 index 0000000..4d55b46 --- /dev/null +++ b/tests/auto/declarative/qmlsystempalette/qmlsystempalette.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlsystempalette.cpp diff --git a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp new file mode 100644 index 0000000..039eaa8 --- /dev/null +++ b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +class tst_qmlsystempalette : public QObject + +{ + Q_OBJECT +public: + tst_qmlsystempalette(); + +private slots: + void activePalette(); + void inactivePalette(); + void disabledPalette(); + +private: + QmlEngine engine; +}; + +tst_qmlsystempalette::tst_qmlsystempalette() +{ +} + +void tst_qmlsystempalette::activePalette() +{ + QString componentStr = "import Qt 4.6\nSystemPalette { }"; + QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Active); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qmlsystempalette::inactivePalette() +{ + QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Inactive }"; + QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Inactive); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qmlsystempalette::disabledPalette() +{ + QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Disabled }"; + QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Disabled); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +QTEST_MAIN(tst_qmlsystempalette) + +#include "tst_qmlsystempalette.moc" -- cgit v0.12 From 01d7ae66da344f9aaef039310ac241015ec4cad5 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 5 Nov 2009 16:56:14 +1000 Subject: Use darker() and lighter() functions from global Qt object rather than from SystemPalette. --- demos/declarative/calculator/CalcButton.qml | 2 +- demos/declarative/calculator/calculator.qml | 2 +- demos/declarative/samegame/content/Button.qml | 2 +- demos/declarative/samegame/samegame.qml | 2 +- examples/declarative/dynamic/dynamic.qml | 2 +- examples/declarative/dynamic/qml/Button.qml | 2 +- examples/declarative/loader/Browser.qml | 4 ++-- examples/declarative/tutorials/samegame/samegame1/Button.qml | 2 +- examples/declarative/tutorials/samegame/samegame1/samegame.qml | 2 +- examples/declarative/tutorials/samegame/samegame2/Button.qml | 2 +- examples/declarative/tutorials/samegame/samegame2/samegame.qml | 2 +- examples/declarative/tutorials/samegame/samegame3/Button.qml | 2 +- examples/declarative/tutorials/samegame/samegame3/samegame.qml | 2 +- examples/declarative/tutorials/samegame/samegame4/content/Button.qml | 2 +- examples/declarative/tutorials/samegame/samegame4/samegame.qml | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml index c2e3a81..03ede9c 100644 --- a/demos/declarative/calculator/CalcButton.qml +++ b/demos/declarative/calculator/CalcButton.qml @@ -9,7 +9,7 @@ Rectangle { id: button; width: 50; height: 30 border.color: palette.mid; radius: 6 gradient: Gradient { - GradientStop { id: G1; position: 0.0; color: palette.lighter(palette.button) } + GradientStop { id: G1; position: 0.0; color: Qt.lighter(palette.button) } GradientStop { id: G2; position: 1.0; color: palette.button } } diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 8041025..18ee5b9 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -3,7 +3,7 @@ import Qt 4.6 Rectangle { width: 320; height: 270; color: palette.window - SystemPalette { id: palette; colorGroup: Qt.Active } + SystemPalette { id: palette } Script { source: "calculator.js" } Column { diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml index 301124e..63cd555 100644 --- a/demos/declarative/samegame/content/Button.qml +++ b/demos/declarative/samegame/content/Button.qml @@ -8,7 +8,7 @@ Rectangle { color: activePalette.button; smooth: true width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 4560b56..19b929f 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -5,7 +5,7 @@ Rectangle { id: screen width: 490; height: 720 - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } Item { width: parent.width; anchors.top: parent.top; anchors.bottom: toolBar.top diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 0166b4c..f420a1c 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -46,7 +46,7 @@ Item { ColorAnimation { duration: 3000 } } - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } // toolbox Rectangle { diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml index 2769cd8..cf2ffa7 100644 --- a/examples/declarative/dynamic/qml/Button.qml +++ b/examples/declarative/dynamic/qml/Button.qml @@ -6,7 +6,7 @@ Rectangle { property var text signal clicked - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } height: text.height + 10 width: text.width + 20 border.width: 1 diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index f2cbd3d..9139346 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -19,7 +19,7 @@ Rectangle { folder: "file:///E:/" // Documents on your S60 phone (or Windows E: drive) } - SystemPalette { id: palette; colorGroup: Qt.Active } + SystemPalette { id: palette } Script { function down(path) { @@ -72,7 +72,7 @@ Rectangle { anchors.fill: parent gradient: Gradient { GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: palette.lighter(palette.highlight) } + GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } } } Item { diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index 3846cf7..9792a22 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -9,7 +9,7 @@ Rectangle { color: activePalette.button; smooth: true width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index b5546d0..289579a 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -5,7 +5,7 @@ Rectangle { id: Screen width: 490; height: 720 - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } Item { width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml index 2354218..9e515e0 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml @@ -8,7 +8,7 @@ Rectangle { color: activePalette.button; smooth: true width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index 257e0de..e0e467a 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -4,7 +4,7 @@ Rectangle { id: Screen width: 490; height: 720 - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } //![2] Script { source: "samegame.js" } //![2] diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml index 2354218..9e515e0 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml @@ -8,7 +8,7 @@ Rectangle { color: activePalette.button; smooth: true width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index 0a7ec0f..e1eb542 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -5,7 +5,7 @@ Rectangle { id: Screen width: 490; height: 720 - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } Script { source: "samegame.js" } Item { diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml index 2354218..9e515e0 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml @@ -8,7 +8,7 @@ Rectangle { color: activePalette.button; smooth: true width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: activePalette.darker(activePalette.button); radius: 8; + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; gradient: Gradient { GradientStop { diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml index e519912..89dc945 100644 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml @@ -7,7 +7,7 @@ Rectangle { Script { source: "content/samegame.js" } - SystemPalette { id: activePalette; colorGroup: Qt.Active } + SystemPalette { id: activePalette } Item { width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top -- cgit v0.12 From e6a682189c4cd7f291648b9190b68cce79106b86 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 16:58:20 +1000 Subject: Add test for GridView, and fix bug. --- .../graphicsitems/qmlgraphicsgridview.cpp | 46 +- .../graphicsitems/qmlgraphicslistview.cpp | 7 +- tests/auto/declarative/declarative.pro | 1 + .../qmlgraphicsgridview/data/gridview.qml | 49 ++ .../qmlgraphicsgridview/qmlgraphicsgridview.pro | 8 + .../tst_qmlgraphicsgridview.cpp | 585 +++++++++++++++++++++ 6 files changed, 672 insertions(+), 24 deletions(-) create mode 100644 tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml create mode 100644 tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro create mode 100644 tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 9f9b336..7427266 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -578,29 +578,35 @@ void QmlGraphicsGridViewPrivate::createHighlight() highlightYAnimator = 0; } - if (!highlightComponent) - return; - if (currentItem) { - QmlContext *highlightContext = new QmlContext(qmlContext(q)); - QObject *nobj = highlightComponent->create(highlightContext); - if (nobj) { - highlightContext->setParent(nobj); - QmlGraphicsItem *item = qobject_cast(nobj); - if (item) { - item->setParent(q->viewport()); - highlight = new FxGridItem(item, q); - highlightXAnimator = new QmlEaseFollow(q); - highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x"))); - highlightXAnimator->setDuration(150); - highlightXAnimator->setEnabled(autoHighlight); - highlightYAnimator = new QmlEaseFollow(q); - highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y"))); - highlightYAnimator->setDuration(150); - highlightYAnimator->setEnabled(autoHighlight); + QmlGraphicsItem *item = 0; + if (highlightComponent) { + QmlContext *highlightContext = new QmlContext(qmlContext(q)); + QObject *nobj = highlightComponent->create(highlightContext); + if (nobj) { + highlightContext->setParent(nobj); + item = qobject_cast(nobj); + if (!item) + delete nobj; } else { delete highlightContext; } + } else { + item = new QmlGraphicsItem; + item->setParent(q->viewport()); + } + if (item) { + item->setZValue(0); + item->setParent(q->viewport()); + highlight = new FxGridItem(item, q); + highlightXAnimator = new QmlEaseFollow(q); + highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x"))); + highlightXAnimator->setDuration(150); + highlightXAnimator->setEnabled(autoHighlight); + highlightYAnimator = new QmlEaseFollow(q); + highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y"))); + highlightYAnimator->setDuration(150); + highlightYAnimator->setEnabled(autoHighlight); } } } @@ -1500,6 +1506,8 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count) if (item->index > from && item->index != -1) { // move everything after the moved items. item->index -= count; + if (item->index < d->visibleIndex) + d->visibleIndex = item->index; } ++it; } diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index fc1ec4a..f9d4190 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -662,19 +662,16 @@ void QmlGraphicsListViewPrivate::createHighlight() if (nobj) { highlightContext->setParent(nobj); item = qobject_cast(nobj); - if (!item) { + if (!item) delete nobj; - } else { - item->setParent(q->viewport()); - } } else { delete highlightContext; } } else { item = new QmlGraphicsItem; - item->setParent(q->viewport()); } if (item) { + item->setParent(q->viewport()); item->setZValue(0); highlight = new FxListItem(item, q); if (orient == QmlGraphicsListView::Vertical) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index b9f59d6..e586925 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -8,6 +8,7 @@ SUBDIRS += \ examples \ layouts \ # Cover listview \ # Cover + qmlgraphicsgridview \ # Cover numberformatter \ # Cover pathview \ # Cover qfxloader \ # Cover diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml new file mode 100644 index 0000000..37eb622 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview.qml @@ -0,0 +1,49 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + resources: [ + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: 80 + height: 60 + border.color: "blue" + Text { + text: index + } + Text { + x: 40 + text: wrapper.x + ", " + wrapper.y + } + Text { + y: 20 + id: textName + objectName: "textName" + text: name + } + Text { + y: 40 + id: textNumber + objectName: "textNumber" + text: number + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + } + } + ] + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + } +} diff --git a/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro b/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro new file mode 100644 index 0000000..8eae8ae --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsgridview/qmlgraphicsgridview.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlgraphicsgridview.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp new file mode 100644 index 0000000..c6ea25a --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -0,0 +1,585 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +class tst_QmlGraphicsGridView : public QObject +{ + Q_OBJECT +public: + tst_QmlGraphicsGridView(); + +private slots: + void items(); + void changed(); + void inserted(); + void removed(); + void moved(); + +private: + QmlView *createView(const QString &filename); + template + T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); + template + QList findItems(QmlGraphicsItem *parent, const QString &objectName); +}; + +class TestModel : public QAbstractListModel +{ +public: + enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; + + TestModel(QObject *parent=0) : QAbstractListModel(parent) { + QHash roles; + roles[Name] = "name"; + roles[Number] = "number"; + setRoleNames(roles); + } + + int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { + QVariant rv; + if (role == Name) + rv = list.at(index.row()).first; + else if (role == Number) + rv = list.at(index.row()).second; + + return rv; + } + + int count() const { return rowCount(); } + QString name(int index) const { return list.at(index).first; } + QString number(int index) const { return list.at(index).second; } + + void addItem(const QString &name, const QString &number) { + emit beginInsertRows(QModelIndex(), list.count(), list.count()); + list.append(QPair(name, number)); + emit endInsertRows(); + } + + void insertItem(int index, const QString &name, const QString &number) { + emit beginInsertRows(QModelIndex(), index, index); + list.insert(index, QPair(name, number)); + emit endInsertRows(); + } + + void removeItem(int index) { + emit beginRemoveRows(QModelIndex(), index, index); + list.removeAt(index); + emit endRemoveRows(); + } + + void moveItem(int from, int to) { + emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); + list.move(from, to); + emit endMoveRows(); + } + + void modifyItem(int idx, const QString &name, const QString &number) { + list[idx] = QPair(name, number); + emit dataChanged(index(idx,0), index(idx,0)); + } + +private: + QList > list; +}; + +tst_QmlGraphicsGridView::tst_QmlGraphicsGridView() +{ +} + +void tst_QmlGraphicsGridView::items() +{ + QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + + TestModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Billy", "22345"); + model.addItem("Sam", "2945"); + model.addItem("Ben", "04321"); + model.addItem("Jim", "0780"); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QVERIFY(gridview != 0); + + QmlGraphicsItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + QCOMPARE(gridview->count(), model.count()); + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + for (int i = 0; i < model.count(); ++i) { + QmlGraphicsText *name = findItem(viewport, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + QmlGraphicsText *number = findItem(viewport, "textNumber", i); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(i)); + } + + gridview->moveCurrentIndexRight(); + QCOMPARE(gridview->currentIndex(), 1); + gridview->moveCurrentIndexDown(); + QCOMPARE(gridview->currentIndex(), 4); + gridview->moveCurrentIndexUp(); + QCOMPARE(gridview->currentIndex(), 1); + gridview->moveCurrentIndexLeft(); + QCOMPARE(gridview->currentIndex(), 0); + + // set an empty model and confirm that items are destroyed + TestModel model2; + ctxt->setContextProperty("testModel", &model2); + + int itemCount = findItems(viewport, "wrapper").count(); + QVERIFY(itemCount == 0); + + delete canvas; +} + +void tst_QmlGraphicsGridView::changed() +{ + QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + + TestModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Billy", "22345"); + model.addItem("Sam", "2945"); + model.addItem("Ben", "04321"); + model.addItem("Jim", "0780"); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsFlickable *gridview = findItem(canvas->root(), "grid"); + QVERIFY(gridview != 0); + + QmlGraphicsItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + model.modifyItem(1, "Will", "9876"); + QmlGraphicsText *name = findItem(viewport, "textName", 1); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(1)); + QmlGraphicsText *number = findItem(viewport, "textNumber", 1); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(1)); + + delete canvas; +} + +void tst_QmlGraphicsGridView::inserted() +{ + QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + + TestModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QVERIFY(gridview != 0); + + QmlGraphicsItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + model.insertItem(1, "Will", "9876"); + + // let transitions settle. + QTest::qWait(300); + + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + QmlGraphicsText *name = findItem(viewport, "textName", 1); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(1)); + QmlGraphicsText *number = findItem(viewport, "textNumber", 1); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(1)); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + model.insertItem(0, "Foo", "1111"); // zero index, and current item + + // let transitions settle. + QTest::qWait(300); + + QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + name = findItem(viewport, "textName", 0); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(0)); + number = findItem(viewport, "textNumber", 0); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(0)); + + QCOMPARE(gridview->currentIndex(), 1); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + for (int i = model.count(); i < 30; ++i) + model.insertItem(i, "Hello", QString::number(i)); + QTest::qWait(300); + + gridview->setViewportY(120); + QTest::qWait(300); + + // Insert item outside visible area + model.insertItem(1, "Hello", "1324"); + QTest::qWait(300); + + QVERIFY(gridview->viewportY() == 120); + + delete canvas; +} + +void tst_QmlGraphicsGridView::removed() +{ + QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QVERIFY(gridview != 0); + + QmlGraphicsItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + model.removeItem(1); + + // let transitions settle. + QTest::qWait(300); + + QmlGraphicsText *name = findItem(viewport, "textName", 1); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(1)); + QmlGraphicsText *number = findItem(viewport, "textNumber", 1); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(1)); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + // Remove first item (which is the current item); + model.removeItem(0); + + // let transitions settle. + QTest::qWait(300); + + name = findItem(viewport, "textName", 0); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(0)); + number = findItem(viewport, "textNumber", 0); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(0)); + + // Confirm items positioned correctly + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + // Remove items not visible + model.removeItem(25); + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + // Remove items before visible + gridview->setViewportY(120); + gridview->setCurrentIndex(10); + + model.removeItem(1); + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly + for (int i = 6; i < 18; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + gridview->setViewportY(0); + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + delete canvas; +} + +void tst_QmlGraphicsGridView::moved() +{ + QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->execute(); + qApp->processEvents(); + + QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QVERIFY(gridview != 0); + + QmlGraphicsItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + model.moveItem(1, 8); + + // let transitions settle. + QTest::qWait(300); + + QmlGraphicsText *name = findItem(viewport, "textName", 1); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(1)); + QmlGraphicsText *number = findItem(viewport, "textNumber", 1); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(1)); + + name = findItem(viewport, "textName", 8); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(8)); + number = findItem(viewport, "textNumber", 8); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(8)); + + // Confirm items positioned correctly + int itemCount = findItems(viewport, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60); + } + + gridview->setViewportY(120); + + // move outside visible area + model.moveItem(1, 25); + + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly and indexes correct + itemCount = findItems(viewport, "wrapper").count(); + for (int i = 3; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QCOMPARE(item->x(), qreal((i%3)*80)); + QCOMPARE(item->y(), qreal((i/3)*60 + 60)); + name = findItem(viewport, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + number = findItem(viewport, "textNumber", i); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(i)); + } + + // move from outside visible into visible + model.moveItem(28, 8); + + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly and indexes correct + for (int i = 3; i < model.count() && i < itemCount; ++i) { + QmlGraphicsItem *item = findItem(viewport, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->x() == (i%3)*80); + QVERIFY(item->y() == (i/3)*60 + 60); + name = findItem(viewport, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + number = findItem(viewport, "textNumber", i); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(i)); + } + + delete canvas; +} + +QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) +{ + QmlView *canvas = new QmlView(0); + canvas->setFixedSize(240,320); + + QFile file(filename); + file.open(QFile::ReadOnly); + QString qml = file.readAll(); + canvas->setQml(qml, filename); + + return canvas; +} + +/* + Find an item with the specified objectName. If index is supplied then the + item must also evaluate the {index} expression equal to index +*/ +template +T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->QGraphicsObject::children().count() << "children"; + for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { + QmlGraphicsItem *item = qobject_cast(parent->QGraphicsObject::children().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QmlExpression e(qmlContext(item), "index", item); + e.setTrackChange(false); + if (e.value().toInt() == index) + return static_cast(item); + } else { + return static_cast(item); + } + } + item = findItem(item, objectName, index); + if (item) + return static_cast(item); + } + + return 0; +} + +template +QList tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QString &objectName) +{ + QList items; + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->QGraphicsObject::children().count() << "children"; + for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { + QmlGraphicsItem *item = qobject_cast(parent->QGraphicsObject::children().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) + items.append(static_cast(item)); + items += findItems(item, objectName); + } + + return items; +} + + +QTEST_MAIN(tst_QmlGraphicsGridView) + +#include "tst_qmlgraphicsgridview.moc" -- cgit v0.12 From 26cae0653332caf0b4e315fd35fd59469c66bac9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 5 Nov 2009 16:59:33 +1000 Subject: Compile. --- tests/auto/declarative/valuetypes/testtypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/valuetypes/testtypes.cpp b/tests/auto/declarative/valuetypes/testtypes.cpp index d57afaf..f0fdaf8 100644 --- a/tests/auto/declarative/valuetypes/testtypes.cpp +++ b/tests/auto/declarative/valuetypes/testtypes.cpp @@ -40,4 +40,4 @@ ****************************************************************************/ #include "testtypes.h" -QML_DEFINE_TYPE(Test, 1, 0, 0, MyTypeObject, MyTypeObject); +QML_DEFINE_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject); -- cgit v0.12