From 1133c0dd2230499b24d7f92634531bb633ee00f6 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Fri, 6 Jan 2012 15:51:53 +0100 Subject: Remove all references to QAccessible::(Up|Down|Left|Right) It is now the resonsibility of the bridge to support this (by querying for QAccessibleInterface::rect()) The windows bridge (currently the only bridge in need of this) has already been updated to reflect this in commit 7dca461620ee6d8cce3a74acf2e1530d4497bff9 Change-Id: Ief1339ab6edc118e2d47e3875e09fa885db65c2f Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible.h | 4 - src/plugins/accessible/widgets/complexwidgets.cpp | 114 ----------- src/plugins/accessible/widgets/complexwidgets.h | 1 - src/plugins/accessible/widgets/qaccessiblemenu.cpp | 27 +-- .../accessible/widgets/qaccessiblewidgets.cpp | 211 --------------------- .../accessible/widgets/qaccessiblewidgets.h | 4 - .../platforms/windows/qwindowsaccessibility.cpp | 10 +- 7 files changed, 11 insertions(+), 360 deletions(-) (limited to 'src') diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 2126cfd877..e41898f045 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -276,10 +276,6 @@ public: Unrelated = 0x00000000, Self = 0x00000001, - Up = 0x00000100, - Down = 0x00000200, - Left = 0x00000400, - Right = 0x00000800, Covers = 0x00001000, Covered = 0x00002000, GeometryMask = 0x0000ff00, diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp index 94eb535791..a8f477e261 100644 --- a/src/plugins/accessible/widgets/complexwidgets.cpp +++ b/src/plugins/accessible/widgets/complexwidgets.cpp @@ -414,120 +414,6 @@ bool QAccessibleAbstractScrollArea::isValid() const return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->viewport()); } -int QAccessibleAbstractScrollArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - if (!target) - return -1; - - *target = 0; - - QWidget *targetWidget = 0; - QWidget *entryWidget = 0; - - if (relation == QAccessible::Left || relation == QAccessible::Up || relation == QAccessible::Right || relation == QAccessible::Down) { - QWidgetList children = accessibleChildren(); - if (entry < 0 || entry > children.count()) - return -1; - - if (entry == Self) - entryWidget = abstractScrollArea(); - else - entryWidget = children.at(entry - 1); - AbstractScrollAreaElement entryElement = elementType(entryWidget); - - // Not one of the most beautiful switches I've ever seen, but I believe it has - // to be like this since each case need special handling. - // It might be possible to make it more general, but I'll leave that as an exercise - // to the reader. :-) - switch (relation) { - case QAccessible::Left: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - case HorizontalContainer: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->cornerWidget(); - break; - case VerticalContainer: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - default: - break; - } - break; - case QAccessible::Right: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - if (isLeftToRight()) - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - case HorizontalContainer: - targetWidget = abstractScrollArea()->cornerWidget(); - break; - case VerticalContainer: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - if (!isLeftToRight()) - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - default: - break; - } - break; - case QAccessible::Up: - if (entry < 1) - break; - switch (entryElement) { - case HorizontalContainer: - targetWidget = abstractScrollArea()->viewport(); - break; - case CornerWidget: - targetWidget = abstractScrollArea()->verticalScrollBar(); - break; - default: - break; - } - break; - case QAccessible::Down: - if (entry < 1) - break; - switch (entryElement) { - case Viewport: - targetWidget = abstractScrollArea()->horizontalScrollBar(); - break; - case VerticalContainer: - targetWidget = abstractScrollArea()->cornerWidget(); - break; - default: - break; - } - break; - default: - break; - } - } else { - return QAccessibleWidget::navigate(relation, entry, target); - } - - if (qobject_cast(targetWidget)) - targetWidget = targetWidget->parentWidget(); - *target = QAccessible::queryAccessibleInterface(targetWidget); - return *target ? 0: -1; -} - QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const { if (!abstractScrollArea()->isVisible()) diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h index 24c033bda3..3145c5255f 100644 --- a/src/plugins/accessible/widgets/complexwidgets.h +++ b/src/plugins/accessible/widgets/complexwidgets.h @@ -79,7 +79,6 @@ public: int childCount() const; int indexOfChild(const QAccessibleInterface *child) const; bool isValid() const; - int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const; QAccessibleInterface *childAt(int x, int y) const; //protected: diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp index e188db284f..77157d1b62 100644 --- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp +++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp @@ -206,31 +206,10 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const { + Q_UNUSED(relation); + Q_UNUSED(entry); *target = 0; - if (entry < 0) { - return -1; - } - - switch (relation) { - case QAccessible::Up: - case QAccessible::Down:{ - QAccessibleInterface *parentIface = parent(); - if (parentIface) { - int index = parentIface->indexOfChild(this); - if (index != -1) { - index += (relation == QAccessible::Down ? +1 : -1); - if (index >= 0) - *target = parentIface->child(index); - } - } - delete parentIface; - break; - } - default: - break; - - } - return *target ? 0 : -1; + return -1; } void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t) diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp index a067adaaa8..1d6638ee42 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp @@ -98,121 +98,6 @@ QList childWidgets(const QWidget *widget, bool includeTopLevel) return widgets; } -static inline int distance(QWidget *source, QWidget *target, - QAccessible::RelationFlag relation) -{ - if (!source || !target) - return -1; - - int returnValue = -1; - switch (relation) { - case QAccessible::Up: - if (target->y() <= source->y()) - returnValue = source->y() - target->y(); - break; - case QAccessible::Down: - if (target->y() >= source->y() + source->height()) - returnValue = target->y() - (source->y() + source->height()); - break; - case QAccessible::Right: - if (target->x() >= source->x() + source->width()) - returnValue = target->x() - (source->x() + source->width()); - break; - case QAccessible::Left: - if (target->x() <= source->x()) - returnValue = source->x() - target->x(); - break; - default: - break; - } - return returnValue; -} - -static inline QWidget *mdiAreaNavigate(QWidget *area, - QAccessible::RelationFlag relation, int entry) -{ -#if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE) - Q_UNUSED(area); -#endif -#ifndef QT_NO_MDIAREA - const QMdiArea *mdiArea = qobject_cast(area); -#endif -#ifndef QT_NO_WORKSPACE - const QWorkspace *workspace = qobject_cast(area); -#endif - if (true -#ifndef QT_NO_MDIAREA - && !mdiArea -#endif -#ifndef QT_NO_WORKSPACE - && !workspace -#endif - ) - return 0; - - QWidgetList windows; -#ifndef QT_NO_MDIAREA - if (mdiArea) { - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) - windows.append(window); - } else -#endif - { -#ifndef QT_NO_WORKSPACE - foreach (QWidget *window, workspace->windowList()) - windows.append(window->parentWidget()); -#endif - } - - if (windows.isEmpty() || entry < 1 || entry > windows.count()) - return 0; - - QWidget *source = windows.at(entry - 1); - QMap candidates; - foreach (QWidget *window, windows) { - if (source == window) - continue; - int candidateDistance = distance(source, window, relation); - if (candidateDistance >= 0) - candidates.insert(candidateDistance, window); - } - - int minimumDistance = INT_MAX; - QWidget *target = 0; - foreach (QWidget *candidate, candidates) { - switch (relation) { - case QAccessible::Up: - case QAccessible::Down: - if (qAbs(candidate->x() - source->x()) < minimumDistance) { - target = candidate; - minimumDistance = qAbs(candidate->x() - source->x()); - } - break; - case QAccessible::Left: - case QAccessible::Right: - if (qAbs(candidate->y() - source->y()) < minimumDistance) { - target = candidate; - minimumDistance = qAbs(candidate->y() - source->y()); - } - break; - default: - break; - } - if (minimumDistance == 0) - break; - } - -#ifndef QT_NO_WORKSPACE - if (workspace) { - foreach (QWidget *widget, workspace->windowList()) { - if (widget->parentWidget() == target) - target = widget; - } - } -#endif - return target; -} - #ifndef QT_NO_TEXTEDIT /*! @@ -790,24 +675,6 @@ int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const return -1; } -int QAccessibleMdiArea::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - QWidget *targetObject = 0; - switch (relation) { - case QAccessible::Up: - case QAccessible::Down: - case QAccessible::Left: - case QAccessible::Right: - targetObject = mdiAreaNavigate(mdiArea(), relation, entry); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - QMdiArea *QAccessibleMdiArea::mdiArea() const { return static_cast(object()); @@ -881,44 +748,6 @@ int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) con return -1; } -int QAccessibleMdiSubWindow::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - - if (!mdiSubWindow()->parent()) - return QAccessibleWidget::navigate(relation, entry, target); - - QWidget *targetObject = 0; - QMdiSubWindow *source = mdiSubWindow(); - switch (relation) { - case QAccessible::Up: - case QAccessible::Down: - case QAccessible::Left: - case QAccessible::Right: { - if (entry != 0) - break; - QWidget *parent = source->parentWidget(); - while (parent && !parent->inherits("QMdiArea")) - parent = parent->parentWidget(); - QMdiArea *mdiArea = qobject_cast(parent); - if (!mdiArea) - break; - int index = mdiArea->subWindowList().indexOf(source); - if (index == -1) - break; - if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) { - *target = QAccessible::queryAccessibleInterface(dest); - return *target ? 0 : -1; - } - break; - } - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - QRect QAccessibleMdiSubWindow::rect() const { if (mdiSubWindow()->isHidden()) @@ -967,24 +796,6 @@ int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const return -1; } -int QAccessibleWorkspace::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - QWidget *targetObject = 0; - switch (relation) { - case QAccessible::Up: - case QAccessible::Down: - case QAccessible::Left: - case QAccessible::Right: - targetObject = mdiAreaNavigate(workspace(), relation, entry); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetObject); - return *target ? 0: -1; -} - QWorkspace *QAccessibleWorkspace::workspace() const { return static_cast(object()); @@ -1056,28 +867,6 @@ QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const return QAccessible::queryAccessibleInterface(calendarView()); } -int QAccessibleCalendarWidget::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const -{ - *target = 0; - if (entry <= 0 || entry > childCount()) - return QAccessibleWidget::navigate(relation, entry, target); - QWidget *targetWidget = 0; - switch (relation) { - case QAccessible::Up: - if (entry == 2) - targetWidget = navigationBar(); - break; - case QAccessible::Down: - if (entry == 1 && childCount() == 2) - targetWidget = calendarView(); - break; - default: - return QAccessibleWidget::navigate(relation, entry, target); - } - *target = QAccessible::queryAccessibleInterface(targetWidget); - return *target ? 0 : -1; -} - QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const { return static_cast(object()); diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h index e60ed06b59..c1c1cbbd0e 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.h +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h @@ -154,7 +154,6 @@ public: int childCount() const; QAccessibleInterface *child(int index) const; int indexOfChild(const QAccessibleInterface *child) const; - int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const; protected: QMdiArea *mdiArea() const; @@ -171,7 +170,6 @@ public: 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; protected: @@ -188,7 +186,6 @@ public: int childCount() const; QAccessibleInterface *child(int index) const; int indexOfChild(const QAccessibleInterface *child) const; - int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const; protected: QWorkspace *workspace() const; @@ -221,7 +218,6 @@ public: int childCount() const; int indexOfChild(const QAccessibleInterface *child) const; - int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const; QAccessibleInterface *child(int index) const; diff --git a/src/plugins/platforms/windows/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/qwindowsaccessibility.cpp index 82e65f66b5..4de4294e8f 100644 --- a/src/plugins/platforms/windows/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/qwindowsaccessibility.cpp @@ -827,8 +827,14 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accChild(VARIANT varChildID, I if (childIndex) { acc = accessible->child(childIndex - 1); } else { - // FIXME - Q_ASSERT(0); + // Yes, some AT clients (Active Accessibility Object Inspector) + // actually ask for the same object. As a consequence, we need to clone ourselves: + if (QAccessibleInterface *par = accessible->parent()) { + const int indexOf = par->indexOfChild(accessible); + QAccessibleInterface *clone = par->child(indexOf); + delete par; + acc = clone; + } } } -- cgit v1.2.3