| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/accessible/qplatformaccessibility.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | #include "qplatformaccessibility.h" | - | ||||||||||||
| 40 | #include <private/qfactoryloader_p.h> | - | ||||||||||||
| 41 | #include "qaccessibleplugin.h" | - | ||||||||||||
| 42 | #include "qaccessibleobject.h" | - | ||||||||||||
| 43 | #include "qaccessiblebridge.h" | - | ||||||||||||
| 44 | #include <QtGui/QGuiApplication> | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | #include <QDebug> | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | /* accessiblebridge plugin discovery stuff */ | - | ||||||||||||
| 53 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, bridgeloader, never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||
| 54 | (QAccessibleBridgeFactoryInterface_iid, QLatin1String("/accessiblebridge"))) | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | Q_GLOBAL_STATIC(QVector<QAccessibleBridge *>, bridges) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||||||||
| 57 | - | |||||||||||||
| 58 | /*! | - | ||||||||||||
| 59 | \class QPlatformAccessibility | - | ||||||||||||
| 60 | \since 5.0 | - | ||||||||||||
| 61 | \internal | - | ||||||||||||
| 62 | \preliminary | - | ||||||||||||
| 63 | \ingroup qpa | - | ||||||||||||
| 64 | \ingroup accessibility | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | \brief The QPlatformAccessibility class is the base class for | - | ||||||||||||
| 67 | integrating accessibility backends | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | \sa QAccessible | - | ||||||||||||
| 70 | */ | - | ||||||||||||
| 71 | QPlatformAccessibility::QPlatformAccessibility() | - | ||||||||||||
| 72 | : m_active(false) | - | ||||||||||||
| 73 | { | - | ||||||||||||
| 74 | } never executed: end of block | 0 | ||||||||||||
| 75 | - | |||||||||||||
| 76 | QPlatformAccessibility::~QPlatformAccessibility() | - | ||||||||||||
| 77 | { | - | ||||||||||||
| 78 | } | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | void QPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) | - | ||||||||||||
| 81 | { | - | ||||||||||||
| 82 | initialize(); | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | if (!bridges() || bridges()->isEmpty())
| 0 | ||||||||||||
| 85 | return; never executed: return; | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | for (int i = 0; i < bridges()->count(); ++i)
| 0 | ||||||||||||
| 88 | bridges()->at(i)->notifyAccessibilityUpdate(event); never executed: bridges()->at(i)->notifyAccessibilityUpdate(event); | 0 | ||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||
| 90 | - | |||||||||||||
| 91 | void QPlatformAccessibility::setRootObject(QObject *o) | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | initialize(); | - | ||||||||||||
| 94 | if (bridges()->isEmpty())
| 0 | ||||||||||||
| 95 | return; never executed: return; | 0 | ||||||||||||
| 96 | - | |||||||||||||
| 97 | if (!o)
| 0 | ||||||||||||
| 98 | return; never executed: return; | 0 | ||||||||||||
| 99 | - | |||||||||||||
| 100 | for (int i = 0; i < bridges()->count(); ++i) {
| 0 | ||||||||||||
| 101 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); | - | ||||||||||||
| 102 | bridges()->at(i)->setRootObject(iface); | - | ||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||
| 104 | } never executed: end of block | 0 | ||||||||||||
| 105 | - | |||||||||||||
| 106 | void QPlatformAccessibility::initialize() | - | ||||||||||||
| 107 | { | - | ||||||||||||
| 108 | static bool isInit = false; | - | ||||||||||||
| 109 | if (isInit)
| 0 | ||||||||||||
| 110 | return; never executed: return; | 0 | ||||||||||||
| 111 | isInit = true; // ### not atomic | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | typedef QMultiMap<int, QString> PluginKeyMap; | - | ||||||||||||
| 114 | typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | const PluginKeyMap keyMap = bridgeloader()->keyMap(); | - | ||||||||||||
| 117 | QAccessibleBridgePlugin *factory = 0; | - | ||||||||||||
| 118 | int i = -1; | - | ||||||||||||
| 119 | const PluginKeyMapConstIterator cend = keyMap.constEnd(); | - | ||||||||||||
| 120 | for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
| 0 | ||||||||||||
| 121 | if (it.key() != i) {
| 0 | ||||||||||||
| 122 | i = it.key(); | - | ||||||||||||
| 123 | factory = qobject_cast<QAccessibleBridgePlugin*>(bridgeloader()->instance(i)); | - | ||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||
| 125 | if (factory)
| 0 | ||||||||||||
| 126 | if (QAccessibleBridge *bridge = factory->create(it.value()))
| 0 | ||||||||||||
| 127 | bridges()->append(bridge); never executed: bridges()->append(bridge); | 0 | ||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||
| 130 | - | |||||||||||||
| 131 | void QPlatformAccessibility::cleanup() | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | qDeleteAll(*bridges()); | - | ||||||||||||
| 134 | } never executed: end of block | 0 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | void QPlatformAccessibility::setActive(bool active) | - | ||||||||||||
| 137 | { | - | ||||||||||||
| 138 | m_active = active; | - | ||||||||||||
| 139 | QAccessible::setActive(active); | - | ||||||||||||
| 140 | } never executed: end of block | 0 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |