diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2012-03-23 17:42:09 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-10 21:03:04 +0200 |
commit | 80872d0a450d4179e66121d8efe01929ad56fb05 (patch) | |
tree | f00280e8b9b7f8d1d2386f0c41542edef01dc021 /src/plugins/accessible | |
parent | 3bac6c910e87d28ddbbf0779d32bca72bc57dbd4 (diff) |
Create accessible interfaces only for items with attached prop
If the attached property is not found, ignore the item, unless
it is part of the tree. We still create a valid hierarchy this
way, but filter out all irrelevant items. The same goes for
hit-testing.
On the other hand this patch enables the root item to be found
by setting isAccessible on it when updating the flags. Otherwise
the hierarchy is not valid again.
Change-Id: Ied422fd0506d13458757c87a5dad7cdb9d3079bf
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/plugins/accessible')
-rw-r--r-- | src/plugins/accessible/quick/main.cpp | 6 | ||||
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickview.cpp | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/accessible/quick/main.cpp b/src/plugins/accessible/quick/main.cpp index 2c75e594c2..6592c59e0f 100644 --- a/src/plugins/accessible/quick/main.cpp +++ b/src/plugins/accessible/quick/main.cpp @@ -46,6 +46,7 @@ #include <QtQuick/QQuickView> #include <QtQuick/QQuickItem> +#include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquickaccessibleattached_p.h> #include <qaccessibleplugin.h> @@ -86,8 +87,11 @@ QAccessibleInterface *AccessibleQuickFactory::create(const QString &classname, Q if (classname == QLatin1String("QQuickView")) { return new QAccessibleQuickView(qobject_cast<QQuickView *>(object)); // FIXME } else if (classname == QLatin1String("QQuickItem")) { - QQuickItem * item = qobject_cast<QQuickItem *>(object); + QQuickItem *item = qobject_cast<QQuickItem *>(object); Q_ASSERT(item); + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + if (!itemPrivate->isAccessible) + return 0; QVariant v = QQuickAccessibleAttached::property(item, "role"); bool ok; diff --git a/src/plugins/accessible/quick/qaccessiblequickview.cpp b/src/plugins/accessible/quick/qaccessiblequickview.cpp index 2df1f243b8..ed8167f4d1 100644 --- a/src/plugins/accessible/quick/qaccessiblequickview.cpp +++ b/src/plugins/accessible/quick/qaccessiblequickview.cpp @@ -127,7 +127,11 @@ static QQuickItem *childAt_helper(QQuickItem *item, int x, int y) } QScopedPointer<QAccessibleInterface> accessibleInterface(QAccessible::queryAccessibleInterface(item)); - if (accessibleInterface && accessibleInterface->childCount() == 0) { + // this item has no Accessible attached property + if (!accessibleInterface) + return 0; + + if (accessibleInterface->childCount() == 0) { return (itemScreenRect(item).contains(x, y)) ? item : 0; } @@ -155,6 +159,7 @@ QAccessibleInterface *QAccessibleQuickView::childAt(int x, int y) const if (root) { if (QQuickItem *item = childAt_helper(root, x, y)) return QAccessible::queryAccessibleInterface(item); + return QAccessible::queryAccessibleInterface(root); } return 0; } |