OpenCoverage

qquickaccessibleattached_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickaccessibleattached_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
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-
64QT_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-
84class 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-
92public:-
93 Q_ENUMS(QAccessible::Role QAccessible::Event)-
94 STATE_PROPERTY(checkable)
never executed: return;
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
never executed: return m_state.checkable ;
m_state.checkable == argDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-4
95 STATE_PROPERTY(checked)
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickaccessible
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
never executed: return m_state.checked ;
m_state.checked == argDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-8
96 STATE_PROPERTY(editable)
never executed: return;
never executed: end of block
never executed: return m_state.editable ;
m_state.editable == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
97 STATE_PROPERTY(focusable)
never executed: return;
never executed: end of block
never executed: return m_state.focusable ;
m_state.focusable == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
98 STATE_PROPERTY(focused)
never executed: return;
never executed: end of block
never executed: return m_state.focused ;
m_state.focused == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
99 STATE_PROPERTY(multiLine)
never executed: return;
never executed: end of block
never executed: return m_state.multiLine ;
m_state.multiLine == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
100 STATE_PROPERTY(readOnly)
never executed: return;
never executed: end of block
never executed: return m_state.readOnly ;
m_state.readOnly == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
101 STATE_PROPERTY(selected)
never executed: return;
never executed: end of block
never executed: return m_state.selected ;
m_state.selected == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 STATE_PROPERTY(selectable)
never executed: return;
never executed: end of block
never executed: return m_state.selectable ;
m_state.selectable == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
103 STATE_PROPERTY(pressed)
never executed: return;
never executed: end of block
never executed: return m_state.pressed ;
m_state.pressed == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
104 STATE_PROPERTY(checkStateMixed)
never executed: return;
never executed: end of block
never executed: return m_state.checkStateMixed ;
m_state.checkStateMixed == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
105 STATE_PROPERTY(defaultButton)
never executed: return;
never executed: end of block
never executed: return m_state.defaultButton ;
m_state.defaultButton == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
106 STATE_PROPERTY(passwordEdit)
never executed: return;
never executed: end of block
never executed: return m_state.passwordEdit ;
m_state.passwordEdit == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 STATE_PROPERTY(selectableText)
never executed: return;
never executed: end of block
never executed: return m_state.selectableText ;
m_state.selectableText == argDescription
TRUEnever evaluated
FALSEnever evaluated
0
108 STATE_PROPERTY(searchEdit)
never executed: return;
never executed: end of block
never executed: return m_state.searchEdit ;
m_state.searchEdit == argDescription
TRUEnever evaluated
FALSEnever evaluated
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:
  • tst_qquickaccessible
240
114 void setRole(QAccessible::Role role)-
115 {-
116 if (role != m_role) {
role != m_roleDescription
TRUEevaluated 78 times by 2 tests
Evaluated by:
  • tst_qquickaccessible
  • tst_qquickitem2
FALSEnever evaluated
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:
  • tst_qquickaccessible
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:
  • tst_qquickaccessible
4
128 case QAccessible::Button:
executed 12 times by 1 test: case QAccessible::Button:
Executed by:
  • tst_qquickaccessible
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:
  • tst_qquickaccessible
12
138 default:
executed 62 times by 2 tests: default:
Executed by:
  • tst_qquickaccessible
  • tst_qquickitem2
62
139 break;
executed 62 times by 2 tests: break;
Executed by:
  • tst_qquickaccessible
  • tst_qquickitem2
62
140 }-
141 }-
142 }
executed 78 times by 2 tests: end of block
Executed by:
  • tst_qquickaccessible
  • tst_qquickitem2
78
143 QString name() const {-
144 if (m_state.passwordEdit)
m_state.passwordEditDescription
TRUEnever evaluated
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qquickaccessible
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:
  • tst_qquickaccessible
60
147 }-
148 void setName(const QString &name) {-
149 if (name != m_name) {
name != m_nameDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickaccessible
66
155 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
66
156-
157 QString description() const { return m_description; }
executed 4 times by 1 test: return m_description;
Executed by:
  • tst_qquickaccessible
4
158 void setDescription(const QString &description)-
159 {-
160 if (m_description != description) {
m_description != descriptionDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
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 block
Executed by:
  • tst_qquickaccessible
36
166 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
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:
  • tst_qquickaccessible
126
174 }-
175-
176 // Property getter-
177 static QVariant property(const QObject *object, const char *propertyName)-
178 {-
179 if (QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object))
QObject *attac...erties(object)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
0-34
180 return attachedObject->property(propertyName);
executed 34 times by 1 test: return attachedObject->property(propertyName);
Executed by:
  • tst_qquickaccessible
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) {
!objDescription
TRUEnever evaluated
FALSEnever evaluated
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) {
objectDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickaccessible
2-6
197 QQuickAccessibleAttached *att = QQuickAccessibleAttached::attachedProperties(object);-
198 if (att && (role == QAccessible::NoRole || att->role() == role)) {
attDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
role == QAccessible::NoRoleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
att->role() == roleDescription
TRUEnever evaluated
FALSEnever evaluated
0-4
199 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_qquickaccessible
2
200 }-
201 object = object->parent();-
202 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
4
203 return object;
executed 4 times by 1 test: return object;
Executed by:
  • tst_qquickaccessible
4
204 }-
205-
206 QAccessible::State state() const { return m_state; }
executed 80 times by 1 test: return m_state;
Executed by:
  • tst_qquickaccessible
80
207 bool ignored() const;-
208 bool doAction(const QString &actionName);-
209 void availableActions(QStringList *actions) const;-
210-
211public 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-
223Q_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-
239private:-
240 QQuickItem *item() const { return static_cast<QQuickItem*>(parent()); }
executed 8 times by 1 test: return static_cast<QQuickItem*>(parent());
Executed by:
  • tst_qquickaccessible
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-
258public:-
259 using QObject::property;-
260};-
261-
262-
263QT_END_NAMESPACE-
264-
265QML_DECLARE_TYPE(QQuickAccessibleAttached)-
266QML_DECLARE_TYPEINFO(QQuickAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES)-
267-
268#endif // accessibility-
269-
270#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0