diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-10-06 07:19:08 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-10-06 07:24:00 (GMT) |
commit | 3da33626c056169f5fadf94f12997180cb3a08b4 (patch) | |
tree | 12fca08483dca8dc83497ed53ee688d941b224d1 /tests | |
parent | 771f2d93ba063591343578b6cdb3c18a6a09c49c (diff) | |
download | Qt-3da33626c056169f5fadf94f12997180cb3a08b4.zip Qt-3da33626c056169f5fadf94f12997180cb3a08b4.tar.gz Qt-3da33626c056169f5fadf94f12997180cb3a08b4.tar.bz2 |
Fix the pad navigator demo.
QGraphicsWidget used to called setPosHelper where all the logic was.
But since the new flag itemSendsGeometryChanges some part of the code
inside setPosHelper move back to setPos. QGraphicsWidget was not updated
after this change. It doesn't matter as it is but for QGraphicsProxyWidget
which activate the flag itemSendsGeometryChanges it matters. ItemChange
was never called so the proxy was never really moved.
Task-number:QT-672
Reviewed-by:andreas
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 0b73733..26021e0 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -157,6 +157,7 @@ private slots: void shortcutsDeletion(); void painterStateProtectionOnWindowFrame(); void ensureClipping(); + void widgetSendsGeometryChanges(); void respectHFW(); // Task fixes @@ -2562,6 +2563,76 @@ void tst_QGraphicsWidget::ensureClipping() QVERIFY(scene.drawnItems.contains(childitem)); } +class ItemChangeTester : public QGraphicsWidget +{ +public: + ItemChangeTester() + { setFlag(ItemSendsGeometryChanges); clear(); } + ItemChangeTester(QGraphicsItem *parent) : QGraphicsWidget(parent) + { setFlag(ItemSendsGeometryChanges); clear(); } + + void clear() + { + changes.clear(); + values.clear(); + oldValues.clear(); + } + QList<GraphicsItemChange> changes; + QList<QVariant> values; + QList<QVariant> oldValues; +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value) + { + changes << change; + values << value; + switch (change) { + case QGraphicsItem::ItemPositionChange: + oldValues << pos(); + break; + case QGraphicsItem::ItemPositionHasChanged: + break; + default: + break; + } + return value; + } +}; + +void tst_QGraphicsWidget::widgetSendsGeometryChanges() +{ + ItemChangeTester widget; + widget.setFlags(0); + widget.clear(); + + QPointF pos(10, 10); + widget.setPos(pos); + + QCOMPARE(widget.pos(), pos); + QCOMPARE(widget.changes.size(), 0); + + widget.setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + QCOMPARE(widget.changes.size(), 2); + + widget.setPos(QPointF()); + QCOMPARE(widget.changes.size(), 4); + + QCOMPARE(widget.pos(), QPointF()); + + QRectF geometry(20, 20, 50, 50); + widget.setGeometry(geometry); + QCOMPARE(widget.changes.size(), 6); + + QCOMPARE(widget.geometry(), geometry); + + QCOMPARE(widget.changes, QList<QGraphicsItem::GraphicsItemChange>() + << QGraphicsItem::ItemFlagsChange + << QGraphicsItem::ItemFlagsHaveChanged + << QGraphicsItem::ItemPositionChange + << QGraphicsItem::ItemPositionHasChanged + << QGraphicsItem::ItemPositionChange + << QGraphicsItem::ItemPositionHasChanged); +} + class HFWWidget : public QGraphicsWidget { public: |