| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/accessible/qaccessibleobject.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 | - | |||||||||||||
| 40 | #include "qaccessibleobject.h" | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #include <QtGui/QGuiApplication> | - | ||||||||||||
| 45 | #include <QtGui/QWindow> | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #include "qpointer.h" | - | ||||||||||||
| 48 | #include "qmetaobject.h" | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | class QAccessibleObjectPrivate | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | public: | - | ||||||||||||
| 55 | QPointer<QObject> object; | - | ||||||||||||
| 56 | }; | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | /*! | - | ||||||||||||
| 59 | \class QAccessibleObject | - | ||||||||||||
| 60 | \brief The QAccessibleObject class implements parts of the | - | ||||||||||||
| 61 | QAccessibleInterface for QObjects. | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | \ingroup accessibility | - | ||||||||||||
| 64 | \inmodule QtGui | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | This class is part of \l {Accessibility for QWidget Applications}. | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | This class is mainly provided for convenience. All subclasses of | - | ||||||||||||
| 69 | the QAccessibleInterface that provide implementations of non-widget objects | - | ||||||||||||
| 70 | should use this class as their base class. | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | \sa QAccessible, QAccessibleWidget | - | ||||||||||||
| 73 | */ | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | /*! | - | ||||||||||||
| 76 | Creates a QAccessibleObject for \a object. | - | ||||||||||||
| 77 | */ | - | ||||||||||||
| 78 | QAccessibleObject::QAccessibleObject(QObject *object) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | d = new QAccessibleObjectPrivate; | - | ||||||||||||
| 81 | d->object = object; | - | ||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | /*! | - | ||||||||||||
| 85 | Destroys the QAccessibleObject. | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | This only happens when a call to release() decrements the internal | - | ||||||||||||
| 88 | reference counter to zero. | - | ||||||||||||
| 89 | */ | - | ||||||||||||
| 90 | QAccessibleObject::~QAccessibleObject() | - | ||||||||||||
| 91 | { | - | ||||||||||||
| 92 | delete d; | - | ||||||||||||
| 93 | } never executed: end of block | 0 | ||||||||||||
| 94 | - | |||||||||||||
| 95 | /*! | - | ||||||||||||
| 96 | \reimp | - | ||||||||||||
| 97 | */ | - | ||||||||||||
| 98 | QObject *QAccessibleObject::object() const | - | ||||||||||||
| 99 | { | - | ||||||||||||
| 100 | return d->object; never executed: return d->object; | 0 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | /*! | - | ||||||||||||
| 104 | \reimp | - | ||||||||||||
| 105 | */ | - | ||||||||||||
| 106 | bool QAccessibleObject::isValid() const | - | ||||||||||||
| 107 | { | - | ||||||||||||
| 108 | return !d->object.isNull(); never executed: return !d->object.isNull(); | 0 | ||||||||||||
| 109 | } | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | /*! \reimp */ | - | ||||||||||||
| 112 | QRect QAccessibleObject::rect() const | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | /*! \reimp */ | - | ||||||||||||
| 118 | void QAccessibleObject::setText(QAccessible::Text, const QString &) | - | ||||||||||||
| 119 | { | - | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | /*! \reimp */ | - | ||||||||||||
| 123 | QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | for (int i = 0; i < childCount(); ++i) {
| 0 | ||||||||||||
| 126 | QAccessibleInterface *childIface = child(i); | - | ||||||||||||
| 127 | Q_ASSERT(childIface); | - | ||||||||||||
| 128 | if (childIface->rect().contains(x,y))
| 0 | ||||||||||||
| 129 | return childIface; never executed: return childIface; | 0 | ||||||||||||
| 130 | } never executed: end of block | 0 | ||||||||||||
| 131 | return 0; never executed: return 0; | 0 | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | /*! | - | ||||||||||||
| 135 | \class QAccessibleApplication | - | ||||||||||||
| 136 | \brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication. | - | ||||||||||||
| 137 | - | |||||||||||||
| 138 | \internal | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | \ingroup accessibility | - | ||||||||||||
| 141 | */ | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | /*! | - | ||||||||||||
| 144 | Creates a QAccessibleApplication for the QApplication object referenced by qApp. | - | ||||||||||||
| 145 | */ | - | ||||||||||||
| 146 | QAccessibleApplication::QAccessibleApplication() | - | ||||||||||||
| 147 | : QAccessibleObject(qApp) | - | ||||||||||||
| 148 | { | - | ||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||
| 150 | - | |||||||||||||
| 151 | QWindow *QAccessibleApplication::window() const | - | ||||||||||||
| 152 | { | - | ||||||||||||
| 153 | // an application can have several windows, and AFAIK we don't need | - | ||||||||||||
| 154 | // to notify about changes on the application. | - | ||||||||||||
| 155 | return 0; never executed: return 0; | 0 | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | // all toplevel windows except popups and the desktop | - | ||||||||||||
| 159 | static QObjectList topLevelObjects() | - | ||||||||||||
| 160 | { | - | ||||||||||||
| 161 | QObjectList list; | - | ||||||||||||
| 162 | const QWindowList tlw(QGuiApplication::topLevelWindows()); | - | ||||||||||||
| 163 | for (int i = 0; i < tlw.count(); ++i) {
| 0 | ||||||||||||
| 164 | QWindow *w = tlw.at(i); | - | ||||||||||||
| 165 | if (w->type() != Qt::Popup && w->type() != Qt::Desktop) {
| 0 | ||||||||||||
| 166 | if (QAccessibleInterface *root = w->accessibleRoot()) {
| 0 | ||||||||||||
| 167 | if (root->object())
| 0 | ||||||||||||
| 168 | list.append(root->object()); never executed: list.append(root->object()); | 0 | ||||||||||||
| 169 | } never executed: end of block | 0 | ||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||
| 171 | } never executed: end of block | 0 | ||||||||||||
| 172 | - | |||||||||||||
| 173 | return list; never executed: return list; | 0 | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | /*! \reimp */ | - | ||||||||||||
| 177 | int QAccessibleApplication::childCount() const | - | ||||||||||||
| 178 | { | - | ||||||||||||
| 179 | return topLevelObjects().count(); never executed: return topLevelObjects().count(); | 0 | ||||||||||||
| 180 | } | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | /*! \reimp */ | - | ||||||||||||
| 183 | int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||
| 184 | { | - | ||||||||||||
| 185 | if (!child)
| 0 | ||||||||||||
| 186 | return -1; never executed: return -1; | 0 | ||||||||||||
| 187 | const QObjectList tlw(topLevelObjects()); | - | ||||||||||||
| 188 | return tlw.indexOf(child->object()); never executed: return tlw.indexOf(child->object()); | 0 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | QAccessibleInterface *QAccessibleApplication::parent() const | - | ||||||||||||
| 192 | { | - | ||||||||||||
| 193 | return 0; never executed: return 0; | 0 | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | QAccessibleInterface *QAccessibleApplication::child(int index) const | - | ||||||||||||
| 197 | { | - | ||||||||||||
| 198 | const QObjectList tlo(topLevelObjects()); | - | ||||||||||||
| 199 | if (index >= 0 && index < tlo.count())
| 0 | ||||||||||||
| 200 | return QAccessible::queryAccessibleInterface(tlo.at(index)); never executed: return QAccessible::queryAccessibleInterface(tlo.at(index)); | 0 | ||||||||||||
| 201 | return 0; never executed: return 0; | 0 | ||||||||||||
| 202 | } | - | ||||||||||||
| 203 | - | |||||||||||||
| 204 | - | |||||||||||||
| 205 | /*! \reimp */ | - | ||||||||||||
| 206 | QAccessibleInterface *QAccessibleApplication::focusChild() const | - | ||||||||||||
| 207 | { | - | ||||||||||||
| 208 | if (QWindow *window = QGuiApplication::focusWindow())
| 0 | ||||||||||||
| 209 | return window->accessibleRoot(); never executed: return window->accessibleRoot(); | 0 | ||||||||||||
| 210 | return 0; never executed: return 0; | 0 | ||||||||||||
| 211 | } | - | ||||||||||||
| 212 | - | |||||||||||||
| 213 | /*! \reimp */ | - | ||||||||||||
| 214 | QString QAccessibleApplication::text(QAccessible::Text t) const | - | ||||||||||||
| 215 | { | - | ||||||||||||
| 216 | switch (t) { | - | ||||||||||||
| 217 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||
| 218 | return QGuiApplication::applicationName(); never executed: return QGuiApplication::applicationName(); | 0 | ||||||||||||
| 219 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||
| 220 | return QGuiApplication::applicationFilePath(); never executed: return QGuiApplication::applicationFilePath(); | 0 | ||||||||||||
| 221 | default: never executed: default: | 0 | ||||||||||||
| 222 | break; never executed: break; | 0 | ||||||||||||
| 223 | } | - | ||||||||||||
| 224 | return QString(); never executed: return QString(); | 0 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | /*! \reimp */ | - | ||||||||||||
| 228 | QAccessible::Role QAccessibleApplication::role() const | - | ||||||||||||
| 229 | { | - | ||||||||||||
| 230 | return QAccessible::Application; never executed: return QAccessible::Application; | 0 | ||||||||||||
| 231 | } | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | /*! \reimp */ | - | ||||||||||||
| 234 | QAccessible::State QAccessibleApplication::state() const | - | ||||||||||||
| 235 | { | - | ||||||||||||
| 236 | return QAccessible::State(); never executed: return QAccessible::State(); | 0 | ||||||||||||
| 237 | } | - | ||||||||||||
| 238 | - | |||||||||||||
| 239 | - | |||||||||||||
| 240 | QT_END_NAMESPACE | - | ||||||||||||
| 241 | - | |||||||||||||
| 242 | #endif //QT_NO_ACCESSIBILITY | - | ||||||||||||
| Source code | Switch to Preprocessed file |