summaryrefslogtreecommitdiffstats
path: root/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-09-15 21:41:54 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-19 12:06:13 +0200
commit76d0d1926466d42b1b25f0bac642c1e0f239074c (patch)
tree84397813957307cf1ac393ac29d045acc6e08846 /src/plugins/accessible/widgets/qaccessiblewidgets.cpp
parent3647a00d47fd774daccce9f143cc2046fb59099d (diff)
Add parent and child functions to QAccessibleInterface.
Stop the mis-use of navigate to find the parent. In order to make navigation straight forward parent and child functions are now part of QAccessibleInterface. This allows navigating the hierarchy of accessible objects without the 1-based indexes in the navigate function which lead to confusion. Eventually the support for Ancestor in navigate can be completely removed and forwarded in the windows bridge if needed. In addition default parameters for virtual children. This will make the transition smooth since it allows to remove the integer already. Change-Id: I278287ce17161f9fa46797ac244676778c859576 Reviewed-on: http://codereview.qt-project.org/5024 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/plugins/accessible/widgets/qaccessiblewidgets.cpp')
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index dc16d80c5f..d811f976ab 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -414,22 +414,22 @@ int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) co
return -1;
}
-int QAccessibleStackedWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+QAccessibleInterface *QAccessibleStackedWidget::child(int index) const
{
- *target = 0;
+ if (index < 0 || index >= stackedWidget()->count())
+ return 0;
+ return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index));
+}
- QObject *targetObject = 0;
+int QAccessibleStackedWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
switch (relation) {
case Child:
- if (entry < 1 || entry > stackedWidget()->count())
- return -1;
- targetObject = stackedWidget()->widget(entry-1);
- break;
+ *target = child(entry - 1);
+ return *target ? 0 : -1;
default:
return QAccessibleWidget::navigate(relation, entry, target);
}
- *target = QAccessible::queryAccessibleInterface(targetObject);
- return *target ? 0 : -1;
}
QStackedWidget *QAccessibleStackedWidget::stackedWidget() const
@@ -1069,15 +1069,37 @@ QAccessibleTitleBar::QAccessibleTitleBar(QDockWidget *widget)
}
-int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
+QAccessibleInterface *QAccessibleTitleBar::parent() const
{
- if (entry == 0 || relation == Self) {
- *iface = new QAccessibleTitleBar(dockWidget());
- return 0;
+ return new QAccessibleDockWidget(dockWidget());
+}
+
+QAccessibleInterface *QAccessibleTitleBar::child(int index) const
+{
+ if (index >= 0) {
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ int role;
+ int currentIndex = 0;
+ for (role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) {
+ QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
+ if (!w || !w->isVisible())
+ continue;
+ if (currentIndex == index)
+ return QAccessible::queryAccessibleInterface(w);
+ ++currentIndex;
+ }
}
+ return 0;
+}
+
+int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
+{
switch (relation) {
case Child:
+ *iface = child(entry - 1);
+ return *iface ? 0 : -1;
case FocusChild:
+ // ###
if (entry >= 1) {
QDockWidgetLayout *layout = dockWidgetLayout();
int index = 1;
@@ -1095,18 +1117,8 @@ int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleI
}
break;
case Ancestor:
- {
- QAccessibleDockWidget *target = new QAccessibleDockWidget(dockWidget());
- int index;
- if (entry == 1) {
- *iface = target;
- return 0;
- }
- index = target->navigate(Ancestor, entry - 1, iface);
- delete target;
- return index;
-
- break;}
+ *iface = parent();
+ return iface ? 0 : -1;
case Sibling:
return navigate(Child, entry, iface);
break;