diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-16 23:17:08 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-16 23:17:08 (GMT) |
commit | 6e1f1d76b5bef03e44a2ec48a1a9359145dfca74 (patch) | |
tree | 2c77488c22262b9d74228bdd54a89c4269aa5af6 | |
parent | 82440843435b8bf02391fae1c9df6f081a945a65 (diff) | |
parent | c6867a620259ee6c82a038995f424bef63d45aea (diff) | |
download | Qt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.zip Qt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.tar.gz Qt-6e1f1d76b5bef03e44a2ec48a1a9359145dfca74.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Add missing auto test files.
Fix game could not be restarted
Handle QGraphicsWidgets in Flickable
More positioners with QGraphicsWidgets fixes.
Make positioners work with QGraphicsWidgets also
emit countChanged where appropriate in Repeater
12 files changed, 202 insertions, 69 deletions
diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js index 0f0dbf7..fab7834 100644 --- a/demos/declarative/snake/content/snake.js +++ b/demos/declarative/snake/content/snake.js @@ -35,9 +35,12 @@ function startNewGame() if (heartbeat.running) { endGame(); startNewGameTimer.running = true; + state = "starting"; return; } + state = "starting"; + numRows = numRowsAvailable; numColumns = numColumnsAvailable; board = new Array(numRows * numColumns); @@ -80,7 +83,6 @@ function startNewGame() waitForCookie = 5; score = 0; startHeartbeatTimer.running = true; - heartbeat.running = true; } function endGame() @@ -94,6 +96,7 @@ function endGame() } lastScore = score; highScores.saveScore(lastScore); + state = ""; } function move() { diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index b1344af..ed3bac9 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -94,6 +94,7 @@ Rectangle { Timer { id: startHeartbeatTimer; interval: 1000 ; + onTriggered: { state = "running"; heartbeat.running = true; } } @@ -208,21 +209,6 @@ Rectangle { Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); - Connections { - target: startHeartbeatTimer - onRunningChanged: { - if (startHeartbeatTimer.running) - screen.state = "starting"; - else - screen.state = "running" - } - } - Connections { - target: heartbeat - onRunningChanged: if (!heartbeat.running) screen.state = ""; - } - - states: [ State { name: "starting" diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 31f7707..7fee44e 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1029,7 +1029,7 @@ void QDeclarativeFlickable::cancelFlick() void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) { - QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o); + QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o); if (i) i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem); else diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 5c21b03..4ceb5d9 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -61,16 +61,37 @@ static const QDeclarativeItemPrivate::ChangeTypes watchedChanges | QDeclarativeItemPrivate::Opacity | QDeclarativeItemPrivate::Destroyed; -void QDeclarativeBasePositionerPrivate::watchChanges(QDeclarativeItem *other) +void QDeclarativeBasePositionerPrivate::watchChanges(QGraphicsObject *other) { - QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other)); - otherPrivate->addItemChangeListener(this, watchedChanges); + if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { + QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other)); + otherPrivate->addItemChangeListener(this, watchedChanges); + } else { + Q_Q(QDeclarativeBasePositioner); + QObject::connect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::connect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::connect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::connect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + } } -void QDeclarativeBasePositionerPrivate::unwatchChanges(QDeclarativeItem* other) +void QDeclarativeBasePositionerPrivate::unwatchChanges(QGraphicsObject* other) { - QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other)); - otherPrivate->removeItemChangeListener(this, watchedChanges); + if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { + QDeclarativeItemPrivate *otherPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(other)); + otherPrivate->removeItemChangeListener(this, watchedChanges); + } else { + Q_Q(QDeclarativeBasePositioner); + QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + QObject::disconnect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged())); + } +} + +void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged() +{ + prePositioning(); } /*! @@ -174,16 +195,16 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, Q_D(QDeclarativeBasePositioner); if (change == ItemChildAddedChange){ QGraphicsItem* item = value.value<QGraphicsItem*>(); - QDeclarativeItem* child = 0; + QGraphicsObject* child = 0; if(item) - child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject()); + child = item->toGraphicsObject(); if (child) prePositioning(); } else if (change == ItemChildRemovedChange) { QGraphicsItem* item = value.value<QGraphicsItem*>(); - QDeclarativeItem* child = 0; + QGraphicsObject* child = 0; if(item) - child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject()); + child = item->toGraphicsObject(); if (child) { QDeclarativeBasePositioner::PositionedItem posItem(child); int idx = positionedItems.find(posItem); @@ -194,7 +215,6 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, prePositioning(); } } - return QDeclarativeItem::itemChange(change, value); } @@ -216,10 +236,10 @@ void QDeclarativeBasePositioner::prePositioning() QPODVector<PositionedItem,8> oldItems; positionedItems.copyAndClear(oldItems); for (int ii = 0; ii < children.count(); ++ii) { - QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii)); + QGraphicsObject *child = children.at(ii)->toGraphicsObject(); if (!child) continue; - QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child)); + QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child)); PositionedItem *item = 0; PositionedItem posItem(child); int wIdx = oldItems.find(posItem); @@ -302,10 +322,10 @@ void QDeclarativeBasePositioner::finishApplyTransitions() d->moveActions.clear(); } -static inline bool isInvisible(QDeclarativeItem *child) +static inline bool isInvisible(QGraphicsObject *child) { - QDeclarativeItemPrivate *childPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(child)); - return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !child->width() || !child->height(); + QGraphicsItemPrivate *childPrivate = static_cast<QGraphicsItemPrivate*>(QGraphicsItemPrivate::get(child)); + return child->opacity() == 0.0 || childPrivate->explicitlyHidden || !childPrivate->width() || !childPrivate->height(); } /*! @@ -441,9 +461,9 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize) if(child.item->y() != voffset) positionY(voffset, child); - contentSize->setWidth(qMax(contentSize->width(), child.item->width())); + contentSize->setWidth(qMax(contentSize->width(), QGraphicsItemPrivate::get(child.item)->width())); - voffset += child.item->height(); + voffset += QGraphicsItemPrivate::get(child.item)->height(); voffset += spacing(); } @@ -455,8 +475,8 @@ void QDeclarativeColumn::reportConflictingAnchors() QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; + if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { + QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors; if (anchors) { QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::TopAnchor || @@ -581,9 +601,9 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize) if(child.item->x() != hoffset) positionX(hoffset, child); - contentSize->setHeight(qMax(contentSize->height(), child.item->height())); + contentSize->setHeight(qMax(contentSize->height(), QGraphicsItemPrivate::get(child.item)->height())); - hoffset += child.item->width(); + hoffset += QGraphicsItemPrivate::get(child.item)->width(); hoffset += spacing(); } @@ -595,8 +615,8 @@ void QDeclarativeRow::reportConflictingAnchors() QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; + if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { + QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors; if (anchors) { QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::LeftAnchor || @@ -817,10 +837,11 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) const PositionedItem &child = positionedItems.at(childIndex++); if (!child.item || isInvisible(child.item)) continue; - if (child.item->width() > maxColWidth[j]) - maxColWidth[j] = child.item->width(); - if (child.item->height() > maxRowHeight[i]) - maxRowHeight[i] = child.item->height(); + QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); + if (childPrivate->width() > maxColWidth[j]) + maxColWidth[j] = childPrivate->width(); + if (childPrivate->height() > maxRowHeight[i]) + maxRowHeight[i] = childPrivate->height(); } } } else { @@ -836,10 +857,11 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) const PositionedItem &child = positionedItems.at(childIndex++); if (!child.item || isInvisible(child.item)) continue; - if (child.item->width() > maxColWidth[j]) - maxColWidth[j] = child.item->width(); - if (child.item->height() > maxRowHeight[i]) - maxRowHeight[i] = child.item->height(); + QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); + if (childPrivate->width() > maxColWidth[j]) + maxColWidth[j] = childPrivate->width(); + if (childPrivate->height() > maxRowHeight[i]) + maxRowHeight[i] = childPrivate->height(); } } } @@ -858,7 +880,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) } if (m_flow == LeftToRight) { - contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width())); + contentSize->setWidth(qMax(contentSize->width(), xoffset + QGraphicsItemPrivate::get(child.item)->width())); contentSize->setHeight(yoffset + maxRowHeight[curRow]); xoffset+=maxColWidth[curCol]+spacing(); @@ -872,7 +894,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) break; } } else { - contentSize->setHeight(qMax(contentSize->height(), yoffset + child.item->height())); + contentSize->setHeight(qMax(contentSize->height(), yoffset + QGraphicsItemPrivate::get(child.item)->height())); contentSize->setWidth(xoffset + maxColWidth[curCol]); yoffset+=maxRowHeight[curRow]+spacing(); @@ -894,8 +916,8 @@ void QDeclarativeGrid::reportConflictingAnchors() QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; + if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { + QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors; if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { d->anchorConflict = true; break; @@ -1030,14 +1052,15 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) if (!child.item || isInvisible(child.item)) continue; + QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); if (d->flow == LeftToRight) { - if (widthValid() && hoffset && hoffset + child.item->width() > width()) { + if (widthValid() && hoffset && hoffset + childPrivate->width() > width()) { hoffset = 0; voffset += linemax + spacing(); linemax = 0; } } else { - if (heightValid() && voffset && voffset + child.item->height() > height()) { + if (heightValid() && voffset && voffset + childPrivate->height() > height()) { voffset = 0; hoffset += linemax + spacing(); linemax = 0; @@ -1049,17 +1072,17 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) positionY(voffset, child); } - contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width())); - contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height())); + contentSize->setWidth(qMax(contentSize->width(), hoffset + childPrivate->width())); + contentSize->setHeight(qMax(contentSize->height(), voffset + childPrivate->height())); if (d->flow == LeftToRight) { - hoffset += child.item->width(); + hoffset += childPrivate->width(); hoffset += spacing(); - linemax = qMax(linemax, qCeil(child.item->height())); + linemax = qMax(linemax, qCeil(childPrivate->height())); } else { - voffset += child.item->height(); + voffset += childPrivate->height(); voffset += spacing(); - linemax = qMax(linemax, qCeil(child.item->width())); + linemax = qMax(linemax, qCeil(childPrivate->width())); } } } @@ -1069,8 +1092,8 @@ void QDeclarativeFlow::reportConflictingAnchors() Q_D(QDeclarativeFlow); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(child.item)->_anchors; + if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { + QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast<QDeclarativeItem *>(child.item))->_anchors; if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { d->anchorConflict = true; break; diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index c03e518..f9ecc0a 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -91,14 +91,16 @@ Q_SIGNALS: protected Q_SLOTS: void prePositioning(); + void graphicsWidgetGeometryChanged(); protected: virtual void doPositioning(QSizeF *contentSize)=0; virtual void reportConflictingAnchors()=0; - struct PositionedItem { - PositionedItem(QDeclarativeItem *i) : item(i), isNew(false), isVisible(true) {} + class PositionedItem { + public : + PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {} bool operator==(const PositionedItem &other) const { return other.item == item; } - QDeclarativeItem *item; + QGraphicsObject *item; bool isNew; bool isVisible; }; diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h index 822079b..35946e9 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h @@ -94,8 +94,8 @@ public: QDeclarativeTransitionManager addTransitionManager; QDeclarativeTransitionManager moveTransitionManager; - void watchChanges(QDeclarativeItem *other); - void unwatchChanges(QDeclarativeItem* other); + void watchChanges(QGraphicsObject *other); + void unwatchChanges(QGraphicsObject* other); bool queuedPositioning : 1; bool doingPositioning : 1; bool anchorConflict : 1; @@ -123,6 +123,7 @@ public: if (newGeometry.size() != oldGeometry.size()) q->prePositioning(); } + virtual void itemVisibilityChanged(QDeclarativeItem *) { schedulePositioning(); diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 8828d3e..4a951a2 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -246,8 +246,8 @@ void QDeclarativeRepeater::setModel(const QVariant &model) connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); */ regenerate(); - emit countChanged(); } + emit countChanged(); } /*! @@ -378,6 +378,7 @@ void QDeclarativeRepeater::itemsInserted(int index, int count) d->deletables.insert(modelIndex, item); } } + emit countChanged(); } void QDeclarativeRepeater::itemsRemoved(int index, int count) @@ -392,6 +393,7 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count) else break; } + emit countChanged(); } void QDeclarativeRepeater::itemsMoved(int from, int to, int count) @@ -421,6 +423,7 @@ void QDeclarativeRepeater::modelReset() if (!isComponentComplete()) return; regenerate(); + emit countChanged(); } QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml new file mode 100644 index 0000000..8e95a94 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Flickable { + width: 100; height: 100 + + QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 } +} diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 678996b..e7ded8a 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -44,6 +44,7 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativeflickable_p.h> #include <private/qdeclarativevaluetype_p.h> +#include <QtGui/qgraphicswidget.h> #include <math.h> #ifdef Q_OS_SYMBIAN @@ -67,9 +68,13 @@ private slots: void flickDeceleration(); void pressDelay(); void flickableDirection(); + void qgraphicswidget(); private: QDeclarativeEngine engine; + + template<typename T> + T *findItem(QGraphicsObject *parent, const QString &objectName); }; tst_qdeclarativeflickable::tst_qdeclarativeflickable() @@ -261,6 +266,38 @@ void tst_qdeclarativeflickable::flickableDirection() QCOMPARE(spy.count(),3); } +void tst_qdeclarativeflickable::qgraphicswidget() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(c.create()); + + QVERIFY(flickable != 0); + QGraphicsWidget *widget = findItem<QGraphicsWidget>(flickable->contentItem(), "widget1"); + QVERIFY(widget); +} + +template<typename T> +T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) +{ + const QMetaObject &mo = T::staticMetaObject; + //qDebug() << parent->childItems().count() << "children"; + for (int i = 0; i < parent->childItems().count(); ++i) { + QGraphicsObject *item = qobject_cast<QGraphicsObject*>(parent->childItems().at(i)); + if(!item) + continue; + //qDebug() << "try" << item; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + return static_cast<T*>(item); + } + item = findItem<T>(item, objectName); + if (item) + return static_cast<T*>(item); + } + + return 0; +} + QTEST_MAIN(tst_qdeclarativeflickable) #include "tst_qdeclarativeflickable.moc" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml new file mode 100644 index 0000000..c9c8607 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml @@ -0,0 +1,24 @@ +import Qt 4.7 + +Item { + width: 640 + height: 480 + Column { + objectName: "column" + QGraphicsWidget { + objectName: "one" + width: 50 + height: 50 + } + QGraphicsWidget { + objectName: "two" + width: 20 + height: 10 + } + QGraphicsWidget { + objectName: "three" + width: 40 + height: 20 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 0663991..887be50 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -46,6 +46,7 @@ #include <private/qdeclarativepositioners_p.h> #include <private/qdeclarativetransition_p.h> #include <qdeclarativeexpression.h> +#include <QtGui/qgraphicswidget.h> #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -77,6 +78,7 @@ private slots: void test_flow_resize(); void test_flow_implicit_resize(); void test_conflictinganchors(); + void test_vertical_qgraphicswidget(); private: QDeclarativeView *createView(const QString &filename); }; @@ -771,6 +773,48 @@ void tst_QDeclarativePositioners::test_conflictinganchors() QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); } +void tst_QDeclarativePositioners::test_vertical_qgraphicswidget() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml"); + + QGraphicsWidget *one = canvas->rootObject()->findChild<QGraphicsWidget*>("one"); + QVERIFY(one != 0); + + QGraphicsWidget *two = canvas->rootObject()->findChild<QGraphicsWidget*>("two"); + QVERIFY(two != 0); + + QGraphicsWidget *three = canvas->rootObject()->findChild<QGraphicsWidget*>("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 60.0); + + QDeclarativeItem *column = canvas->rootObject()->findChild<QDeclarativeItem*>("column"); + QVERIFY(column); + QCOMPARE(column->height(), 80.0); + QCOMPARE(column->width(), 50.0); + + two->resize(QSizeF(two->size().width(), 20.0)); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 70.0); + + two->setOpacity(0.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 50.0); + + one->setVisible(false); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 0.0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 623b3d7..360d90f 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -309,11 +309,14 @@ void tst_QDeclarativeRepeater::dataModel() QCOMPARE(container->childItems().count(), 4); + QSignalSpy repeaterSpy(repeater, SIGNAL(countChanged())); testModel.addItem("four", "4"); QCOMPARE(container->childItems().count(), 5); + QCOMPARE(repeaterSpy.count(),1); testModel.removeItem(2); QCOMPARE(container->childItems().count(), 4); + QCOMPARE(repeaterSpy.count(),2); // Check that model changes are propagated QDeclarativeText *text = findItem<QDeclarativeText>(canvas->rootObject(), "myName", 1); |