diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-05 12:11:03 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-11-06 11:19:26 (GMT) |
commit | f8a0b7b9ea2e077be7167c58d4eac27360d4cee6 (patch) | |
tree | 8da241b063829cdd910277ebe0ed22032c2819c4 /tests/auto/qgraphicsscene | |
parent | 3433bc44168398734cdd53df9b64adf016c8ab3b (diff) | |
download | Qt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.zip Qt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.tar.gz Qt-f8a0b7b9ea2e077be7167c58d4eac27360d4cee6.tar.bz2 |
QGraphicsView: Fixes QGraphicsView::focusItem when scene is not active
When scene is not active, returns the item that would get the focus if
the scene became active.
This is more consistant with Qt 4.5 behaviour
Reviewed-by: Andreas
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 4f76ddd..c81bd64 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -225,6 +225,7 @@ private slots: void focusItem(); void focusItemLostFocus(); void setFocusItem(); + void setFocusItem_inactive(); void mouseGrabberItem(); void hoverEvents_siblings(); void hoverEvents_parentChild(); @@ -1534,6 +1535,26 @@ void tst_QGraphicsScene::setFocusItem() QVERIFY(!item2->hasFocus()); } +void tst_QGraphicsScene::setFocusItem_inactive() +{ + QGraphicsScene scene; + QGraphicsItem *item = scene.addText("Qt"); + QVERIFY(!scene.focusItem()); + QVERIFY(!scene.hasFocus()); + scene.setFocusItem(item); + QVERIFY(!scene.hasFocus()); + QVERIFY(!scene.focusItem()); + item->setFlag(QGraphicsItem::ItemIsFocusable); + + for (int i = 0; i < 3; ++i) { + scene.setFocusItem(item); + QCOMPARE(scene.focusItem(), item); + QVERIFY(!item->hasFocus()); + } + +} + + void tst_QGraphicsScene::mouseGrabberItem() { QGraphicsScene scene; @@ -3130,6 +3151,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!item->hasFocus()); + QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item)); // Check that the correct item regains focus. widget.show(); |