summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-06 07:19:08 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-06 07:24:00 (GMT)
commit3da33626c056169f5fadf94f12997180cb3a08b4 (patch)
tree12fca08483dca8dc83497ed53ee688d941b224d1
parent771f2d93ba063591343578b6cdb3c18a6a09c49c (diff)
downloadQt-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
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp2
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp71
2 files changed, 72 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 7764157..35a3c13 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -347,7 +347,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
// setPos triggers ItemPositionChange, which can adjust position
wd->inSetGeometry = 1;
- wd->setPosHelper(newGeom.topLeft());
+ setPos(newGeom.topLeft());
wd->inSetGeometry = 0;
newGeom.moveTopLeft(pos());
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: