summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-05-27 12:56:26 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-05-27 12:56:26 (GMT)
commit54972a8a888ab73b7492dd0115327063bfdaff85 (patch)
tree61373a6300495bc69626125785b9193dbc97872a
parent2c1b11f2192fd48da01a1093a7cb4a848de43c8a (diff)
parent3a61a448b92b4f7c7ee02196340d3bcb75d067fb (diff)
downloadQt-54972a8a888ab73b7492dd0115327063bfdaff85.zip
Qt-54972a8a888ab73b7492dd0115327063bfdaff85.tar.gz
Qt-54972a8a888ab73b7492dd0115327063bfdaff85.tar.bz2
Integrate merge-request #407 into branch 'test'
diaulas (1): Dont show children when parent is not visible in QGraphicsItem Request-url: http://qt.gitorious.org/qt/qt/merge_requests/407 Reviewed-by: Leonardo Sobral Cunha <leo.cunha@nokia.com>
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp5
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp32
2 files changed, 37 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 4908296..b6a7386 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1522,6 +1522,11 @@ 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) {
+ return;
+ }
+
// Modify the property.
const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
quint32(newVisible)));
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 58a17ea..d477135 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -123,6 +123,7 @@ private slots:
void destruction();
void scene();
void parentItem();
+ void childrenVisibility();
void setParentItem();
void children();
void flags();
@@ -549,6 +550,37 @@ 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;