From 8d1f218f6b11cff798bcd0b3123a2fe38c4a4142 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 5 Jun 2009 13:46:29 +0200 Subject: QGraphicsItem::setOpacity(0.0) does not trigger an update of child items Forwarding the ignoreOpacity flag to children in QGraphicsItemPrivate::fullUpdateHelper. This is a complementary fix to task 252913, partly fixed in commit 2e3a5ea44... Reviewed-by: bnilsen BT: yes --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 51 +++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 34a6ab18d0..30174079d8 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -207,6 +207,7 @@ private slots: void opacity_data(); void opacity(); void opacity2(); + void opacityZeroUpdates(); void itemStacksBehindParent(); void nestedClipping(); void nestedClippingTransforms(); @@ -5498,7 +5499,7 @@ void tst_QGraphicsItem::itemTransform_unrelated() QCOMPARE(stranger1->itemTransform(stranger2).map(QPointF(10, 10)), QPointF(10, 10)); QCOMPARE(stranger2->itemTransform(stranger1).map(QPointF(10, 10)), QPointF(10, 10)); } - + void tst_QGraphicsItem::opacity_data() { QTest::addColumn("p_opacity"); @@ -5693,6 +5694,54 @@ void tst_QGraphicsItem::opacity2() QCOMPARE(grandChild->repaints, 0); } +void tst_QGraphicsItem::opacityZeroUpdates() +{ + EventTester *parent = new EventTester; + EventTester *child = new EventTester(parent); + + child->setPos(10, 10); + + QGraphicsScene scene; + scene.addItem(parent); + + class MyGraphicsView : public QGraphicsView + { public: + int repaints; + QRegion paintedRegion; + MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {} + void paintEvent(QPaintEvent *e) + { + ++repaints; + paintedRegion += e->region(); + QGraphicsView::paintEvent(e); + } + void reset() { repaints = 0; paintedRegion = QRegion(); } + }; + + MyGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + + view.reset(); + parent->setOpacity(0.0); + + QTest::qWait(200); + + // transforming items bounding rect to view coordinates + const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) + .mapRect(child->boundingRect()).toRect(); + const QRect parentDeviceBoundingRect = parent->deviceTransform(view.viewportTransform()) + .mapRect(parent->boundingRect()).toRect(); + + QRegion expectedRegion = parentDeviceBoundingRect.adjusted(-2, -2, 2, 2); + expectedRegion += childDeviceBoundingRect.adjusted(-2, -2, 2, 2); + + QCOMPARE(view.paintedRegion, expectedRegion); +} + void tst_QGraphicsItem::itemStacksBehindParent() { QGraphicsRectItem *parent1 = new QGraphicsRectItem(QRectF(0, 0, 100, 50)); -- cgit v1.2.1