diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2012-12-03 07:03:02 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-05 04:09:00 (GMT) |
commit | a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6 (patch) | |
tree | 85020b7051d0985c475933cfd35d5244484ab692 /tests | |
parent | c74b83d9baca9210588f7ee107e10f2dffffdc73 (diff) | |
download | Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.zip Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.tar.gz Qt-a1e8e908d575c79b3ac3c96f6aba7bee6beb62f6.tar.bz2 |
Clear focus of GraphicsItem focus scopes and their children.
A focus scope has effective focus if one of its children is the focus item,
clearFocus() should remove effective focus from an item and its children
not just from the focus item.
Task-number: QTBUG-28328
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
(cherry picked from commit ab97a44b6ae5cc826460f3704669383afd398594)
Change-Id: Ib6f43b40091cb1bb1a0d5b8b9ac71e44f35b037b
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index c087463..2c56dbc 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9220,6 +9220,45 @@ void tst_QGraphicsItem::focusScope() scope3->setFocus(); QVERIFY(scope3->hasFocus()); + // clearFocus() on a focus scope will remove focus from its children. + scope1->clearFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(!scope3->hasFocus()); + + scope1->setFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(scope3->hasFocus()); + + scope2->clearFocus(); + QVERIFY(scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(!scope3->hasFocus()); + + scope2->setFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(scope3->hasFocus()); + + // Focus cleared while a parent doesn't have focus remains cleared + // when the parent regains focus. + scope1->clearFocus(); + scope3->clearFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(!scope3->hasFocus()); + + scope1->setFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(scope2->hasFocus()); + QVERIFY(!scope3->hasFocus()); + + scope3->setFocus(); + QVERIFY(!scope1->hasFocus()); + QVERIFY(!scope2->hasFocus()); + QVERIFY(scope3->hasFocus()); + QGraphicsRectItem *rect4 = new QGraphicsRectItem; rect4->setData(0, "rect4"); rect4->setParentItem(scope3); |