summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan-Arve Saether <jan-arve.saether@nokia.com>2012-01-05 09:51:20 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-06 19:24:23 +0100
commit7dca461620ee6d8cce3a74acf2e1530d4497bff9 (patch)
tree3e24f90a0dbe0826b33d025f16ac0cf83e3e47f3 /src
parentca5072fb185a75e2c9ef25fd19a56cbe41128b0a (diff)
Remove all references to QAccessible:: {Child|Ancestor|Sibling}
These are deprecated in favor of QAccessibleInterface::child() and QAccessibleInterface::parent() QAccessible::Sibling can be done with a combination of those two. This is handled by the bridges, if required. Change-Id: I2e2a6eb2a982e7c9001a393d69f0c5f1ae9c0970 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/accessible/qaccessible.h5
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp3
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.cpp32
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.h1
-rw-r--r--src/plugins/accessible/widgets/itemviews.cpp128
-rw-r--r--src/plugins/accessible/widgets/itemviews.h11
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.cpp47
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.h3
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp66
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.h4
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowsaccessibility.cpp116
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp134
13 files changed, 170 insertions, 385 deletions
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 37071bcdaf..949c67c4ca 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -274,11 +274,6 @@ public:
enum RelationFlag {
Unrelated = 0x00000000,
Self = 0x00000001,
- Ancestor = 0x00000002,
- Child = 0x00000004,
- Descendent = 0x00000008,
- Sibling = 0x00000010,
- HierarchyMask = 0x000000ff,
Up = 0x00000100,
Down = 0x00000200,
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index af86ad47c2..5ba3cd1281 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -272,9 +272,6 @@ int QAccessibleApplication::navigate(QAccessible::RelationFlag relation, int,
return 0;
}
break;
- case QAccessible::Ancestor:
- *target = parent();
- return 0;
default:
break;
}
diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp
index b1ff87132f..f09c942170 100644
--- a/src/plugins/accessible/widgets/complexwidgets.cpp
+++ b/src/plugins/accessible/widgets/complexwidgets.cpp
@@ -124,17 +124,11 @@ public:
QAccessibleInterface *child(int) const { return 0; }
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return 0;
- }
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
+ Q_UNUSED(iface);
return -1;
}
- QAccessible::Relation relationTo(const QAccessibleInterface *) const
- {
- return QAccessible::Unrelated;
- }
-
// action interface
QStringList actionNames() const
{
@@ -172,18 +166,6 @@ QTabBar *QAccessibleTabBar::tabBar() const
return qobject_cast<QTabBar*>(object());
}
-int QAccessibleTabBar::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
-{
- if (rel == QAccessible::Child) {
- *target = child(entry - 1);
- if (*target) {
- return 0;
- }
- return -1;
- }
- return QAccessibleWidget::navigate(rel, entry, target);
-}
-
QAccessibleInterface* QAccessibleTabBar::child(int index) const
{
// first the tabs, then 2 buttons
@@ -443,8 +425,7 @@ int QAccessibleAbstractScrollArea::navigate(QAccessible::RelationFlag relation,
QWidget *targetWidget = 0;
QWidget *entryWidget = 0;
- if (relation == QAccessible::Child ||
- relation == QAccessible::Left || relation == QAccessible::Up || relation == QAccessible::Right || relation == QAccessible::Down) {
+ if (relation == QAccessible::Left || relation == QAccessible::Up || relation == QAccessible::Right || relation == QAccessible::Down) {
QWidgetList children = accessibleChildren();
if (entry < 0 || entry > children.count())
return -1;
@@ -460,11 +441,6 @@ int QAccessibleAbstractScrollArea::navigate(QAccessible::RelationFlag relation,
// It might be possible to make it more general, but I'll leave that as an exercise
// to the reader. :-)
switch (relation) {
- case QAccessible::Child:
- if (entry > 0) {
- *target = child(entry - 1);
- return *target ? 0 : -1;
- }
case QAccessible::Left:
if (entry < 1)
break;
diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h
index 66dbdcfab8..24c033bda3 100644
--- a/src/plugins/accessible/widgets/complexwidgets.h
+++ b/src/plugins/accessible/widgets/complexwidgets.h
@@ -112,7 +112,6 @@ public:
QAccessibleInterface* child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
- int navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const;
protected:
QTabBar *tabBar() const;
diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp
index f6d719ae3a..a12036b52d 100644
--- a/src/plugins/accessible/widgets/itemviews.cpp
+++ b/src/plugins/accessible/widgets/itemviews.cpp
@@ -444,23 +444,9 @@ QAccessibleInterface *QAccessibleTable::child(int index) const
int QAccessibleTable::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
*iface = 0;
- switch (relation) {
- case QAccessible::Ancestor: {
- *iface = parent();
- return *iface ? 0 : -1;
- }
- case QAccessible::Child: {
- Q_ASSERT(index > 0);
- *iface = child(index - 1);
- if (*iface) {
- return 0;
- }
- break;
- }
- default:
- break;
- }
return -1;
}
@@ -518,6 +504,29 @@ int QAccessibleTree::childCount() const
return (treeView->d_func()->viewItems.count() + hHeader)* view->model()->columnCount();
}
+
+QAccessibleInterface *QAccessibleTree::child(int index) const
+{
+ Q_ASSERT(index >= 0);
+ int hHeader = horizontalHeader() ? 1 : 0;
+
+ if (hHeader) {
+ if (index < view->model()->columnCount()) {
+ return new QAccessibleTableHeaderCell(view, index, Qt::Horizontal);
+ } else {
+ index -= view->model()->columnCount();
+ }
+ }
+
+ int row = index / view->model()->columnCount();
+ int column = index % view->model()->columnCount();
+ QModelIndex modelIndex = indexFromLogical(row, column);
+ if (modelIndex.isValid()) {
+ return cell(modelIndex);
+ }
+ return 0;
+}
+
int QAccessibleTree::rowCount() const
{
const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
@@ -550,38 +559,6 @@ int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const
return -1;
}
-int QAccessibleTree::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
-{
- switch (relation) {
- case QAccessible::Child: {
- Q_ASSERT(index > 0);
- --index;
- int hHeader = horizontalHeader() ? 1 : 0;
-
- if (hHeader) {
- if (index < view->model()->columnCount()) {
- *iface = new QAccessibleTableHeaderCell(view, index, Qt::Horizontal);
- return 0;
- } else {
- index -= view->model()->columnCount();
- }
- }
-
- int row = index / view->model()->columnCount();
- int column = index % view->model()->columnCount();
- QModelIndex modelIndex = indexFromLogical(row, column);
- if (modelIndex.isValid()) {
- *iface = cell(modelIndex);
- return 0;
- }
- return -1;
- }
- default:
- break;
- }
- return QAccessibleTable::navigate(relation, index, iface);
-}
-
QAccessible::Relation QAccessibleTree::relationTo(const QAccessibleInterface *) const
{
return QAccessible::Unrelated;
@@ -815,29 +792,10 @@ QAccessibleInterface *QAccessibleTableCell::child(int) const
int QAccessibleTableCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return 0;
- }
-
- *iface = 0;
- if (!view)
- return -1;
-
- switch (relation) {
-
- case QAccessible::Child: {
- return -1;
- }
- case QAccessible::Sibling:
- if (index > 0) {
- QAccessibleInterface *parent = QAccessible::queryAccessibleInterface(view);
- *iface = parent->child(index - 1);
- delete parent;
- return *iface ? 0 : -1;
- }
- return -1;
+ Q_UNUSED(index);
+ Q_UNUSED(relation);
+// switch (relation) {
// From table1 implementation:
// case Up:
// case Down:
@@ -862,28 +820,11 @@ int QAccessibleTableCell::navigate(QAccessible::RelationFlag relation, int index
// if (idx.parent() != row.parent() || idx.row() != row.row())
// *iface = cell(idx);
// return index ? kids.indexOf(idx) + 1 : 0; }
- default:
- break;
- }
-
+// }
+ *iface = 0;
return -1;
}
-QAccessible::Relation QAccessibleTableCell::relationTo(const QAccessibleInterface *other) const
-{
- // we only check for parent-child relationships in trees
- if (m_role == QAccessible::TreeItem && other->role() == QAccessible::TreeItem) {
- QModelIndex otherIndex = static_cast<const QAccessibleTableCell*>(other)->m_index;
- // is the other our parent?
- if (otherIndex.parent() == m_index)
- return QAccessible::Ancestor;
- // are we the other's child?
- if (m_index.parent() == otherIndex)
- return QAccessible::Child;
- }
- return QAccessible::Unrelated;
-}
-
QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_)
: view(view_), index(index_), orientation(orientation_)
{
@@ -976,11 +917,10 @@ QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const
int QAccessibleTableHeaderCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor && index == 1) {
- *iface = parent();
- return *iface ? 0 : -1;
- }
- *iface = 0;
+ Q_UNUSED(relation);
+ Q_UNUSED(index);
+ Q_UNUSED(iface);
+
return -1;
}
diff --git a/src/plugins/accessible/widgets/itemviews.h b/src/plugins/accessible/widgets/itemviews.h
index 6fe6138d6b..3a2f5a8cb1 100644
--- a/src/plugins/accessible/widgets/itemviews.h
+++ b/src/plugins/accessible/widgets/itemviews.h
@@ -155,11 +155,12 @@ public:
QAccessibleInterface *childAt(int x, int y) const;
int childCount() const;
+ QAccessibleInterface *child(int index) const;
+
int indexOfChild(const QAccessibleInterface *) const;
int rowCount() const;
- int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
// table interface
@@ -194,7 +195,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int) const;
int navigate(QAccessible::RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
// cell interface
virtual int columnExtent() const;
@@ -283,12 +283,11 @@ public:
}
int navigate(QAccessible::RelationFlag relation, int, QAccessibleInterface **iface) const
{
- if (relation == QAccessible::Ancestor) {
- *iface = parent();
- return *iface ? 0 : -1;
- }
+ Q_UNUSED(relation);
+ Q_UNUSED(iface);
return -1;
}
+
QAccessible::Relation relationTo(const QAccessibleInterface *) const
{
return QAccessible::Unrelated;
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
index 8204621c13..d3a7fe0fe6 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
@@ -111,21 +111,6 @@ QAccessibleInterface *QAccessibleMenu::parent() const
return QAccessibleWidget::parent();
}
-int QAccessibleMenu::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- Q_ASSERT(entry >= 0);
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
- case QAccessible::Ancestor:
- *target = parent();
- return *target ? 0 : -1;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
-}
-
int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const
{
int index = -1;
@@ -162,15 +147,6 @@ QAccessibleInterface *QAccessibleMenuBar::child(int index) const
return 0;
}
-int QAccessibleMenuBar::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- if (relation == QAccessible::Child) {
- *target = child(entry - 1);
- return *target ? 0 : -1;
- }
- return QAccessibleWidget::navigate(relation, entry, target);
-}
-
int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
{
int index = -1;
@@ -244,12 +220,6 @@ int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry,
}
switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- break;
- case QAccessible::Ancestor:
- *target = parent();
- break;
case QAccessible::Up:
case QAccessible::Down:{
QAccessibleInterface *parentIface = parent();
@@ -263,13 +233,6 @@ int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry,
delete parentIface;
break;
}
- case QAccessible::Sibling: {
- QAccessibleInterface *parentIface = parent();
- if (parentIface)
- *target = parentIface->child(entry - 1);
- delete parentIface;
- break;
- }
default:
break;
@@ -308,16 +271,6 @@ QRect QAccessibleMenuItem::rect() const
return rect;
}
-QAccessible::Relation QAccessibleMenuItem::relationTo(const QAccessibleInterface *other) const
-{
- if (other->object() == owner()) {
- return QAccessible::Child;
- }
- Q_UNUSED(other)
- // ###
- return QAccessible::Unrelated;
-}
-
QAccessible::Role QAccessibleMenuItem::role() const
{
return m_action->isSeparator() ? QAccessible::Separator : QAccessible::MenuItem;
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h
index d44c02b753..873aacd5d4 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.h
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.h
@@ -65,7 +65,6 @@ public:
QAccessible::Role role() const;
QAccessibleInterface *child(int index) const;
QAccessibleInterface *parent() const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
int indexOfChild( const QAccessibleInterface *child ) const;
protected:
@@ -81,7 +80,6 @@ public:
QAccessibleInterface *child(int index) const;
int childCount() const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
int indexOfChild(const QAccessibleInterface *child) const;
protected:
@@ -108,7 +106,6 @@ public:
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface ** target) const;
QObject * object() const;
QRect rect() const;
- QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
QAccessible::Role role() const;
void setText(QAccessible::Text t, const QString & text);
QAccessible::State state() const;
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index 17031fe272..182a85dfc7 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -698,6 +698,7 @@ QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget)
QVariant QAccessibleStackedWidget::invokeMethod(QAccessible::Method, const QVariantList &params)
{
+ Q_UNUSED(params);
return QVariant();
}
@@ -739,17 +740,6 @@ QAccessibleInterface *QAccessibleStackedWidget::child(int index) const
return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index));
}
-int QAccessibleStackedWidget::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
-{
- switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
- default:
- return QAccessibleWidget::navigate(relation, entry, target);
- }
-}
-
QStackedWidget *QAccessibleStackedWidget::stackedWidget() const
{
return static_cast<QStackedWidget *>(object());
@@ -783,6 +773,16 @@ int QAccessibleMdiArea::childCount() const
return mdiArea()->subWindowList().count();
}
+QAccessibleInterface *QAccessibleMdiArea::child(int index) const
+{
+ QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
+ QWidget *targetObject = subWindows.value(index);
+ if (!targetObject)
+ return 0;
+ return QAccessible::queryAccessibleInterface(targetObject);
+}
+
+
int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const
{
if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
@@ -799,13 +799,7 @@ int QAccessibleMdiArea::navigate(QAccessible::RelationFlag relation, int entry,
{
*target = 0;
QWidget *targetObject = 0;
- QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
switch (relation) {
- case QAccessible::Child:
- if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
- return -1;
- targetObject = subWindows.at(entry - 1);
- break;
case QAccessible::Up:
case QAccessible::Down:
case QAccessible::Left:
@@ -873,6 +867,15 @@ int QAccessibleMdiSubWindow::childCount() const
return 0;
}
+QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const
+{
+ QMdiSubWindow *source = mdiSubWindow();
+ if (index != 0 || !source->widget())
+ return 0;
+
+ return QAccessible::queryAccessibleInterface(source->widget());
+}
+
int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const
{
if (child && child->object() && child->object() == mdiSubWindow()->widget())
@@ -890,11 +893,6 @@ int QAccessibleMdiSubWindow::navigate(QAccessible::RelationFlag relation, int en
QWidget *targetObject = 0;
QMdiSubWindow *source = mdiSubWindow();
switch (relation) {
- case QAccessible::Child:
- if (entry != 1 || !source->widget())
- return -1;
- targetObject = source->widget();
- break;
case QAccessible::Up:
case QAccessible::Down:
case QAccessible::Left:
@@ -952,6 +950,15 @@ int QAccessibleWorkspace::childCount() const
return workspace()->windowList().count();
}
+QAccessibleInterface *QAccessibleWorkspace::child(int index) const
+{
+ QWidgetList subWindows = workspace()->windowList();
+ if (index < 0 || subWindows.isEmpty() || index >= subWindows.count())
+ return 0;
+ QObject *targetObject = subWindows.at(index);
+ return QAccessible::queryAccessibleInterface(targetObject);
+}
+
int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const
{
if (!child || !child->object() || workspace()->windowList().isEmpty())
@@ -968,13 +975,7 @@ int QAccessibleWorkspace::navigate(QAccessible::RelationFlag relation, int entry
{
*target = 0;
QWidget *targetObject = 0;
- QWidgetList subWindows = workspace()->windowList();
switch (relation) {
- case QAccessible::Child:
- if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
- return -1;
- targetObject = subWindows.at(entry - 1);
- break;
case QAccessible::Up:
case QAccessible::Down:
case QAccessible::Left:
@@ -1066,9 +1067,6 @@ int QAccessibleCalendarWidget::navigate(QAccessible::RelationFlag relation, int
return QAccessibleWidget::navigate(relation, entry, target);
QWidget *targetWidget = 0;
switch (relation) {
- case QAccessible::Child:
- *target = child(entry - 1);
- return *target ? 0 : -1;
case QAccessible::Up:
if (entry == 2)
targetWidget = navigationBar();
@@ -1201,9 +1199,6 @@ QAccessibleInterface *QAccessibleTitleBar::child(int index) const
int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **iface) const
{
switch (relation) {
- case QAccessible::Child:
- *iface = child(entry - 1);
- return *iface ? 0 : -1;
case QAccessible::FocusChild:
// ###
if (entry >= 1) {
@@ -1222,9 +1217,6 @@ int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry,
return role > QDockWidgetLayout::FloatButton ? -1 : index;
}
break;
- case QAccessible::Ancestor:
- *iface = parent();
- return iface ? 0 : -1;
default:
break;
}
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h
index 44fdcc7a19..e60ed06b59 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.h
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h
@@ -125,7 +125,6 @@ public:
int childCount() const;
int indexOfChild(const QAccessibleInterface *child) const;
QAccessibleInterface *child(int index) const;
- int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
protected:
QStackedWidget *stackedWidget() const;
@@ -153,6 +152,7 @@ public:
explicit QAccessibleMdiArea(QWidget *widget);
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
@@ -169,6 +169,7 @@ public:
void setText(QAccessible::Text textType, const QString &text);
QAccessible::State state() const;
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
QRect rect() const;
@@ -185,6 +186,7 @@ public:
explicit QAccessibleWorkspace(QWidget *widget);
int childCount() const;
+ QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const;
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 385ca09e08..b05b917c21 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -464,10 +464,11 @@ int QAccessibleDisplay::navigate(QAccessible::RelationFlag rel, int entry, QAcce
} else {
QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
if (groupbox && !groupbox->title().isEmpty())
- rel = QAccessible::Child;
+ *target = child(entry - 1);
#endif
}
- *target = QAccessible::queryAccessibleInterface(targetObject);
+ if (targetObject)
+ *target = QAccessible::queryAccessibleInterface(targetObject);
if (*target)
return 0;
}
diff --git a/src/plugins/platforms/windows/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/qwindowsaccessibility.cpp
index 73006a5ff9..f181f3061b 100644
--- a/src/plugins/platforms/windows/qwindowsaccessibility.cpp
+++ b/src/plugins/platforms/windows/qwindowsaccessibility.cpp
@@ -762,13 +762,12 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accNavigate(long navDir, VARIANT v
return E_FAIL;
QAccessibleInterface *acc = 0;
- int control = -1;
switch (navDir) {
case NAVDIR_FIRSTCHILD:
- control = accessible->navigate(QAccessible::Child, 1, &acc);
+ acc = accessible->child(0);
break;
case NAVDIR_LASTCHILD:
- control = accessible->navigate(QAccessible::Child, accessible->childCount(), &acc);
+ acc = accessible->child(accessible->childCount() - 1);
break;
case NAVDIR_NEXT:
case NAVDIR_PREVIOUS:
@@ -778,41 +777,107 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accNavigate(long navDir, VARIANT v
int index = parent->indexOfChild(accessible);
index += (navDir == NAVDIR_NEXT) ? 1 : -1;
if (index > 0 && index <= parent->childCount())
- control = parent->navigate(QAccessible::Child, index, &acc);
+ acc = parent->child(index - 1);
delete parent;
}
} else {
int index = varStart.lVal;
index += (navDir == NAVDIR_NEXT) ? 1 : -1;
if (index > 0 && index <= accessible->childCount())
- control = accessible->navigate(QAccessible::Child, index, &acc);
+ acc = accessible->child(index - 1);
}
break;
+
+ // Geometrical
case NAVDIR_UP:
- control = accessible->navigate(QAccessible::Up, varStart.lVal, &acc);
- break;
case NAVDIR_DOWN:
- control = accessible->navigate(QAccessible::Down, varStart.lVal, &acc);
- break;
case NAVDIR_LEFT:
- control = accessible->navigate(QAccessible::Left, varStart.lVal, &acc);
- break;
case NAVDIR_RIGHT:
- control = accessible->navigate(QAccessible::Right, varStart.lVal, &acc);
+ if (QAccessibleInterface *pIface = accessible->parent()) {
+
+ QRect startg = accessible->rect();
+ QPoint startc = startg.center();
+ QAccessibleInterface *candidate = 0;
+ unsigned mindist = UINT_MAX; // will work on screen sizes at least up to 46340x46340
+ const int sibCount = pIface->childCount();
+ for (int i = 0; i < sibCount; ++i) {
+ QAccessibleInterface *sibling = 0;
+ sibling = pIface->child(i);
+ Q_ASSERT(sibling);
+ if ((accessible->relationTo(sibling) & QAccessible::Self) || (sibling->state() & QAccessible::Invisible)) {
+ //ignore ourself and invisible siblings
+ delete sibling;
+ continue;
+ }
+
+ QRect sibg = sibling->rect();
+ QPoint sibc = sibg.center();
+ QPoint sibp;
+ QPoint startp;
+ QPoint distp;
+ switch (navDir) {
+ case NAVDIR_LEFT:
+ startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
+ sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
+ if (QPoint(sibc - startc).x() >= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case NAVDIR_RIGHT:
+ startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
+ sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
+ if (QPoint(sibc - startc).x() <= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case NAVDIR_UP:
+ startp = QPoint(startg.left() + startg.width() / 2, startg.top());
+ sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
+ if (QPoint(sibc - startc).y() >= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case NAVDIR_DOWN:
+ startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
+ sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
+ if (QPoint(sibc - startc).y() <= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ default:
+ break;
+ }
+
+ // Since we're *comparing* (and not measuring) distances, we can compare the
+ // squared distance, (thus, no need to take the sqrt()).
+ unsigned dist = distp.x() * distp.x() + distp.y() * distp.y();
+ if (dist < mindist) {
+ delete candidate;
+ candidate = sibling;
+ mindist = dist;
+ } else {
+ delete sibling;
+ }
+ }
+ delete pIface;
+ acc = candidate;
+ }
break;
default:
break;
}
- if (control == -1) {
+ if (!acc) {
(*pvarEnd).vt = VT_EMPTY;
return S_FALSE;
}
- if (!acc) {
- (*pvarEnd).vt = VT_I4;
- (*pvarEnd).lVal = control;
- return S_OK;
- }
-
QWindowsAccessible* wacc = new QWindowsAccessible(acc);
IDispatch *iface = 0;
@@ -850,18 +915,21 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accChild(VARIANT varChildID, I
acc = QAccessible::queryAccessibleInterface(ref.first);
if (acc && ref.second) {
if (ref.second) {
- QAccessibleInterface *res;
- int index = acc->navigate(QAccessible::Child, ref.second, &res);
+ QAccessibleInterface *res = acc->child(ref.second - 1);
delete acc;
- if (index == -1)
+ if (!res)
return E_INVALIDARG;
acc = res;
}
}
}
} else {
- QAccessible::RelationFlag rel = childIndex ? QAccessible::Child : QAccessible::Self;
- accessible->navigate(rel, childIndex, &acc);
+ if (childIndex) {
+ acc = accessible->child(childIndex - 1);
+ } else {
+ // FIXME
+ Q_ASSERT(0);
+ }
}
if (acc) {
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index 5953333d0c..43a72a336f 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -363,11 +363,7 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface *
}
QObject *parent = object()->parent();
- if (o == parent)
- return relation | QAccessible::Child;
-
if (o->parent() == parent) {
- relation |= QAccessible::Sibling;
QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o);
Q_ASSERT(sibIface);
QRect wg = rect();
@@ -385,28 +381,12 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface *
relation |= QAccessible::Covered;
}
delete pIface;
- } else {
- QPoint wc = wg.center();
- QPoint sc = sg.center();
- if (wc.x() < sc.x())
- relation |= QAccessible::Left;
- else if(wc.x() > sc.x())
- relation |= QAccessible::Right;
- if (wc.y() < sc.y())
- relation |= QAccessible::Up;
- else if (wc.y() > sc.y())
- relation |= QAccessible::Down;
}
delete sibIface;
return relation;
}
- if (isAncestor(o, object()))
- return relation | QAccessible::Descendent;
- if (isAncestor(object(), o))
- return relation | QAccessible::Ancestor;
-
return relation;
}
@@ -437,120 +417,6 @@ int QAccessibleWidget::navigate(QAccessible::RelationFlag relation, int entry,
QObject *targetObject = 0;
switch (relation) {
- // Hierarchical
- case QAccessible::Self:
- targetObject = object();
- break;
- case QAccessible::Child:
- qWarning() << "QAccessibleWidget::navigate is deprecated for QAccessible::Child in:" << object()->metaObject()->className();
- *target = child(entry - 1);
- return *target ? 0 : -1;
- case QAccessible::Ancestor:
- qWarning() << "QAccessibleWidget::navigate is deprecated for QAccessible::Ancestor in:" << object()->metaObject()->className();
- *target = parent();
- return *target ? 0 : -1;
- case QAccessible::Sibling:
- {
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject());
- if (!iface)
- return -1;
-
- *target = iface->child(entry - 1);
- delete iface;
- if (*target)
- return 0;
- }
- break;
-
- // Geometrical
- case QAccessible::Left:
- // fall through
- case QAccessible::Right:
- // fall through
- case QAccessible::Up:
- // fall through
- case QAccessible::Down:
- {
- QAccessibleInterface *pIface = parent();
- if (!pIface)
- return -1;
-
- QRect startg = rect();
- QPoint startc = startg.center();
- QAccessibleInterface *candidate = 0;
- int mindist = 100000;
- int sibCount = pIface->childCount();
- for (int i = 0; i < sibCount; ++i) {
- QAccessibleInterface *sibling = 0;
- sibling = pIface->child(i);
- Q_ASSERT(sibling);
- if ((relationTo(sibling) & QAccessible::Self) || (sibling->state() & QAccessible::Invisible)) {
- //ignore ourself and invisible siblings
- delete sibling;
- continue;
- }
-
- QRect sibg = sibling->rect();
- QPoint sibc = sibg.center();
- QPoint sibp;
- QPoint startp;
- QPoint distp;
- switch (relation) {
- case QAccessible::Left:
- startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
- sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
- if (QPoint(sibc - startc).x() >= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Right:
- startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
- sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
- if (QPoint(sibc - startc).x() <= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Up:
- startp = QPoint(startg.left() + startg.width() / 2, startg.top());
- sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
- if (QPoint(sibc - startc).y() >= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Down:
- startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
- sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
- if (QPoint(sibc - startc).y() <= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- default:
- break;
- }
-
- int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y());
- if (dist < mindist) {
- delete candidate;
- candidate = sibling;
- mindist = dist;
- } else {
- delete sibling;
- }
- }
- delete pIface;
- *target = candidate;
- if (*target)
- return 0;
- }
- break;
case QAccessible::Covers:
if (entry > 0) {
QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());