diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-11-22 18:08:05 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-19 12:27:45 +0100 |
commit | 74c9f9d83f9f5cb934d0b62b468c74df5a3b9a0d (patch) | |
tree | ea5e783b8d025ce2d525dab5c524aaee298dd6b9 /src/gui/accessible/qaccessibleobject.cpp | |
parent | 7e12d2d30f74b5fe1f80fac7192416cf6eb22d4d (diff) |
Accessibility: childAt returns interface
childAt used to return an integer.
Return an interface instead.
Not requiring a direct child to be returned allows optimizing
by bypassing iterating through the hierarchy of accessibles.
For QtQuick this is the only sensible way of implementing this.
The bridges are still responsible for finding the top-most element.
The default implementation in QAccessibleObject is sufficient
to return direct children. The implementation in
QAccessibleApplication is therfore no longer needed.
Change-Id: Id7100dd5bcc3a98de516a7f4a12eaaa41cb46d26
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/gui/accessible/qaccessibleobject.cpp')
-rw-r--r-- | src/gui/accessible/qaccessibleobject.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 18941437fe..b3e9479013 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -154,6 +154,18 @@ void QAccessibleObject::setText(QAccessible::Text, const QString &) { } +/*! \reimp */ +QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const +{ + for (int i = 0; i < childCount(); ++i) { + QAccessibleInterface *childIface = child(i); + if (childIface->rect().contains(x,y)) { + return childIface; + } + } + return 0; +} + /*! \class QAccessibleApplication \brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication. @@ -214,19 +226,6 @@ int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) cons } /*! \reimp */ -int QAccessibleApplication::childAt(int x, int y) const -{ - for (int i = 0; i < childCount(); ++i) { - QAccessibleInterface *childIface = child(i); - QRect geom = childIface->rect(); - if (geom.contains(x,y)) - return i+1; - delete childIface; - } - return rect().contains(x,y) ? 0 : -1; -} - -/*! \reimp */ QAccessible::Relation QAccessibleApplication::relationTo(const QAccessibleInterface *other) const { QObject *o = other ? other->object() : 0; |