1 | // Copyright (C) 2016 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 | #ifndef QACCESSIBLECACHE_P |
5 | #define QACCESSIBLECACHE_P |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/private/qtguiglobal_p.h> |
19 | #include <QtCore/qobject.h> |
20 | #include <QtCore/qhash.h> |
21 | |
22 | #include "qaccessible.h" |
23 | |
24 | #if QT_CONFIG(accessibility) |
25 | |
26 | Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QMacAccessibilityElement)); |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | class Q_GUI_EXPORT QAccessibleCache :public QObject |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | ~QAccessibleCache() override; |
36 | static QAccessibleCache *instance(); |
37 | QAccessibleInterface *interfaceForId(QAccessible::Id id) const; |
38 | QAccessible::Id idForInterface(QAccessibleInterface *iface) const; |
39 | QAccessible::Id idForObject(QObject *obj) const; |
40 | bool containsObject(QObject *obj) const; |
41 | QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; |
42 | void deleteInterface(QAccessible::Id id, QObject *obj = nullptr); |
43 | |
44 | #ifdef Q_OS_MAC |
45 | QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *elementForId(QAccessible::Id axid) const; |
46 | void insertElement(QAccessible::Id axid, QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element) const; |
47 | #endif |
48 | |
49 | private Q_SLOTS: |
50 | void objectDestroyed(QObject *obj); |
51 | |
52 | private: |
53 | QAccessible::Id acquireId() const; |
54 | |
55 | mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface; |
56 | mutable QHash<QAccessibleInterface *, QAccessible::Id> interfaceToId; |
57 | mutable QMultiHash<QObject *, QPair<QAccessible::Id, const QMetaObject*>> objectToId; |
58 | |
59 | #ifdef Q_OS_MAC |
60 | void removeCocoaElement(QAccessible::Id axid); |
61 | mutable QHash<QAccessible::Id, QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *> cocoaElements; |
62 | #endif |
63 | |
64 | friend class QAccessible; |
65 | friend class QAccessibleInterface; |
66 | }; |
67 | |
68 | QT_END_NAMESPACE |
69 | |
70 | #endif // QT_CONFIG(accessibility) |
71 | |
72 | #endif |
73 |