Commit f0833861 authored by Jan Arve Saether's avatar Jan Arve Saether Committed by Jan Arve Sæther
Browse files

Don't assume there is only one toplevel item.


With the upcoming introduction of unignoredChildren, there can
exist many top level items (if the root item is ignored).

Change-Id: If7aaea08fdd4d1f5a0a5109e1239c53e0af9b61e
Reviewed-by: default avatarFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>
parent db16f3e5
No related merge requests found
Showing with 18 additions and 15 deletions
...@@ -50,19 +50,16 @@ QAccessibleQuickWindow::QAccessibleQuickWindow(QQuickWindow *object) ...@@ -50,19 +50,16 @@ QAccessibleQuickWindow::QAccessibleQuickWindow(QQuickWindow *object)
{ {
} }
QQuickItem *QAccessibleQuickWindow::rootItem() const QList<QQuickItem *> QAccessibleQuickWindow::rootItems() const
{ {
if (QQuickItem *ci = window()->contentItem()) { if (QQuickItem *ci = window()->contentItem())
const QList<QQuickItem *> &childItems = accessibleUnignoredChildren(ci); return accessibleUnignoredChildren(ci);
if (!childItems.isEmpty()) return QList<QQuickItem *>();
return childItems.first();
}
return 0;
} }
int QAccessibleQuickWindow::childCount() const int QAccessibleQuickWindow::childCount() const
{ {
return rootItem() ? 1 : 0; return rootItems().count();
} }
QAccessibleInterface *QAccessibleQuickWindow::parent() const QAccessibleInterface *QAccessibleQuickWindow::parent() const
...@@ -73,8 +70,9 @@ QAccessibleInterface *QAccessibleQuickWindow::parent() const ...@@ -73,8 +70,9 @@ QAccessibleInterface *QAccessibleQuickWindow::parent() const
QAccessibleInterface *QAccessibleQuickWindow::child(int index) const QAccessibleInterface *QAccessibleQuickWindow::child(int index) const
{ {
if (index == 0) const QList<QQuickItem*> &kids = rootItems();
return QAccessible::queryAccessibleInterface(rootItem()); if (index >= 0 && index < kids.count())
return QAccessible::queryAccessibleInterface(kids.at(index));
return 0; return 0;
} }
...@@ -127,12 +125,17 @@ QAccessibleInterface *QAccessibleQuickWindow::childAt(int x, int y) const ...@@ -127,12 +125,17 @@ QAccessibleInterface *QAccessibleQuickWindow::childAt(int x, int y) const
int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) const int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) const
{ {
int i = -1;
if (iface) { if (iface) {
QQuickItem *declarativeRoot = rootItem(); const QList<QQuickItem *> &roots = rootItems();
if (declarativeRoot == iface->object()) i = roots.count() - 1;
return 0; while (i >= 0) {
if (iface->object() == roots.at(i))
break;
--i;
}
} }
return -1; return i;
} }
QT_END_NAMESPACE QT_END_NAMESPACE
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
private: private:
QQuickWindow *window() const { return static_cast<QQuickWindow*>(object()); } QQuickWindow *window() const { return static_cast<QQuickWindow*>(object()); }
QQuickItem *rootItem() const; QList<QQuickItem *> rootItems() const;
}; };
#endif // QT_NO_ACCESSIBILITY #endif // QT_NO_ACCESSIBILITY
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment