summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-28 12:24:38 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-28 12:28:52 (GMT)
commitf9d6862d13ae38c59ec4a58092c8126620801e0b (patch)
treea9f964410b1b8ef17349014252822a15137a3e3e /tests
parentf85545a53bae8cbfbc0192d4730d181d7525a65d (diff)
downloadQt-f9d6862d13ae38c59ec4a58092c8126620801e0b.zip
Qt-f9d6862d13ae38c59ec4a58092c8126620801e0b.tar.gz
Qt-f9d6862d13ae38c59ec4a58092c8126620801e0b.tar.bz2
QGraphicsItem with parent flag ItemClipsChildrenToShape not visible
Regression against Qt 4.4. Children of items with ItemClipsChildrenToShape would only be discovered if the view's expose region contained the outer bounding rect of all items, _if_ there was at least one item in the scene that enabled ItemIgnoresTransformations. The reason for this bug is that the presence of an untransformable item causes the item lookups to go through a different path (QGraphicsViewPrivate::itemsInArea()). This function had the bug that it didn't correctly discover children of clip-items. Because of this, in the provided test case you could "work around" the bug by either removing the clip flag, or the transformation flag. Task-number: QTBUG-4151 Reviewed-by: Alexis
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index cae8e56..5237963 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -63,6 +63,7 @@
#include <QtGui/QBoxLayout>
#include <QtGui/QStyle>
#include <QtGui/QPushButton>
+#include "../../shared/util.h"
//TESTED_CLASS=
//TESTED_FILES=
@@ -201,6 +202,8 @@ private slots:
void task239047_fitInViewSmallViewport();
void task245469_itemsAtPointWithClip();
void task253415_reconnectUpdateSceneOnSceneChanged();
+ void QTBUG_4151_clipAndIgnore_data();
+ void QTBUG_4151_clipAndIgnore();
};
void tst_QGraphicsView::initTestCase()
@@ -3068,5 +3071,50 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
QVERIFY(wasConnected2);
}
+void tst_QGraphicsView::QTBUG_4151_clipAndIgnore_data()
+{
+ QTest::addColumn<bool>("clip");
+ QTest::addColumn<bool>("ignoreTransformations");
+ QTest::addColumn<int>("numItems");
+
+ QTest::newRow("none") << false << false << 3;
+ QTest::newRow("clip") << true << false << 3;
+ QTest::newRow("ignore") << false << true << 3;
+ QTest::newRow("clip+ignore") << true << true << 3;
+}
+
+void tst_QGraphicsView::QTBUG_4151_clipAndIgnore()
+{
+ QFETCH(bool, clip);
+ QFETCH(bool, ignoreTransformations);
+ QFETCH(int, numItems);
+
+ QGraphicsScene scene;
+
+ QGraphicsRectItem *parent = new QGraphicsRectItem(QRectF(0, 0, 50, 50), 0);
+ QGraphicsRectItem *child = new QGraphicsRectItem(QRectF(-10, -10, 40, 40), parent);
+ QGraphicsRectItem *ignore = new QGraphicsRectItem(QRectF(60, 60, 50, 50), 0);
+
+ if (clip)
+ parent->setFlags(QGraphicsItem::ItemClipsChildrenToShape);
+ if (ignoreTransformations)
+ ignore->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+
+ parent->setBrush(Qt::red);
+ child->setBrush(QColor(0, 0, 255, 128));
+ ignore->setBrush(Qt::green);
+
+ scene.addItem(parent);
+ scene.addItem(ignore);
+
+ QGraphicsView view(&scene);
+ view.setFrameStyle(0);
+ view.resize(75, 75);
+ view.show();
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+
+ QCOMPARE(view.items(view.rect()).size(), numItems);
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"