summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2009-10-06 07:24:55 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-10-06 07:24:55 (GMT)
commitb1c5547c5682e57b746e3bc8ac616ebbd23c12b8 (patch)
tree31dd27005934dcb520ee8ef127c2cc22b1c472d7
parent231d8d7c02161e93b3a97a1bacb3c402f16e1fcb (diff)
parent3da33626c056169f5fadf94f12997180cb3a08b4 (diff)
downloadQt-b1c5547c5682e57b746e3bc8ac616ebbd23c12b8.zip
Qt-b1c5547c5682e57b746e3bc8ac616ebbd23c12b8.tar.gz
Qt-b1c5547c5682e57b746e3bc8ac616ebbd23c12b8.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-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: