Accessibility: indexOfChild is 0-based.
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>
Mon, 9 Jan 2012 15:06:23 +0000 (16:06 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jan 2012 14:12:43 +0000 (15:12 +0100)
Also test for it to work.

Change-Id: I3be913984e2dddce241b538c7801f3376acdd1fa
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp
src/plugins/accessible/quick/qaccessiblequickitem.cpp
src/plugins/accessible/quick/qaccessiblequickview.cpp
tests/auto/declarative/qdeclarativeaccessibility/tst_qdeclarativeaccessibility.cpp

index 25034a2..765e00a 100644 (file)
@@ -80,7 +80,7 @@ int QAccessibleDeclarativeView::indexOfChild(const QAccessibleInterface *iface)
     if (iface) {
         QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem();
         if (declarativeRoot == iface->object())
-            return 1;
+            return 0;
     }
     return -1;
 }
index 10442b2..fd087c4 100644 (file)
@@ -135,10 +135,7 @@ int QAccessibleQuickItem::navigate(QAccessible::RelationFlag rel, int entry, QAc
 int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const
 {
     QList<QQuickItem*> kids = childItems();
-    int idx = kids.indexOf(static_cast<QQuickItem*>(iface->object()));
-    if (idx != -1)
-        ++idx;
-    return idx;
+    return kids.indexOf(static_cast<QQuickItem*>(iface->object()));
 }
 
 QList<QQuickItem *> QAccessibleQuickItem::childItems() const
index d15e01d..da8c424 100644 (file)
@@ -158,7 +158,7 @@ int QAccessibleQuickView::indexOfChild(const QAccessibleInterface *iface) const
     if (iface) {
         QQuickItem *declarativeRoot = view()->rootObject();
         if (declarativeRoot == iface->object())
-            return 1;
+            return 0;
     }
     return -1;
 
index a20094d..0688edf 100644 (file)
@@ -382,6 +382,7 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
     QCOMPARE(item->childCount(), 2);
     QCOMPARE(item->rect().size(), QSize(400, 400));
     QCOMPARE(item->role(), QAccessible::Pane);
+    QCOMPARE(iface->indexOfChild(item.data()), 0);
 
     QAI text = QAI(item->child(0));
     QVERIFY(text.data());
@@ -392,6 +393,7 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
     QCOMPARE(text->rect().x(), item->rect().x() + 100);
     QCOMPARE(text->rect().y(), item->rect().y() + 20);
     QCOMPARE(text->role(), QAccessible::StaticText);
+    QCOMPARE(item->indexOfChild(text.data()), 0);
 
     QAI text2 = QAI(item->child(1));
     QVERIFY(text2.data());
@@ -402,6 +404,10 @@ void tst_QDeclarativeAccessibility::basicPropertiesTest()
     QCOMPARE(text2->rect().x(), item->rect().x() + 100);
     QCOMPARE(text2->rect().y(), item->rect().y() + 40);
     QCOMPARE(text2->role(), QAccessible::StaticText);
+    QCOMPARE(item->indexOfChild(text2.data()), 1);
+
+    QCOMPARE(iface->indexOfChild(text2.data()), -1);
+    QCOMPARE(text2->indexOfChild(item.data()), -1);
 
     delete canvas;
 }