diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:23:15 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:33:18 (GMT) |
commit | 21806ff0921641b4e4d9d39721ab4ebeae74dddc (patch) | |
tree | 6f854d6279385c120986f0288eb997373058106a /tests/auto/declarative/qdeclarativefocusscope | |
parent | 4f6e480acce94d8ae920c3eda4879fc4f9cb2598 (diff) | |
download | Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.zip Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.gz Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.bz2 |
QML focus API updates.
The wantsFocus property has been renamed to activeFocus, to better
reflect its value. Reading and writing the focus property is also now
consistent -- this property represents focus within a scope. Other small
changes were made to keep things consistent with the new naming.
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/auto/declarative/qdeclarativefocusscope')
8 files changed, 104 insertions, 109 deletions
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml index 6c39f20..42b50cf 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml @@ -4,11 +4,11 @@ Rectangle { id: root width:300; height:400 - property bool focus1: root.wantsFocus - property bool focus2: item1.wantsFocus - property bool focus3: fs1.wantsFocus - property bool focus4: fs2.wantsFocus - property bool focus5: theItem.wantsFocus + property bool focus1: root.activeFocus + property bool focus2: item1.activeFocus + property bool focus3: fs1.activeFocus + property bool focus4: fs2.activeFocus + property bool focus5: theItem.activeFocus Item { id: item1 diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml index af9c420..9144854 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml @@ -15,28 +15,28 @@ Rectangle { height: 120; width: 420 color: "transparent" - border.width: 5; border.color: firstScope.wantsFocus?"blue":"black" + border.width: 5; border.color: firstScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item2; objectName: "item2" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -50,32 +50,32 @@ Rectangle { y: 160; height: 120; width: 420 color: "transparent" - border.width: 5; border.color: secondScope.wantsFocus?"blue":"black" + border.width: 5; border.color: secondScope.activeFocus?"blue":"black" Rectangle { id: item4; objectName: "item4" x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } Rectangle { id: item5; objectName: "item5" x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: wantsFocus?"blue":"black" + border.width: 5; border.color: activeFocus?"blue":"black" Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } } } Keys.onDigit4Pressed: item4.focus = true - Keys.onDigit5Pressed: item5.forceFocus() + Keys.onDigit5Pressed: item5.forceActiveFocus() } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml index aa43ba8..55be103 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml @@ -20,21 +20,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.debug("Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -43,13 +43,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -63,14 +63,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml index 216277e..5ed701d 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml @@ -10,27 +10,27 @@ Rectangle { FocusScope { y: 100 focus: true; objectName: "item1" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item2" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item3" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item4" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } FocusScope { y: 100 focus: true; objectName: "item5" - Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" } + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } } } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml index 2ac0d18..c6d112f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml @@ -13,7 +13,7 @@ Rectangle { ListElement { name: "4" } ListElement { name: "5" } ListElement { name: "6" } - ListElement { name: "6" } + ListElement { name: "7" } ListElement { name: "8" } ListElement { name: "9" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml index 8862b39..3c6d3bd 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml @@ -19,21 +19,21 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { id: item1; objectName: "item1" x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Top Left"); KeyNavigation.right: item2 focus: true Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } @@ -42,13 +42,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onDigit9Pressed: console.log("Error - Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -62,14 +62,14 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" Keys.onDigit9Pressed: console.log("Error - Bottom Left"); KeyNavigation.up: myScope Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml index cdb5164..4417d5f 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml +++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml @@ -20,13 +20,13 @@ Rectangle { color: "transparent" border.width: 5 - border.color: myScope.wantsFocus?"blue":"black" + border.color: myScope.activeFocus?"blue":"black" Rectangle { x: 10; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: item1.wantsFocus?"blue":"black" + border.color: item1.activeFocus?"blue":"black" } TextEdit { @@ -47,13 +47,13 @@ Rectangle { x: 310; y: 10 width: 100; height: 100; color: "green" border.width: 5 - border.color: wantsFocus?"blue":"black" + border.color: activeFocus?"blue":"black" KeyNavigation.left: item1 Keys.onReturnPressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent - color: parent.focus?"red":"transparent" + color: parent.activeFocus?"red":"transparent" } } } @@ -66,7 +66,7 @@ Rectangle { x: 10; y: 300 width: 100; height: 100; color: "green" border.width: 5 - border.color: item3.wantsFocus?"blue":"black" + border.color: item3.activeFocus?"blue":"black" } TextEdit { diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 2559087..b0c9c03 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -118,22 +118,22 @@ void tst_qdeclarativefocusscope::basic() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -166,16 +166,11 @@ void tst_qdeclarativefocusscope::nested() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item1->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->wantsFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item3->hasFocus() == false); - QVERIFY(item4->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->wantsFocus() == true); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == true); + QVERIFY(item5->hasActiveFocus() == true); delete view; } @@ -204,22 +199,22 @@ void tst_qdeclarativefocusscope::noFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); delete view; } @@ -249,32 +244,32 @@ void tst_qdeclarativefocusscope::textEdit() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == true); - QVERIFY(item3->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); delete view; } @@ -308,28 +303,28 @@ void tst_qdeclarativefocusscope::forceFocus() QVERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_4); - QVERIFY(item0->wantsFocus() == true); - QVERIFY(item1->hasFocus() == true); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == false); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == false); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); QTest::keyClick(view, Qt::Key_5); - QVERIFY(item0->wantsFocus() == false); - QVERIFY(item1->hasFocus() == false); - QVERIFY(item2->hasFocus() == false); - QVERIFY(item3->wantsFocus() == true); - QVERIFY(item4->hasFocus() == false); - QVERIFY(item5->hasFocus() == true); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == true); delete view; } |