Skip to content

Commit

Permalink
Remove all references to QAccessible:: {Child|Ancestor|Sibling}
Browse files Browse the repository at this point in the history
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 bridge

Change-Id: Ie63d74314189d9e0f24f1152a2f0030d9e865b75
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
  • Loading branch information
Jan-Arve Saether authored and Qt by Nokia committed Jan 5, 2012
1 parent 4e9efd5 commit c831c9f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 108 deletions.
45 changes: 0 additions & 45 deletions src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp
Expand Up @@ -129,50 +129,6 @@ int QAccessibleDeclarativeItem::navigate(QAccessible::RelationFlag rel, int entr
}

switch (rel) {
case QAccessible::Child: {
QList<QGraphicsItem *> children = m_item->childItems();
const int childIndex = entry - 1;

if (childIndex >= children.count())
return -1;

QGraphicsItem *child = children.at(childIndex);
QGraphicsObject *childObject = qobject_cast<QGraphicsObject *>(child);
if (!childObject)
return -1;

*target = new QAccessibleDeclarativeItem(childObject, m_view);
return 0;
break;}
case QAccessible::Ancestor: {
Q_ASSERT(entry >= 1);
QGraphicsItem *parent = m_item->parentItem();
QGraphicsObject *parentObj = parent ? parent->toGraphicsObject() : 0;
if (parent && !parentObj)
qWarning("Can not make QGraphicsItems accessible");
QAccessibleInterface *ancestor = (parentObj
? new QAccessibleDeclarativeItem(parentObj, m_view)
: QAccessible::queryAccessibleInterface(m_view));
if (entry == 1) {
*target = ancestor;
return 0;
} else if (entry > 1) {
int ret = ancestor->navigate(QAccessible::Ancestor, entry - 1, target);
delete ancestor;
return ret;
}
break;}
case QAccessible::Sibling: {
QAccessibleInterface *iface = 0;
if (navigate(QAccessible::Ancestor, 1, &iface) == 0) {
if (iface) {
int ret = iface->navigate(QAccessible::Child, entry, target);
delete iface;
return ret;
}
}
return -1;
break;}
case QAccessible::FocusChild: {
QGraphicsObject *focusObject = 0;
if (m_item->hasFocus()) {
Expand All @@ -194,7 +150,6 @@ int QAccessibleDeclarativeItem::navigate(QAccessible::RelationFlag rel, int entr
}

return -1;

}

int QAccessibleDeclarativeItem::indexOfChild(const QAccessibleInterface *iface) const
Expand Down
11 changes: 2 additions & 9 deletions src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp
Expand Up @@ -68,17 +68,10 @@ QAccessibleInterface *QAccessibleDeclarativeView::child(int index) const
return 0;
}

int QAccessibleDeclarativeView::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
{
if (rel == QAccessible::Child) {
*target = child(entry - 1);
return *target ? 0 : -1;
}
return QAccessibleWidget::navigate(rel, entry, target);
}

QAccessibleInterface *QAccessibleDeclarativeView::childAt(int x, int y) const
{
Q_UNUSED(x);
Q_UNUSED(y);
return child(0); // return the top-level QML item
}

Expand Down
Expand Up @@ -60,7 +60,6 @@ class QAccessibleDeclarativeView: public QAccessibleWidget

QAccessibleInterface *child(int index) const;
int childCount() const;
int navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const;
QAccessibleInterface *childAt(int x, int y) const;
int indexOfChild(const QAccessibleInterface *iface) const;

Expand Down
47 changes: 3 additions & 44 deletions src/plugins/accessible/quick/qaccessiblequickitem.cpp
Expand Up @@ -141,55 +141,14 @@ QAccessibleInterface *QAccessibleQuickItem::child(int index) const

int QAccessibleQuickItem::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
{
Q_UNUSED(rel);
Q_UNUSED(entry);
Q_UNUSED(target);
*target = 0;
if (entry == 0) {
*target = new QAccessibleQuickItem(m_item);
return 0;
}

switch (rel) {
case QAccessible::Child: { // FIMXE
QList<QQuickItem *> children = childItems();
const int childIndex = entry - 1;

if (childIndex >= children.count())
return -1;

QQuickItem *child = children.at(childIndex);
if (!child)
return -1;

*target = new QAccessibleQuickItem(child);
return 0;
break;}
case QAccessible::Ancestor: { // FIMXE
QQuickItem *parent = m_item->parentItem();
if (parent) {
QDeclarativeAccessible *ancestor = new QAccessibleQuickItem(parent);
if (entry == 1) {
QQuickCanvas *canvas = m_item->canvas();
// Jump out to the scene widget if the parent is the root item.
// There are two root items, QQuickCanvas::rootItem and
// QQuickView::declarativeRoot. The former is the true root item,
// but is not a part of the accessibility tree. Check if we hit
// it here and return an interface for the scene instead.
if (parent == canvas->rootItem()) {
*target = QAccessible::queryAccessibleInterface(canvas);
} else {
*target = ancestor;
}
return 0;
} else if (entry > 1) {
int ret = ancestor->navigate(QAccessible::Ancestor, entry - 1, target);
delete ancestor;
return ret;
}
}
return -1;
break;}
default: break;
}

return -1;
}

Expand Down
13 changes: 4 additions & 9 deletions src/plugins/accessible/quick/qaccessiblequickview.cpp
Expand Up @@ -93,15 +93,10 @@ QRect QAccessibleQuickView::rect() const

int QAccessibleQuickView::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const
{
switch (rel) {
case QAccessible::Child:
*target = child(entry - 1);
case QAccessible::Ancestor:
*target = parent();
default:
*target = 0;
}
return *target ? 0 : -1;
Q_UNUSED(rel);
Q_UNUSED(entry);
Q_UNUSED(target);
return -1;
}

QString QAccessibleQuickView::text(QAccessible::Text text) const
Expand Down

0 comments on commit c831c9f

Please sign in to comment.