diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-05-27 13:03:00 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-05-27 13:03:00 (GMT) |
commit | 5675d15eebd76fde43bc9305347c3b7833a7d893 (patch) | |
tree | 30059b7bab3a6c73f6e3ee2562ec16eb01cee754 | |
parent | 54972a8a888ab73b7492dd0115327063bfdaff85 (diff) | |
download | Qt-5675d15eebd76fde43bc9305347c3b7833a7d893.zip Qt-5675d15eebd76fde43bc9305347c3b7833a7d893.tar.gz Qt-5675d15eebd76fde43bc9305347c3b7833a7d893.tar.bz2 |
Fixes for merge-request #407
Removed unused line and added task number to autotest.
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 70 |
2 files changed, 39 insertions, 36 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b6a7386..e8ace65 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1522,10 +1522,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo if (visible == quint32(newVisible)) return; - QGraphicsItem *parent(q_ptr->parentItem()); - if (parent && newVisible && !parent->d_ptr->visible) { + // Don't show child if parent is not visible + if (parent && newVisible && !parent->d_ptr->visible) return; - } // Modify the property. const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index d477135..34a6ab1 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -123,7 +123,6 @@ private slots: void destruction(); void scene(); void parentItem(); - void childrenVisibility(); void setParentItem(); void children(); void flags(); @@ -227,6 +226,7 @@ private slots: void task240400_clickOnTextItem_data(); void task240400_clickOnTextItem(); void task243707_addChildBeforeParent(); + void task197802_childrenVisibility(); }; void tst_QGraphicsItem::init() @@ -550,37 +550,6 @@ void tst_QGraphicsItem::parentItem() delete item2; } -void tst_QGraphicsItem::childrenVisibility() -{ - QGraphicsScene scene; - QGraphicsRectItem item(QRectF(0,0,20,20)); - - QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(0,0,10,10), &item); - scene.addItem(&item); - - //freshly created: both visible - QVERIFY(item.isVisible()); - QVERIFY(item2->isVisible()); - //hide child: parent visible, child not - item2->hide(); - QVERIFY(item.isVisible()); - QVERIFY(!item2->isVisible()); - //hide parent: parent and child invisible - item.hide(); - QVERIFY(!item.isVisible()); - QVERIFY(!item2->isVisible()); - //ask to show the child: parent and child invisible anyways - item2->show(); - QVERIFY(!item.isVisible()); - QVERIFY(!item2->isVisible()); - //show the parent: both parent and child visible - item.show(); - QVERIFY(item.isVisible()); - QVERIFY(item2->isVisible()); - - delete item2; -} - void tst_QGraphicsItem::setParentItem() { QGraphicsScene scene; @@ -5378,7 +5347,7 @@ void tst_QGraphicsItem::task243707_addChildBeforeParent() // inconsistent internal state that can cause a crash. This test shows // one such crash. QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget *widget = new QGraphicsWidget; QGraphicsWidget *widget2 = new QGraphicsWidget(widget); scene.addItem(widget2); QVERIFY(!widget2->parentItem()); @@ -5387,6 +5356,41 @@ void tst_QGraphicsItem::task243707_addChildBeforeParent() QVERIFY(!widget2->commonAncestorItem(widget)); } +void tst_QGraphicsItem::task197802_childrenVisibility() +{ + QGraphicsScene scene; + QGraphicsRectItem item(QRectF(0,0,20,20)); + + QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(0,0,10,10), &item); + scene.addItem(&item); + + //freshly created: both visible + QVERIFY(item.isVisible()); + QVERIFY(item2->isVisible()); + + //hide child: parent visible, child not + item2->hide(); + QVERIFY(item.isVisible()); + QVERIFY(!item2->isVisible()); + + //hide parent: parent and child invisible + item.hide(); + QVERIFY(!item.isVisible()); + QVERIFY(!item2->isVisible()); + + //ask to show the child: parent and child invisible anyways + item2->show(); + QVERIFY(!item.isVisible()); + QVERIFY(!item2->isVisible()); + + //show the parent: both parent and child visible + item.show(); + QVERIFY(item.isVisible()); + QVERIFY(item2->isVisible()); + + delete item2; +} + void tst_QGraphicsItem::boundingRegion_data() { QTest::addColumn<QLineF>("line"); |