| 1 | // Copyright (C) 2021 The Qt Company Ltd. | 
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 3 | |
| 4 | #include "qaccessiblequickpage_p.h" | 
| 5 | #include "qquickpage_p.h" | 
| 6 | |
| 7 | QT_BEGIN_NAMESPACE | 
| 8 | |
| 9 | QAccessibleQuickPage::QAccessibleQuickPage(QQuickPage *page) | 
| 10 | : QAccessibleQuickItem(page) | 
| 11 | { | 
| 12 | } | 
| 13 | |
| 14 | QAccessibleInterface *QAccessibleQuickPage::child(int index) const | 
| 15 | { | 
| 16 | const QList<QQuickItem*> kids = orderedChildItems(); | 
| 17 | if (QQuickItem *item = kids.value(i: index)) | 
| 18 | return QAccessible::queryAccessibleInterface(item); | 
| 19 | return nullptr; | 
| 20 | } | 
| 21 | |
| 22 | int QAccessibleQuickPage::indexOfChild(const QAccessibleInterface *iface) const | 
| 23 | { | 
| 24 | const QList<QQuickItem*> kids = orderedChildItems(); | 
| 25 | return (int)kids.indexOf(t: static_cast<QQuickItem*>(iface->object())); | 
| 26 | } | 
| 27 | |
| 28 | QList<QQuickItem *> QAccessibleQuickPage::orderedChildItems() const | 
| 29 | { | 
| 30 | // Just ensures that the header is first, and footer is last. Other existing order is kept. | 
| 31 | const QQuickPage *p = page(); | 
| 32 | QList<QQuickItem*> kids = childItems(); | 
| 33 | const qsizetype hidx = kids.indexOf(t: p->header()); | 
| 34 | if (hidx != -1) | 
| 35 | kids.move(from: hidx, to: 0); | 
| 36 | const qsizetype fidx = kids.indexOf(t: p->footer()); | 
| 37 | if (fidx != -1) | 
| 38 | kids.move(from: fidx, to: kids.size() - 1); | 
| 39 | return kids; | 
| 40 | } | 
| 41 | |
| 42 | QQuickPage *QAccessibleQuickPage::page() const | 
| 43 | { | 
| 44 | return static_cast<QQuickPage*>(object()); | 
| 45 | } | 
| 46 | |
| 47 | QT_END_NAMESPACE | 
| 48 | |
| 49 | 
