accessible/qaccessibleobject.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qaccessibleobject.h" -
43 -
44#ifndef QT_NO_ACCESSIBILITY -
45 -
46#include <QtGui/QGuiApplication> -
47#include <QtGui/QWindow> -
48 -
49#include "qpointer.h" -
50#include "qmetaobject.h" -
51 -
52QT_BEGIN_NAMESPACE -
53 -
54class QAccessibleObjectPrivate -
55{ -
56public: -
57 QPointer<QObject> object; -
58 -
59 QList<QByteArray> actionList() const; -
60}; -
61 -
62QList<QByteArray> QAccessibleObjectPrivate::actionList() const -
63{ -
64 QList<QByteArray> actionList;
never executed (the execution status of this line is deduced): QList<QByteArray> actionList;
-
65 -
66 if (!object)
never evaluated: !object
0
67 return actionList;
never executed: return actionList;
0
68 -
69 const QMetaObject *mo = object->metaObject();
never executed (the execution status of this line is deduced): const QMetaObject *mo = object->metaObject();
-
70 Q_ASSERT(mo);
never executed (the execution status of this line is deduced): qt_noop();
-
71 -
72 QByteArray defaultAction = QMetaObject::normalizedSignature(
never executed (the execution status of this line is deduced): QByteArray defaultAction = QMetaObject::normalizedSignature(
-
73 mo->classInfo(mo->indexOfClassInfo("DefaultSlot")).value());
never executed (the execution status of this line is deduced): mo->classInfo(mo->indexOfClassInfo("DefaultSlot")).value());
-
74 -
75 for (int i = 0; i < mo->methodCount(); ++i) {
never evaluated: i < mo->methodCount()
0
76 const QMetaMethod member = mo->method(i);
never executed (the execution status of this line is deduced): const QMetaMethod member = mo->method(i);
-
77 if (member.methodType() != QMetaMethod::Slot && member.access() != QMetaMethod::Public)
never evaluated: member.methodType() != QMetaMethod::Slot
never evaluated: member.access() != QMetaMethod::Public
0
78 continue;
never executed: continue;
0
79 -
80 if (!qstrcmp(member.tag(), "QACCESSIBLE_SLOT")) {
never evaluated: !qstrcmp(member.tag(), "QACCESSIBLE_SLOT")
0
81 if (member.methodSignature() == defaultAction)
never evaluated: member.methodSignature() == defaultAction
0
82 actionList.prepend(defaultAction);
never executed: actionList.prepend(defaultAction);
0
83 else -
84 actionList << member.methodSignature();
never executed: actionList << member.methodSignature();
0
85 } -
86 }
never executed: }
0
87 -
88 return actionList;
never executed: return actionList;
0
89} -
90 -
91/*! -
92 \class QAccessibleObject -
93 \brief The QAccessibleObject class implements parts of the -
94 QAccessibleInterface for QObjects. -
95 \internal -
96 -
97 \ingroup accessibility -
98 \inmodule QtWidgets -
99 -
100 This class is part of \l {Accessibility for QWidget Applications}. -
101 -
102 This class is mainly provided for convenience. All subclasses of -
103 the QAccessibleInterface that provide implementations of non-widget objects -
104 should use this class as their base class. -
105 -
106 \sa QAccessible, QAccessibleWidget -
107*/ -
108 -
109/*! -
110 Creates a QAccessibleObject for \a object. -
111*/ -
112QAccessibleObject::QAccessibleObject(QObject *object) -
113{ -
114 d = new QAccessibleObjectPrivate;
executed (the execution status of this line is deduced): d = new QAccessibleObjectPrivate;
-
115 d->object = object;
executed (the execution status of this line is deduced): d->object = object;
-
116}
executed: }
Execution Count:306
306
117 -
118/*! -
119 Destroys the QAccessibleObject. -
120 -
121 This only happens when a call to release() decrements the internal -
122 reference counter to zero. -
123*/ -
124QAccessibleObject::~QAccessibleObject() -
125{ -
126 delete d;
executed (the execution status of this line is deduced): delete d;
-
127}
executed: }
Execution Count:252
252
128 -
129/*! -
130 \reimp -
131*/ -
132QObject *QAccessibleObject::object() const -
133{ -
134#ifndef QT_NO_DEBUG -
135 if (!d->object) -
136 qWarning("QAccessibleInterface is invalid. Crash pending..."); -
137#endif -
138 return d->object;
executed: return d->object;
Execution Count:2932
2932
139} -
140 -
141/*! -
142 \reimp -
143*/ -
144bool QAccessibleObject::isValid() const -
145{ -
146 return !d->object.isNull();
executed: return !d->object.isNull();
Execution Count:22
22
147} -
148 -
149/*! \reimp */ -
150QRect QAccessibleObject::rect() const -
151{ -
152 return QRect();
never executed: return QRect();
0
153} -
154 -
155/*! \reimp */ -
156void QAccessibleObject::setText(QAccessible::Text, const QString &) -
157{ -
158} -
159 -
160/*! \reimp */ -
161QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const -
162{ -
163 for (int i = 0; i < childCount(); ++i) {
evaluated: i < childCount()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
164 QAccessibleInterface *childIface = child(i);
executed (the execution status of this line is deduced): QAccessibleInterface *childIface = child(i);
-
165 Q_ASSERT(childIface);
executed (the execution status of this line is deduced): qt_noop();
-
166 if (childIface->rect().contains(x,y)) {
evaluated: childIface->rect().contains(x,y)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6
5-6
167 return childIface;
executed: return childIface;
Execution Count:5
5
168 } else { -
169 delete childIface;
executed (the execution status of this line is deduced): delete childIface;
-
170 }
executed: }
Execution Count:6
6
171 } -
172 return 0;
executed: return 0;
Execution Count:4
4
173} -
174 -
175/*! -
176 \class QAccessibleApplication -
177 \brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication. -
178 -
179 \internal -
180 -
181 \ingroup accessibility -
182*/ -
183 -
184/*! -
185 Creates a QAccessibleApplication for the QApplication object referenced by qApp. -
186*/ -
187QAccessibleApplication::QAccessibleApplication() -
188: QAccessibleObject(qApp) -
189{ -
190}
executed: }
Execution Count:2
2
191 -
192QWindow *QAccessibleApplication::window() const -
193{ -
194 // an application can have several windows, and AFAIK we don't need -
195 // to notify about changes on the application. -
196 return 0;
never executed: return 0;
0
197} -
198 -
199// all toplevel windows except popups and the desktop -
200static QObjectList topLevelObjects() -
201{ -
202 QObjectList list;
never executed (the execution status of this line is deduced): QObjectList list;
-
203 const QWindowList tlw(QGuiApplication::topLevelWindows());
never executed (the execution status of this line is deduced): const QWindowList tlw(QGuiApplication::topLevelWindows());
-
204 for (int i = 0; i < tlw.count(); ++i) {
never evaluated: i < tlw.count()
0
205 QWindow *w = tlw.at(i);
never executed (the execution status of this line is deduced): QWindow *w = tlw.at(i);
-
206 if (w->type() != Qt::Popup && w->type() != Qt::Desktop) {
never evaluated: w->type() != Qt::Popup
never evaluated: w->type() != Qt::Desktop
0
207 if (QAccessibleInterface *root = w->accessibleRoot()) {
never evaluated: QAccessibleInterface *root = w->accessibleRoot()
0
208 if (root->object())
never evaluated: root->object()
0
209 list.append(root->object());
never executed: list.append(root->object());
0
210 delete root;
never executed (the execution status of this line is deduced): delete root;
-
211 }
never executed: }
0
212 }
never executed: }
0
213 }
never executed: }
0
214 -
215 return list;
never executed: return list;
0
216} -
217 -
218/*! \reimp */ -
219int QAccessibleApplication::childCount() const -
220{ -
221 return topLevelObjects().count();
never executed: return topLevelObjects().count();
0
222} -
223 -
224/*! \reimp */ -
225int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const -
226{ -
227 const QObjectList tlw(topLevelObjects());
never executed (the execution status of this line is deduced): const QObjectList tlw(topLevelObjects());
-
228 return tlw.indexOf(child->object());
never executed: return tlw.indexOf(child->object());
0
229} -
230 -
231QAccessibleInterface *QAccessibleApplication::parent() const -
232{ -
233 return 0;
never executed: return 0;
0
234} -
235 -
236QAccessibleInterface *QAccessibleApplication::child(int index) const -
237{ -
238 const QObjectList tlo(topLevelObjects());
never executed (the execution status of this line is deduced): const QObjectList tlo(topLevelObjects());
-
239 if (index >= 0 && index < tlo.count())
never evaluated: index >= 0
never evaluated: index < tlo.count()
0
240 return QAccessible::queryAccessibleInterface(tlo.at(index));
never executed: return QAccessible::queryAccessibleInterface(tlo.at(index));
0
241 return 0;
never executed: return 0;
0
242} -
243 -
244 -
245/*! \reimp */ -
246QAccessibleInterface *QAccessibleApplication::focusChild() const -
247{ -
248 if (QWindow *window = QGuiApplication::focusWindow())
never evaluated: QWindow *window = QGuiApplication::focusWindow()
0
249 return window->accessibleRoot();
never executed: return window->accessibleRoot();
0
250 return 0;
never executed: return 0;
0
251} -
252 -
253/*! \reimp */ -
254QString QAccessibleApplication::text(QAccessible::Text t) const -
255{ -
256 switch (t) { -
257 case QAccessible::Name: -
258 return QGuiApplication::applicationName();
executed: return QGuiApplication::applicationName();
Execution Count:1
1
259 case QAccessible::Description: -
260 return QGuiApplication::applicationFilePath();
never executed: return QGuiApplication::applicationFilePath();
0
261 default: -
262 break;
never executed: break;
0
263 } -
264 return QString();
never executed: return QString();
0
265} -
266 -
267/*! \reimp */ -
268QAccessible::Role QAccessibleApplication::role() const -
269{ -
270 return QAccessible::Application;
executed: return QAccessible::Application;
Execution Count:2
2
271} -
272 -
273/*! \reimp */ -
274QAccessible::State QAccessibleApplication::state() const -
275{ -
276 return QAccessible::State();
executed: return QAccessible::State();
Execution Count:1
1
277} -
278 -
279 -
280QT_END_NAMESPACE -
281 -
282#endif //QT_NO_ACCESSIBILITY -
283 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial