Remove QAccessible::FocusChild, add focusChild()

Also cleanup (reduce) all implementations of navigate() in order
to make the final removal of navigate smoother.

Change-Id: I2c216db8f5b2e40afcce8f859fc775053adc2fe3
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
bb10
Jan-Arve Saether 2012-01-19 14:20:54 +01:00 committed by Qt by Nokia
parent fdf9ee1291
commit 1d18fd0164
14 changed files with 52 additions and 179 deletions

View File

@ -909,6 +909,16 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleInterfa
return QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >();
}
/*!
Returns the object that has the keyboard focus.
The object returned can be any descendant, including itself.
*/
QAccessibleInterface *QAccessibleInterface::focusChild() const
{
return 0;
}
/*!
\fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
@ -991,6 +1001,14 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleInterfa
\sa relationTo(), childCount(), parent(), child()
*/
int QAccessibleInterface::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
{
Q_UNUSED(entry);
Q_UNUSED(relation);
*target = 0;
return -1;
}
/*!
\fn QString QAccessibleInterface::text(QAccessible::Text t) const

View File

@ -307,7 +307,6 @@ public:
enum RelationFlag {
Unrelated = 0x00000000,
FocusChild = 0x00010000,
Label = 0x00020000,
Labelled = 0x00040000,
Controller = 0x00080000,
@ -382,6 +381,7 @@ public:
// relations
virtual QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
virtual QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations() const;
virtual QAccessibleInterface *focusChild() const;
virtual QAccessibleInterface *childAt(int x, int y) const = 0;
@ -390,7 +390,7 @@ public:
virtual QAccessibleInterface *child(int index) const = 0;
virtual int childCount() const = 0;
virtual int indexOfChild(const QAccessibleInterface *) const = 0;
virtual int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
virtual int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
// properties and state
virtual QString text(QAccessible::Text t) const = 0;

View File

@ -237,28 +237,13 @@ QAccessibleInterface *QAccessibleApplication::child(int index) const
return 0;
}
/*! \reimp */
int QAccessibleApplication::navigate(QAccessible::RelationFlag relation, int,
QAccessibleInterface **target) const
QAccessibleInterface *QAccessibleApplication::focusChild() const
{
if (!target)
return -1;
*target = 0;
QObject *targetObject = 0;
switch (relation) {
case QAccessible::FocusChild:
if (QWindow *window = QGuiApplication::activeWindow()) {
*target = window->accessibleRoot();
return 0;
}
break;
default:
break;
}
*target = QAccessible::queryAccessibleInterface(targetObject);
return *target ? 0 : -1;
if (QWindow *window = QGuiApplication::activeWindow())
return window->accessibleRoot();
return 0;
}
/*! \reimp */

View File

@ -85,11 +85,11 @@ public:
// relations
int childCount() const;
int indexOfChild(const QAccessibleInterface*) const;
QAccessibleInterface *focusChild() const;
// navigation
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag, int, QAccessibleInterface **) const;
// properties and state
QString text(QAccessible::Text t) const;

View File

@ -122,13 +122,6 @@ public:
return QAccessible::queryAccessibleInterface(m_parent);
}
QAccessibleInterface *child(int) const { return 0; }
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
Q_UNUSED(relation);
Q_UNUSED(index);
Q_UNUSED(iface);
return -1;
}
// action interface
QStringList actionNames() const
{

View File

@ -442,14 +442,6 @@ QAccessibleInterface *QAccessibleTable::child(int index) const
return childFromLogical(index + 1);
}
int QAccessibleTable::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
Q_UNUSED(relation);
Q_UNUSED(index);
*iface = 0;
return -1;
}
void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TableInterface)
@ -780,41 +772,6 @@ QAccessibleInterface *QAccessibleTableCell::child(int) const
return 0;
}
int QAccessibleTableCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
Q_UNUSED(index);
Q_UNUSED(relation);
// switch (relation) {
// From table1 implementation:
// case Up:
// case Down:
// case Left:
// case Right: {
// // This is in the "not so nice" category. In order to find out which item
// // is geometrically around, we have to set the current index, navigate
// // and restore the index as well as the old selection
// view->setUpdatesEnabled(false);
// const QModelIndex oldIdx = view->currentIndex();
// QList<QModelIndex> kids = children();
// const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row);
// const QItemSelection oldSelection = view->selectionModel()->selection();
// view->setCurrentIndex(currentIndex);
// const QModelIndex idx = view->moveCursor(toCursorAction(relation), Qt::NoModifier);
// view->setCurrentIndex(oldIdx);
// view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
// view->setUpdatesEnabled(true);
// if (!idx.isValid())
// return -1;
// if (idx.parent() != row.parent() || idx.row() != row.row())
// *iface = cell(idx);
// return index ? kids.indexOf(idx) + 1 : 0; }
// }
*iface = 0;
return -1;
}
QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_)
: view(view_), index(index_), orientation(orientation_)
{
@ -905,15 +862,6 @@ QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const
return 0;
}
int QAccessibleTableHeaderCell::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const
{
Q_UNUSED(relation);
Q_UNUSED(index);
Q_UNUSED(iface);
return -1;
}
#endif // QT_NO_ITEMVIEWS
QT_END_NAMESPACE

View File

@ -77,7 +77,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
void *interface_cast(QAccessible::InterfaceType t);
@ -190,7 +189,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int) const;
int navigate(QAccessible::RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
// cell interface
virtual int columnExtent() const;
@ -236,7 +234,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface **iface) const;
private:
QAbstractItemView *view;
@ -276,13 +273,6 @@ public:
QAccessibleInterface *child(int) const {
return 0;
}
int navigate(QAccessible::RelationFlag relation, int, QAccessibleInterface **iface) const
{
Q_UNUSED(relation);
Q_UNUSED(iface);
return -1;
}
private:
QAbstractItemView *view;
};

View File

@ -204,14 +204,6 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const
return 0;
}
int QAccessibleMenuItem::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **target) const
{
Q_UNUSED(relation);
Q_UNUSED(entry);
*target = 0;
return -1;
}
void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::ActionInterface)

View File

@ -103,7 +103,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface ** target) const;
QObject * object() const;
QRect rect() const;
QAccessible::Role role() const;

View File

@ -965,34 +965,6 @@ QAccessibleInterface *QAccessibleTitleBar::child(int index) const
return 0;
}
int QAccessibleTitleBar::navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **iface) const
{
switch (relation) {
case QAccessible::FocusChild:
// ###
if (entry >= 1) {
QDockWidgetLayout *layout = dockWidgetLayout();
int index = 1;
int role;
for (role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) {
QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
if (!w->isVisible())
continue;
if (index == entry)
break;
++index;
}
*iface = 0;
return role > QDockWidgetLayout::FloatButton ? -1 : index;
}
break;
default:
break;
}
*iface = 0;
return -1;
}
int QAccessibleTitleBar::indexOfChild(const QAccessibleInterface * /*child*/) const
{
return -1;

View File

@ -248,7 +248,6 @@ public:
QAccessibleInterface *parent() const;
QAccessibleInterface *child(int index) const;
int navigate(QAccessible::RelationFlag relation, int entry, QAccessibleInterface **iface) const;
int indexOfChild(const QAccessibleInterface *child) const;
int childCount() const;
QAccessibleInterface *childAt(int x, int y) const;

View File

@ -1189,29 +1189,18 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accFocus(VARIANT *pvarID)
if (!accessible->isValid())
return E_FAIL;
QAccessibleInterface *acc = 0;
int control = accessible->navigate(QAccessible::FocusChild, 1, &acc);
if (control == -1) {
(*pvarID).vt = VT_EMPTY;
return S_FALSE;
if (QAccessibleInterface *acc = accessible->focusChild()) {
QWindowsAccessible* wacc = new QWindowsAccessible(acc);
IDispatch *iface = 0;
wacc->QueryInterface(IID_IDispatch, (void**)&iface);
if (iface) {
(*pvarID).vt = VT_DISPATCH;
(*pvarID).pdispVal = iface;
return S_OK;
} else {
delete wacc;
}
}
if (!acc || control == 0) {
(*pvarID).vt = VT_I4;
(*pvarID).lVal = control ? control : CHILDID_SELF;
return S_OK;
}
QWindowsAccessible* wacc = new QWindowsAccessible(acc);
IDispatch *iface = 0;
wacc->QueryInterface(IID_IDispatch, (void**)&iface);
if (iface) {
(*pvarID).vt = VT_DISPATCH;
(*pvarID).pdispVal = iface;
return S_OK;
} else {
delete wacc;
}
(*pvarID).vt = VT_EMPTY;
return S_FALSE;
}

View File

@ -339,10 +339,6 @@ QAccessible::Relation QAccessibleWidget::relationTo(const QAccessibleInterface *
if (!o)
return relation;
QWidget *focus = widget()->focusWidget();
if (object() == focus && isAncestor(o, focus))
relation |= QAccessible::FocusChild;
QACConnectionObject *connectionObject = (QACConnectionObject*)object();
for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) {
@ -382,6 +378,20 @@ QAccessibleInterface *QAccessibleWidget::child(int index) const
return 0;
}
/*! \reimp */
QAccessibleInterface *QAccessibleWidget::focusChild() const
{
if (widget()->hasFocus())
return QAccessible::queryAccessibleInterface(object());
QWidget *fw = widget()->focusWidget();
if (!fw)
return 0;
if (isAncestor(widget(), fw) || fw == widget())
return QAccessible::queryAccessibleInterface(fw);
}
/*! \reimp */
int QAccessibleWidget::navigate(QAccessible::RelationFlag relation, int entry,
QAccessibleInterface **target) const
@ -394,29 +404,6 @@ int QAccessibleWidget::navigate(QAccessible::RelationFlag relation, int entry,
switch (relation) {
// Logical
case QAccessible::FocusChild:
{
if (widget()->hasFocus()) {
targetObject = object();
break;
}
QWidget *fw = widget()->focusWidget();
if (!fw)
return -1;
if (isAncestor(widget(), fw) || fw == widget())
targetObject = fw;
/* ###
QWidget *parent = fw;
while (parent && !targetObject) {
parent = parent->parentWidget();
if (parent == widget())
targetObject = fw;
}
*/
}
break;
case QAccessible::Label:
if (entry > 0) {
QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());

View File

@ -62,6 +62,7 @@ public:
int childCount() const;
int indexOfChild(const QAccessibleInterface *child) const;
QAccessible::Relation relationTo(const QAccessibleInterface *other) const;
QAccessibleInterface *focusChild() const;
QRect rect() const;