From 03520d7fde2f6dced73c69744ab0bc1d3b166862 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 20 Sep 2013 10:54:59 +0200 Subject: [PATCH] Add missing implementation in QAccessibleTabBar::indexOfChild This avoids the assertion in iaccessible2.cpp(510) Change-Id: I1a4c007ffcbcda70f0e37ef3cf55a303683b58c1 Reviewed-by: Frederik Gladhorn --- src/plugins/accessible/widgets/complexwidgets.cpp | 12 ++++++++++-- .../auto/other/qaccessibility/tst_qaccessibility.cpp | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp index 819ef6923f..9988e73da1 100644 --- a/src/plugins/accessible/widgets/complexwidgets.cpp +++ b/src/plugins/accessible/widgets/complexwidgets.cpp @@ -138,9 +138,12 @@ public: return QStringList(); } + int index() const { return m_index; } + private: QPointer m_parent; int m_index; + }; /*! @@ -190,12 +193,17 @@ QAccessibleInterface* QAccessibleTabBar::child(int index) const int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const { - // FIXME this looks broken - if (child->object() && child->object() == tabBar()->d_func()->leftB) return tabBar()->count(); if (child->object() && child->object() == tabBar()->d_func()->rightB) return tabBar()->count() + 1; + if (child->role() == QAccessible::PageTab) { + QAccessibleInterface *parent = child->parent(); + if (parent == this) { + const QAccessibleTabButton *tabButton = static_cast(child); + return tabButton->index(); + } + } return -1; } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index bd95f89e88..b03aafcf0d 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1243,6 +1243,7 @@ void tst_QAccessibility::tabWidgetTest() QAccessibleInterface* tabBarInterface = 0; // there is no special logic to sort the children, so the contents will be 1, the tab bar 2 tabBarInterface = interface->child(1); + QCOMPARE(verifyHierarchy(tabBarInterface), 0); QVERIFY(tabBarInterface); QCOMPARE(tabBarInterface->childCount(), 4); QCOMPARE(tabBarInterface->role(), QAccessible::PageTabList);