summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-02 09:33:40 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-02 09:40:09 (GMT)
commit0573653f830fada99311c88ab46e8f5a37854b90 (patch)
tree9790c50179e57922e457c757af798d2f1543611f /tests
parentf1b22116ad94472a6f24a376cf3709a272870478 (diff)
downloadQt-0573653f830fada99311c88ab46e8f5a37854b90.zip
Qt-0573653f830fada99311c88ab46e8f5a37854b90.tar.gz
Qt-0573653f830fada99311c88ab46e8f5a37854b90.tar.bz2
Fix a bug when clipsChildrenToShape is set back to false.
If you set the flag itemClipsChildrenToShape to true on a parent, an optimization was made in 4.5.0 to not add children of this parent in the index. But when you set the flag back to false all the sub-tree of the parent should be re-added to the index otherwise the index will never find all children. This code is not relevant for 4.6 since the index part of QGraphicsView has been refactored and handle this case with itemChange in QGraphicsSceneIndex. Reviewed-by:andreas
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 55e9b34..215334c 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -47,12 +47,14 @@
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
#include <QCursor>
+#include <QLabel>
#include <QDial>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneEvent>
#include <QGraphicsView>
#include <QGraphicsWidget>
+#include <QGraphicsProxyWidget>
#include <QPainter>
#include <QScrollBar>
#include <QVBoxLayout>
@@ -196,6 +198,7 @@ private slots:
void itemClipsChildrenToShape();
void itemClipsChildrenToShape2();
void itemClipsChildrenToShape3();
+ void itemClipsChildrenToShape4();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
void ancestorFlags();
@@ -4724,6 +4727,44 @@ void tst_QGraphicsItem::itemClipsChildrenToShape3()
QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0);
}
+class MyProxyWidget : public QGraphicsProxyWidget
+{
+public:
+ MyProxyWidget(QGraphicsItem *parent) : QGraphicsProxyWidget(parent)
+ {
+ painted = false;
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ QGraphicsProxyWidget::paint(painter, option, widget);
+ painted = true;
+ }
+ bool painted;
+};
+
+void tst_QGraphicsItem::itemClipsChildrenToShape4()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsWidget * outerWidget = new QGraphicsWidget();
+ outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
+ MyProxyWidget * innerWidget = new MyProxyWidget(outerWidget);
+ QLabel * label = new QLabel();
+ label->setText("Welcome back my friends to the show that never ends...");
+ innerWidget->setWidget(label);
+ view.resize(300, 300);
+ scene.addItem(outerWidget);
+ outerWidget->resize( 200, 100 );
+ scene.addEllipse( 100, 100, 100, 50 ); // <-- this is important to trigger the right codepath*
+ //now the label is shown
+ outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false );
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+ QTRY_COMPARE(innerWidget->painted, true);
+}
void tst_QGraphicsItem::itemClipsTextChildToShape()
{