| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickaccessibleattached_p.h |
| 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 QtQuick 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 | #ifndef QQUICKACCESSIBLEATTACHED_H | - | ||||||||||||||||||
| 41 | #define QQUICKACCESSIBLEATTACHED_H | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | // | - | ||||||||||||||||||
| 44 | // W A R N I N G | - | ||||||||||||||||||
| 45 | // ------------- | - | ||||||||||||||||||
| 46 | // | - | ||||||||||||||||||
| 47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||||||||
| 48 | // implementation detail. This header file may change from version to | - | ||||||||||||||||||
| 49 | // version without notice, or even be removed. | - | ||||||||||||||||||
| 50 | // | - | ||||||||||||||||||
| 51 | // We mean it. | - | ||||||||||||||||||
| 52 | // | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | #include <QtQuick/qquickitem.h> | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | #include <QtCore/qobject.h> | - | ||||||||||||||||||
| 57 | #include <QtCore/qstring.h> | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | #if QT_CONFIG(accessibility) | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | #include <QtGui/qaccessible.h> | - | ||||||||||||||||||
| 62 | #include <private/qtquickglobal_p.h> | - | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | #define STATE_PROPERTY(P) \ | - | ||||||||||||||||||
| 68 | Q_PROPERTY(bool P READ P WRITE set_ ## P NOTIFY P ## Changed FINAL) \ | - | ||||||||||||||||||
| 69 | bool P() const { return m_state.P ; } \ | - | ||||||||||||||||||
| 70 | void set_ ## P(bool arg) \ | - | ||||||||||||||||||
| 71 | { \ | - | ||||||||||||||||||
| 72 | if (m_state.P == arg) \ | - | ||||||||||||||||||
| 73 | return; \ | - | ||||||||||||||||||
| 74 | m_state.P = arg; \ | - | ||||||||||||||||||
| 75 | emit P ## Changed(arg); \ | - | ||||||||||||||||||
| 76 | QAccessible::State changedState; \ | - | ||||||||||||||||||
| 77 | changedState.P = true; \ | - | ||||||||||||||||||
| 78 | QAccessibleStateChangeEvent ev(parent(), changedState); \ | - | ||||||||||||||||||
| 79 | QAccessible::updateAccessibility(&ev); \ | - | ||||||||||||||||||
| 80 | } \ | - | ||||||||||||||||||
| 81 | Q_SIGNAL void P ## Changed(bool arg); | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject | - | ||||||||||||||||||
| 85 | { | - | ||||||||||||||||||
| 86 | Q_OBJECT | - | ||||||||||||||||||
| 87 | Q_PROPERTY(QAccessible::Role role READ role WRITE setRole NOTIFY roleChanged FINAL) | - | ||||||||||||||||||
| 88 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL) | - | ||||||||||||||||||
| 89 | Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged FINAL) | - | ||||||||||||||||||
| 90 | Q_PROPERTY(bool ignored READ ignored WRITE setIgnored NOTIFY ignoredChanged FINAL) | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | public: | - | ||||||||||||||||||
| 93 | Q_ENUMS(QAccessible::Role QAccessible::Event) | - | ||||||||||||||||||
| 94 | STATE_PROPERTY(checkable) never executed: return;executed 4 times by 1 test: end of blockExecuted by:
never executed: return m_state.checkable ;
| 0-4 | ||||||||||||||||||
| 95 | STATE_PROPERTY(checked) executed 4 times by 1 test: return;Executed by:
executed 8 times by 1 test: end of blockExecuted by:
never executed: return m_state.checked ;
| 0-8 | ||||||||||||||||||
| 96 | STATE_PROPERTY(editable) never executed: return;never executed: end of blocknever executed: return m_state.editable ;
| 0 | ||||||||||||||||||
| 97 | STATE_PROPERTY(focusable) never executed: return;never executed: end of blocknever executed: return m_state.focusable ;
| 0 | ||||||||||||||||||
| 98 | STATE_PROPERTY(focused) never executed: return;never executed: end of blocknever executed: return m_state.focused ;
| 0 | ||||||||||||||||||
| 99 | STATE_PROPERTY(multiLine) never executed: return;never executed: end of blocknever executed: return m_state.multiLine ;
| 0 | ||||||||||||||||||
| 100 | STATE_PROPERTY(readOnly) never executed: return;never executed: end of blocknever executed: return m_state.readOnly ;
| 0 | ||||||||||||||||||
| 101 | STATE_PROPERTY(selected) never executed: return;never executed: end of blocknever executed: return m_state.selected ;
| 0 | ||||||||||||||||||
| 102 | STATE_PROPERTY(selectable) never executed: return;never executed: end of blocknever executed: return m_state.selectable ;
| 0 | ||||||||||||||||||
| 103 | STATE_PROPERTY(pressed) never executed: return;never executed: end of blocknever executed: return m_state.pressed ;
| 0 | ||||||||||||||||||
| 104 | STATE_PROPERTY(checkStateMixed) never executed: return;never executed: end of blocknever executed: return m_state.checkStateMixed ;
| 0 | ||||||||||||||||||
| 105 | STATE_PROPERTY(defaultButton) never executed: return;never executed: end of blocknever executed: return m_state.defaultButton ;
| 0 | ||||||||||||||||||
| 106 | STATE_PROPERTY(passwordEdit) never executed: return;never executed: end of blocknever executed: return m_state.passwordEdit ;
| 0 | ||||||||||||||||||
| 107 | STATE_PROPERTY(selectableText) never executed: return;never executed: end of blocknever executed: return m_state.selectableText ;
| 0 | ||||||||||||||||||
| 108 | STATE_PROPERTY(searchEdit) never executed: return;never executed: end of blocknever executed: return m_state.searchEdit ;
| 0 | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QQuickAccessibleAttached(QObject *parent); | - | ||||||||||||||||||
| 111 | ~QQuickAccessibleAttached(); | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | QAccessible::Role role() const { return m_role; } executed 240 times by 1 test: return m_role;Executed by:
| 240 | ||||||||||||||||||
| 114 | void setRole(QAccessible::Role role) | - | ||||||||||||||||||
| 115 | { | - | ||||||||||||||||||
| 116 | if (role != m_role) {
| 0-78 | ||||||||||||||||||
| 117 | m_role = role; | - | ||||||||||||||||||
| 118 | Q_EMIT roleChanged(); | - | ||||||||||||||||||
| 119 | // There is no way to signify role changes at the moment. | - | ||||||||||||||||||
| 120 | // QAccessible::updateAccessibility(parent(), 0, QAccessible::); | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | switch (role) { | - | ||||||||||||||||||
| 123 | case QAccessible::CheckBox: executed 4 times by 1 test: case QAccessible::CheckBox:Executed by:
| 4 | ||||||||||||||||||
| 124 | case QAccessible::RadioButton: never executed: case QAccessible::RadioButton: | 0 | ||||||||||||||||||
| 125 | m_state.focusable = true; | - | ||||||||||||||||||
| 126 | m_state.checkable = true; | - | ||||||||||||||||||
| 127 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||
| 128 | case QAccessible::Button: executed 12 times by 1 test: case QAccessible::Button:Executed by:
| 12 | ||||||||||||||||||
| 129 | case QAccessible::MenuItem: never executed: case QAccessible::MenuItem: | 0 | ||||||||||||||||||
| 130 | case QAccessible::PageTab: never executed: case QAccessible::PageTab: | 0 | ||||||||||||||||||
| 131 | case QAccessible::EditableText: never executed: case QAccessible::EditableText: | 0 | ||||||||||||||||||
| 132 | case QAccessible::SpinBox: never executed: case QAccessible::SpinBox: | 0 | ||||||||||||||||||
| 133 | case QAccessible::ComboBox: never executed: case QAccessible::ComboBox: | 0 | ||||||||||||||||||
| 134 | case QAccessible::Terminal: never executed: case QAccessible::Terminal: | 0 | ||||||||||||||||||
| 135 | case QAccessible::ScrollBar: never executed: case QAccessible::ScrollBar: | 0 | ||||||||||||||||||
| 136 | m_state.focusable = true; | - | ||||||||||||||||||
| 137 | break; executed 12 times by 1 test: break;Executed by:
| 12 | ||||||||||||||||||
| 138 | default: executed 62 times by 2 tests: default:Executed by:
| 62 | ||||||||||||||||||
| 139 | break; executed 62 times by 2 tests: break;Executed by:
| 62 | ||||||||||||||||||
| 140 | } | - | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | } executed 78 times by 2 tests: end of blockExecuted by:
| 78 | ||||||||||||||||||
| 143 | QString name() const { | - | ||||||||||||||||||
| 144 | if (m_state.passwordEdit)
| 0-60 | ||||||||||||||||||
| 145 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
| 146 | return m_name; executed 60 times by 1 test: return m_name;Executed by:
| 60 | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | void setName(const QString &name) { | - | ||||||||||||||||||
| 149 | if (name != m_name) {
| 0-66 | ||||||||||||||||||
| 150 | m_name = name; | - | ||||||||||||||||||
| 151 | Q_EMIT nameChanged(); | - | ||||||||||||||||||
| 152 | QAccessibleEvent ev(parent(), QAccessible::NameChanged); | - | ||||||||||||||||||
| 153 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||
| 154 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||
| 155 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | QString description() const { return m_description; } executed 4 times by 1 test: return m_description;Executed by:
| 4 | ||||||||||||||||||
| 158 | void setDescription(const QString &description) | - | ||||||||||||||||||
| 159 | { | - | ||||||||||||||||||
| 160 | if (m_description != description) {
| 0-36 | ||||||||||||||||||
| 161 | m_description = description; | - | ||||||||||||||||||
| 162 | Q_EMIT descriptionChanged(); | - | ||||||||||||||||||
| 163 | QAccessibleEvent ev(parent(), QAccessible::DescriptionChanged); | - | ||||||||||||||||||
| 164 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||
| 165 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||
| 166 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | // Factory function | - | ||||||||||||||||||
| 169 | static QQuickAccessibleAttached *qmlAttachedProperties(QObject *obj); | - | ||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | static QQuickAccessibleAttached *attachedProperties(const QObject *obj) | - | ||||||||||||||||||
| 172 | { | - | ||||||||||||||||||
| 173 | return qobject_cast<QQuickAccessibleAttached*>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(obj, false)); executed 126 times by 1 test: return qobject_cast<QQuickAccessibleAttached*>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(obj, false));Executed by:
| 126 | ||||||||||||||||||
| 174 | } | - | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | // Property getter | - | ||||||||||||||||||
| 177 | static QVariant property(const QObject *object, const char *propertyName) | - | ||||||||||||||||||
| 178 | { | - | ||||||||||||||||||
| 179 | if (QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object))
| 0-34 | ||||||||||||||||||
| 180 | return attachedObject->property(propertyName); executed 34 times by 1 test: return attachedObject->property(propertyName);Executed by:
| 34 | ||||||||||||||||||
| 181 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||
| 182 | } | - | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | static bool setProperty(QObject *object, const char *propertyName, const QVariant &value) | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | QObject *obj = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(object, true); | - | ||||||||||||||||||
| 187 | if (!obj) {
| 0 | ||||||||||||||||||
| 188 | qWarning("cannot set property Accessible.%s of QObject %s", propertyName, object->metaObject()->className()); | - | ||||||||||||||||||
| 189 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | return obj->setProperty(propertyName, value); never executed: return obj->setProperty(propertyName, value); | 0 | ||||||||||||||||||
| 192 | } | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | static QObject *findAccessible(QObject *object, QAccessible::Role role = QAccessible::NoRole) | - | ||||||||||||||||||
| 195 | { | - | ||||||||||||||||||
| 196 | while (object) {
| 2-6 | ||||||||||||||||||
| 197 | QQuickAccessibleAttached *att = QQuickAccessibleAttached::attachedProperties(object); | - | ||||||||||||||||||
| 198 | if (att && (role == QAccessible::NoRole || att->role() == role)) {
| 0-4 | ||||||||||||||||||
| 199 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | object = object->parent(); | - | ||||||||||||||||||
| 202 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 203 | return object; executed 4 times by 1 test: return object;Executed by:
| 4 | ||||||||||||||||||
| 204 | } | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | QAccessible::State state() const { return m_state; } executed 80 times by 1 test: return m_state;Executed by:
| 80 | ||||||||||||||||||
| 207 | bool ignored() const; | - | ||||||||||||||||||
| 208 | bool doAction(const QString &actionName); | - | ||||||||||||||||||
| 209 | void availableActions(QStringList *actions) const; | - | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | public Q_SLOTS: | - | ||||||||||||||||||
| 212 | void valueChanged() { | - | ||||||||||||||||||
| 213 | QAccessibleValueChangeEvent ev(parent(), parent()->property("value")); | - | ||||||||||||||||||
| 214 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | void cursorPositionChanged() { | - | ||||||||||||||||||
| 217 | QAccessibleTextCursorEvent ev(parent(), parent()->property("cursorPosition").toInt()); | - | ||||||||||||||||||
| 218 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | void setIgnored(bool ignored); | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | Q_SIGNALS: | - | ||||||||||||||||||
| 224 | void roleChanged(); | - | ||||||||||||||||||
| 225 | void nameChanged(); | - | ||||||||||||||||||
| 226 | void descriptionChanged(); | - | ||||||||||||||||||
| 227 | void ignoredChanged(); | - | ||||||||||||||||||
| 228 | void pressAction(); | - | ||||||||||||||||||
| 229 | void toggleAction(); | - | ||||||||||||||||||
| 230 | void increaseAction(); | - | ||||||||||||||||||
| 231 | void decreaseAction(); | - | ||||||||||||||||||
| 232 | void scrollUpAction(); | - | ||||||||||||||||||
| 233 | void scrollDownAction(); | - | ||||||||||||||||||
| 234 | void scrollLeftAction(); | - | ||||||||||||||||||
| 235 | void scrollRightAction(); | - | ||||||||||||||||||
| 236 | void previousPageAction(); | - | ||||||||||||||||||
| 237 | void nextPageAction(); | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | private: | - | ||||||||||||||||||
| 240 | QQuickItem *item() const { return static_cast<QQuickItem*>(parent()); } executed 8 times by 1 test: return static_cast<QQuickItem*>(parent());Executed by:
| 8 | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | QAccessible::Role m_role; | - | ||||||||||||||||||
| 243 | QAccessible::State m_state; | - | ||||||||||||||||||
| 244 | QString m_name; | - | ||||||||||||||||||
| 245 | QString m_description; | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | static QMetaMethod sigPress; | - | ||||||||||||||||||
| 248 | static QMetaMethod sigToggle; | - | ||||||||||||||||||
| 249 | static QMetaMethod sigIncrease; | - | ||||||||||||||||||
| 250 | static QMetaMethod sigDecrease; | - | ||||||||||||||||||
| 251 | static QMetaMethod sigScrollUp; | - | ||||||||||||||||||
| 252 | static QMetaMethod sigScrollDown; | - | ||||||||||||||||||
| 253 | static QMetaMethod sigScrollLeft; | - | ||||||||||||||||||
| 254 | static QMetaMethod sigScrollRight; | - | ||||||||||||||||||
| 255 | static QMetaMethod sigPreviousPage; | - | ||||||||||||||||||
| 256 | static QMetaMethod sigNextPage; | - | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | public: | - | ||||||||||||||||||
| 259 | using QObject::property; | - | ||||||||||||||||||
| 260 | }; | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | QML_DECLARE_TYPE(QQuickAccessibleAttached) | - | ||||||||||||||||||
| 266 | QML_DECLARE_TYPEINFO(QQuickAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES) | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | #endif // accessibility | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | #endif | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |