OpenCoverage

qaccessiblequickitem.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
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#include "qaccessiblequickitem_p.h"-
41-
42#include <QtGui/qtextdocument.h>-
43-
44#include "QtQuick/private/qquickitem_p.h"-
45#include "QtQuick/private/qquicktext_p.h"-
46#include "QtQuick/private/qquickaccessibleattached_p.h"-
47#include "QtQuick/qquicktextdocument.h"-
48QT_BEGIN_NAMESPACE-
49-
50#if QT_CONFIG(accessibility)-
51-
52QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)-
53 : QAccessibleObject(item), m_doc(textDocument())-
54{-
55}
executed 84 times by 2 tests: end of block
Executed by:
  • tst_qquickaccessible
  • tst_qquickitem2
84
56-
57QWindow *QAccessibleQuickItem::window() const-
58{-
59 return item()->window();
never executed: return item()->window();
0
60}-
61-
62int QAccessibleQuickItem::childCount() const-
63{-
64 return childItems().count();
executed 28 times by 1 test: return childItems().count();
Executed by:
  • tst_qquickaccessible
28
65}-
66-
67QRect QAccessibleQuickItem::rect() const-
68{-
69 const QRect r = itemScreenRect(item());-
70 return r;
executed 164 times by 1 test: return r;
Executed by:
  • tst_qquickaccessible
164
71}-
72-
73QRect QAccessibleQuickItem::viewRect() const-
74{-
75 // ### no window in some cases.-
76 if (!item()->window()) {
!item()->window()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-80
77 return QRect();
never executed: return QRect();
0
78 }-
79-
80 QQuickWindow *window = item()->window();-
81 QPoint screenPos = window->mapToGlobal(QPoint(0,0));-
82 return QRect(screenPos, window->size());
executed 80 times by 1 test: return QRect(screenPos, window->size());
Executed by:
  • tst_qquickaccessible
80
83}-
84-
85-
86bool QAccessibleQuickItem::clipsChildren() const-
87{-
88 return static_cast<QQuickItem *>(item())->clip();
never executed: return static_cast<QQuickItem *>(item())->clip();
0
89}-
90-
91QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const-
92{-
93 if (item()->clip()) {
item()->clip()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickaccessible
8-52
94 if (!rect().contains(x, y))
!rect().contains(x, y)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickaccessible
2-6
95 return nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickaccessible
2
96 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
6
97-
98 const QList<QQuickItem*> kids = accessibleUnignoredChildren(item(), true);-
99 for (int i = kids.count() - 1; i >= 0; --i) {
i >= 0Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_qquickaccessible
46-48
100 QAccessibleInterface *childIface = QAccessible::queryAccessibleInterface(kids.at(i));-
101 if (QAccessibleInterface *childChild = childIface->childAt(x, y))
QAccessibleInt...>childAt(x, y)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickaccessible
4-44
102 return childChild;
executed 4 times by 1 test: return childChild;
Executed by:
  • tst_qquickaccessible
4
103 if (childIface && !childIface->state().invisible) {
childIfaceDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
!childIface->state().invisibleDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
0-44
104 if (childIface->rect().contains(x, y))
childIface->re...contains(x, y)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_qquickaccessible
8-36
105 return childIface;
executed 8 times by 1 test: return childIface;
Executed by:
  • tst_qquickaccessible
8
106 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
36
107 }
executed 36 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
36
108-
109 return nullptr;
executed 46 times by 1 test: return nullptr;
Executed by:
  • tst_qquickaccessible
46
110}-
111-
112QAccessibleInterface *QAccessibleQuickItem::parent() const-
113{-
114 QQuickItem *parent = item()->parentItem();-
115 QQuickWindow *window = item()->window();-
116 QQuickItem *ci = window ? window->contentItem() : nullptr;
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
117 while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
!QQuickItemPri...->isAccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
parent != ciDescription
TRUEnever evaluated
FALSEnever evaluated
0
118 parent = parent->parentItem();
never executed: parent = parent->parentItem();
0
119-
120 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
121 if (parent == ci) {
parent == ciDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 // Jump out to the scene widget if the parent is the root item.-
123 // There are two root items, QQuickWindow::rootItem and-
124 // QQuickView::declarativeRoot. The former is the true root item,-
125 // but is not a part of the accessibility tree. Check if we hit-
126 // it here and return an interface for the scene instead.-
127 return QAccessible::queryAccessibleInterface(window);
never executed: return QAccessible::queryAccessibleInterface(window);
0
128 } else {-
129 while (parent && !parent->d_func()->isAccessible)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->d_fun...->isAccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
130 parent = parent->parentItem();
never executed: parent = parent->parentItem();
0
131 return QAccessible::queryAccessibleInterface(parent);
never executed: return QAccessible::queryAccessibleInterface(parent);
0
132 }-
133 }-
134 return nullptr;
never executed: return nullptr;
0
135}-
136-
137QAccessibleInterface *QAccessibleQuickItem::child(int index) const-
138{-
139 QList<QQuickItem *> children = childItems();-
140-
141 if (index < 0 || index >= children.count())
index < 0Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickaccessible
index >= children.count()Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-34
142 return nullptr;
never executed: return nullptr;
0
143-
144 QQuickItem *child = children.at(index);-
145 return QAccessible::queryAccessibleInterface(child);
executed 34 times by 1 test: return QAccessible::queryAccessibleInterface(child);
Executed by:
  • tst_qquickaccessible
34
146}-
147-
148int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const-
149{-
150 QList<QQuickItem*> kids = childItems();-
151 return kids.indexOf(static_cast<QQuickItem*>(iface->object()));
executed 6 times by 1 test: return kids.indexOf(static_cast<QQuickItem*>(iface->object()));
Executed by:
  • tst_qquickaccessible
6
152}-
153-
154static void unignoredChildren(QQuickItem *item, QList<QQuickItem *> *items, bool paintOrder)-
155{-
156 const QList<QQuickItem*> childItems = paintOrder ? QQuickItemPrivate::get(item)->paintOrderChildItems()
paintOrderDescription
TRUEevaluated 140 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 214 times by 1 test
Evaluated by:
  • tst_qquickaccessible
140-214
157 : item->childItems();-
158 for (QQuickItem *child : childItems) {-
159 if (QQuickItemPrivate::get(child)->isAccessible) {
QQuickItemPriv...->isAccessibleDescription
TRUEevaluated 356 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 206 times by 1 test
Evaluated by:
  • tst_qquickaccessible
206-356
160 items->append(child);-
161 } else {
executed 356 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
356
162 unignoredChildren(child, items, paintOrder);-
163 }
executed 206 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
206
164 }-
165}
executed 354 times by 1 test: end of block
Executed by:
  • tst_qquickaccessible
354
166-
167QList<QQuickItem *> accessibleUnignoredChildren(QQuickItem *item, bool paintOrder)-
168{-
169 QList<QQuickItem *> items;-
170 unignoredChildren(item, &items, paintOrder);-
171 return items;
executed 148 times by 1 test: return items;
Executed by:
  • tst_qquickaccessible
148
172}-
173-
174QList<QQuickItem *> QAccessibleQuickItem::childItems() const-
175{-
176 return accessibleUnignoredChildren(item());
executed 68 times by 1 test: return accessibleUnignoredChildren(item());
Executed by:
  • tst_qquickaccessible
68
177}-
178-
179QAccessible::State QAccessibleQuickItem::state() const-
180{-
181 QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item());-
182 if (!attached)
!attachedDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-80
183 return QAccessible::State();
never executed: return QAccessible::State();
0
184-
185 QAccessible::State state = attached->state();-
186-
187 QRect viewRect_ = viewRect();-
188 QRect itemRect = rect();-
189-
190 if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
viewRect_.isNull()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
itemRect.isNull()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
!item()->window()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
!item()->window()->isVisible()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
!item()->isVisible()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
qFuzzyIsNull(i...()->opacity())Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-80
191 state.invisible = true;
never executed: state.invisible = true;
0
192 if (!viewRect_.intersects(itemRect))
!viewRect_.int...ects(itemRect)Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-80
193 state.offscreen = true;
never executed: state.offscreen = true;
0
194 if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool())
role() == QAcc...ible::CheckBoxDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquickaccessible
role() == QAcc...e::RadioButtonDescription
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qquickaccessible
object()->prop...ked").toBool()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-68
195 state.checked = true;
executed 6 times by 1 test: state.checked = true;
Executed by:
  • tst_qquickaccessible
6
196 if (item()->activeFocusOnTab() || role() == QAccessible::EditableText)
item()->activeFocusOnTab()Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
role() == QAcc...::EditableTextDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-80
197 state.focusable = true;
never executed: state.focusable = true;
0
198 if (item()->hasActiveFocus())
item()->hasActiveFocus()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_qquickaccessible
4-76
199 state.focused = true;
executed 4 times by 1 test: state.focused = true;
Executed by:
  • tst_qquickaccessible
4
200 return state;
executed 80 times by 1 test: return state;
Executed by:
  • tst_qquickaccessible
80
201}-
202-
203QAccessible::Role QAccessibleQuickItem::role() const-
204{-
205 // Workaround for setAccessibleRole() not working for-
206 // Text items. Text items are special since they are defined-
207 // entirely from C++ (setting the role from QML works.)-
208 if (qobject_cast<QQuickText*>(const_cast<QQuickItem *>(item())))
qobject_cast<Q...em *>(item()))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_qquickaccessible
4-236
209 return QAccessible::StaticText;
executed 4 times by 1 test: return QAccessible::StaticText;
Executed by:
  • tst_qquickaccessible
4
210-
211 QAccessible::Role role = QAccessible::NoRole;-
212 if (item())
item()Description
TRUEevaluated 236 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
0-236
213 role = QQuickItemPrivate::get(item())->accessibleRole();
executed 236 times by 1 test: role = QQuickItemPrivate::get(item())->accessibleRole();
Executed by:
  • tst_qquickaccessible
236
214 if (role == QAccessible::NoRole)
role == QAccessible::NoRoleDescription
TRUEnever evaluated
FALSEevaluated 236 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-236
215 role = QAccessible::Client;
never executed: role = QAccessible::Client;
0
216-
217 return role;
executed 236 times by 1 test: return role;
Executed by:
  • tst_qquickaccessible
236
218}-
219-
220bool QAccessibleQuickItem::isAccessible() const-
221{-
222 return item()->d_func()->isAccessible;
never executed: return item()->d_func()->isAccessible;
0
223}-
224-
225QStringList QAccessibleQuickItem::actionNames() const-
226{-
227 QStringList actions;-
228 switch (role()) {-
229 case QAccessible::PushButton:
never executed: case QAccessible::PushButton:
0
230 actions << QAccessibleActionInterface::pressAction();-
231 break;
never executed: break;
0
232 case QAccessible::RadioButton:
never executed: case QAccessible::RadioButton:
0
233 case QAccessible::CheckBox:
never executed: case QAccessible::CheckBox:
0
234 actions << QAccessibleActionInterface::toggleAction()-
235 << QAccessibleActionInterface::pressAction();-
236 break;
never executed: break;
0
237 case QAccessible::Slider:
never executed: case QAccessible::Slider:
0
238 case QAccessible::SpinBox:
never executed: case QAccessible::SpinBox:
0
239 case QAccessible::ScrollBar:
never executed: case QAccessible::ScrollBar:
0
240 actions << QAccessibleActionInterface::increaseAction()-
241 << QAccessibleActionInterface::decreaseAction();-
242 break;
never executed: break;
0
243 default:
never executed: default:
0
244 break;
never executed: break;
0
245 }-
246 if (state().focusable)
state().focusableDescription
TRUEnever evaluated
FALSEnever evaluated
0
247 actions.append(QAccessibleActionInterface::setFocusAction());
never executed: actions.append(QAccessibleActionInterface::setFocusAction());
0
248-
249 // ### The following can lead to duplicate action names.-
250 if (QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item()))
QQuickAccessib...erties(item())Description
TRUEnever evaluated
FALSEnever evaluated
0
251 attached->availableActions(&actions);
never executed: attached->availableActions(&actions);
0
252 return actions;
never executed: return actions;
0
253}-
254-
255void QAccessibleQuickItem::doAction(const QString &actionName)-
256{-
257 bool accepted = false;-
258 if (actionName == QAccessibleActionInterface::setFocusAction()) {
actionName == ...tFocusAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
259 item()->forceActiveFocus();-
260 accepted = true;-
261 }
never executed: end of block
0
262 if (QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item()))
QQuickAccessib...erties(item())Description
TRUEnever evaluated
FALSEnever evaluated
0
263 accepted = attached->doAction(actionName);
never executed: accepted = attached->doAction(actionName);
0
264-
265 if (accepted)
acceptedDescription
TRUEnever evaluated
FALSEnever evaluated
0
266 return;
never executed: return;
0
267 // Look for and call the accessible[actionName]Action() function on the item.-
268 // This allows for overriding the default action handling.-
269 const QByteArray functionName = "accessible" + actionName.toLatin1() + "Action";-
270 if (object()->metaObject()->indexOfMethod(QByteArray(functionName + "()")) != -1) {
object()->meta...+ "()")) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
271 QMetaObject::invokeMethod(object(), functionName);-
272 return;
never executed: return;
0
273 }-
274-
275 // Role-specific default action handling follows. Items are expected to provide-
276 // properties according to role conventions. These will then be read and/or updated-
277 // by the accessibility system.-
278 // Checkable roles : checked-
279 // Value-based roles : (via the value interface: value, minimumValue, maximumValue), stepSize-
280 switch (role()) {-
281 case QAccessible::RadioButton:
never executed: case QAccessible::RadioButton:
0
282 case QAccessible::CheckBox: {
never executed: case QAccessible::CheckBox:
0
283 QVariant checked = object()->property("checked");-
284 if (checked.isValid()) {
checked.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
285 if (actionName == QAccessibleActionInterface::toggleAction() ||
actionName == ...toggleAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
286 actionName == QAccessibleActionInterface::pressAction()) {
actionName == ...:pressAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
287-
288 object()->setProperty("checked", QVariant(!checked.toBool()));-
289 }
never executed: end of block
0
290 }
never executed: end of block
0
291 break;
never executed: break;
0
292 }-
293 case QAccessible::Slider:
never executed: case QAccessible::Slider:
0
294 case QAccessible::SpinBox:
never executed: case QAccessible::SpinBox:
0
295 case QAccessible::Dial:
never executed: case QAccessible::Dial:
0
296 case QAccessible::ScrollBar: {
never executed: case QAccessible::ScrollBar:
0
297 if (actionName != QAccessibleActionInterface::increaseAction() &&
actionName != ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
298 actionName != QAccessibleActionInterface::decreaseAction())
actionName != ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
299 break;
never executed: break;
0
300-
301 // Update the value using QAccessibleValueInterface, respecting-
302 // the minimum and maximum value (if set). Also check for and-
303 // use the "stepSize" property on the item-
304 if (QAccessibleValueInterface *valueIface = valueInterface()) {
QAccessibleVal...lueInterface()Description
TRUEnever evaluated
FALSEnever evaluated
0
305 QVariant valueV = valueIface->currentValue();-
306 qreal newValue = valueV.toReal();-
307-
308 QVariant stepSizeV = object()->property("stepSize");-
309 qreal stepSize = stepSizeV.isValid() ? stepSizeV.toReal() : qreal(1.0);
stepSizeV.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
310 if (actionName == QAccessibleActionInterface::increaseAction()) {
actionName == ...creaseAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
311 newValue += stepSize;-
312 } else {
never executed: end of block
0
313 newValue -= stepSize;-
314 }
never executed: end of block
0
315-
316 QVariant minimumValueV = valueIface->minimumValue();-
317 if (minimumValueV.isValid()) {
minimumValueV.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
318 newValue = qMax(newValue, minimumValueV.toReal());-
319 }
never executed: end of block
0
320 QVariant maximumValueV = valueIface->maximumValue();-
321 if (maximumValueV.isValid()) {
maximumValueV.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
322 newValue = qMin(newValue, maximumValueV.toReal());-
323 }
never executed: end of block
0
324-
325 valueIface->setCurrentValue(QVariant(newValue));-
326 }
never executed: end of block
0
327 break;
never executed: break;
0
328 }-
329 default:
never executed: default:
0
330 break;
never executed: break;
0
331 }-
332}-
333-
334QStringList QAccessibleQuickItem::keyBindingsForAction(const QString &actionName) const-
335{-
336 Q_UNUSED(actionName)-
337 return QStringList();
never executed: return QStringList();
0
338}-
339-
340QString QAccessibleQuickItem::text(QAccessible::Text textType) const-
341{-
342 // handles generic behavior not specific to an item-
343 switch (textType) {-
344 case QAccessible::Name: {
executed 34 times by 1 test: case QAccessible::Name:
Executed by:
  • tst_qquickaccessible
34
345 QVariant accessibleName = QQuickAccessibleAttached::property(object(), "name");-
346 if (!accessibleName.isNull())
!accessibleName.isNull()Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickaccessible
FALSEnever evaluated
0-34
347 return accessibleName.toString();
executed 34 times by 1 test: return accessibleName.toString();
Executed by:
  • tst_qquickaccessible
34
348 break;}
never executed: break;
0
349 case QAccessible::Description: {
never executed: case QAccessible::Description:
0
350 QVariant accessibleDecription = QQuickAccessibleAttached::property(object(), "description");-
351 if (!accessibleDecription.isNull())
!accessibleDecription.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
352 return accessibleDecription.toString();
never executed: return accessibleDecription.toString();
0
353 break;}
never executed: break;
0
354#ifdef Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION-
355 case QAccessible::DebugDescription: {-
356 QString debugString;-
357 debugString = QString::fromLatin1(object()->metaObject()->className()) + QLatin1Char(' ');-
358 debugString += isAccessible() ? QLatin1String("enabled") : QLatin1String("disabled");-
359 return debugString;-
360 break; }-
361#endif-
362 case QAccessible::Value:
never executed: case QAccessible::Value:
0
363 case QAccessible::Help:
never executed: case QAccessible::Help:
0
364 case QAccessible::Accelerator:
never executed: case QAccessible::Accelerator:
0
365 default:
never executed: default:
0
366 break;
never executed: break;
0
367 }-
368-
369 // the following block handles item-specific behavior-
370 if (role() == QAccessible::EditableText) {
role() == QAcc...::EditableTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
371 if (textType == QAccessible::Value) {
textType == QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
372 if (QTextDocument *doc = textDocument()) {
QTextDocument ...textDocument()Description
TRUEnever evaluated
FALSEnever evaluated
0
373 return doc->toPlainText();
never executed: return doc->toPlainText();
0
374 }-
375 QVariant text = object()->property("text");-
376 return text.toString();
never executed: return text.toString();
0
377 }-
378 }
never executed: end of block
0
379-
380 return QString();
never executed: return QString();
0
381}-
382-
383void *QAccessibleQuickItem::interface_cast(QAccessible::InterfaceType t)-
384{-
385 QAccessible::Role r = role();-
386 if (t == QAccessible::ActionInterface)
t == QAccessib...ctionInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 return static_cast<QAccessibleActionInterface*>(this);
never executed: return static_cast<QAccessibleActionInterface*>(this);
0
388 if (t == QAccessible::ValueInterface &&
t == QAccessib...ValueInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
389 (r == QAccessible::Slider ||
r == QAccessible::SliderDescription
TRUEnever evaluated
FALSEnever evaluated
0
390 r == QAccessible::SpinBox ||
r == QAccessible::SpinBoxDescription
TRUEnever evaluated
FALSEnever evaluated
0
391 r == QAccessible::Dial ||
r == QAccessible::DialDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 r == QAccessible::ScrollBar))
r == QAccessible::ScrollBarDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 return static_cast<QAccessibleValueInterface*>(this);
never executed: return static_cast<QAccessibleValueInterface*>(this);
0
394-
395 if (t == QAccessible::TextInterface &&
t == QAccessib...:TextInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
396 (r == QAccessible::EditableText))
(r == QAccessi...:EditableText)Description
TRUEnever evaluated
FALSEnever evaluated
0
397 return static_cast<QAccessibleTextInterface*>(this);
never executed: return static_cast<QAccessibleTextInterface*>(this);
0
398-
399 return QAccessibleObject::interface_cast(t);
never executed: return QAccessibleObject::interface_cast(t);
0
400}-
401-
402QVariant QAccessibleQuickItem::currentValue() const-
403{-
404 return item()->property("value");
never executed: return item()->property("value");
0
405}-
406-
407void QAccessibleQuickItem::setCurrentValue(const QVariant &value)-
408{-
409 item()->setProperty("value", value);-
410}
never executed: end of block
0
411-
412QVariant QAccessibleQuickItem::maximumValue() const-
413{-
414 return item()->property("maximumValue");
never executed: return item()->property("maximumValue");
0
415}-
416-
417QVariant QAccessibleQuickItem::minimumValue() const-
418{-
419 return item()->property("minimumValue");
never executed: return item()->property("minimumValue");
0
420}-
421-
422QVariant QAccessibleQuickItem::minimumStepSize() const-
423{-
424 return item()->property("stepSize");
never executed: return item()->property("stepSize");
0
425}-
426-
427/*!-
428 \internal-
429 Shared between QAccessibleQuickItem and QAccessibleQuickView-
430*/-
431QRect itemScreenRect(QQuickItem *item)-
432{-
433 // ### no window in some cases.-
434 // ### Should we really check for 0 opacity?-
435 if (!item->window() ||!item->isVisible() || qFuzzyIsNull(item->opacity())) {
!item->window()Description
TRUEnever evaluated
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquickaccessible
!item->isVisible()Description
TRUEnever evaluated
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquickaccessible
qFuzzyIsNull(item->opacity())Description
TRUEnever evaluated
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-164
436 return QRect();
never executed: return QRect();
0
437 }-
438-
439 QSize itemSize((int)item->width(), (int)item->height());-
440 // ### If the bounding rect fails, we first try the implicit size, then we go for the-
441 // parent size. WE MIGHT HAVE TO REVISIT THESE FALLBACKS.-
442 if (itemSize.isEmpty()) {
itemSize.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 164 times by 1 test
Evaluated by:
  • tst_qquickaccessible
0-164
443 itemSize = QSize((int)item->implicitWidth(), (int)item->implicitHeight());-
444 if (itemSize.isEmpty() && item->parentItem())
itemSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
item->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
445 // ### Seems that the above fallback is not enough, fallback to use the parent size...-
446 itemSize = QSize((int)item->parentItem()->width(), (int)item->parentItem()->height());
never executed: itemSize = QSize((int)item->parentItem()->width(), (int)item->parentItem()->height());
0
447 }
never executed: end of block
0
448-
449 QPointF scenePoint = item->mapToScene(QPointF(0, 0));-
450 QPoint screenPos = item->window()->mapToGlobal(scenePoint.toPoint());-
451 return QRect(screenPos, itemSize);
executed 164 times by 1 test: return QRect(screenPos, itemSize);
Executed by:
  • tst_qquickaccessible
164
452}-
453-
454QTextDocument *QAccessibleQuickItem::textDocument() const-
455{-
456 QVariant docVariant = item()->property("textDocument");-
457 if (docVariant.canConvert<QQuickTextDocument*>()) {
docVariant.can...xtDocument*>()Description
TRUEnever evaluated
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • tst_qquickaccessible
  • tst_qquickitem2
0-84
458 QQuickTextDocument *qqdoc = docVariant.value<QQuickTextDocument*>();-
459 return qqdoc->textDocument();
never executed: return qqdoc->textDocument();
0
460 }-
461 return nullptr;
executed 84 times by 2 tests: return nullptr;
Executed by:
  • tst_qquickaccessible
  • tst_qquickitem2
84
462}-
463-
464int QAccessibleQuickItem::characterCount() const-
465{-
466 if (m_doc) {
m_docDescription
TRUEnever evaluated
FALSEnever evaluated
0
467 QTextCursor cursor = QTextCursor(m_doc);-
468 cursor.movePosition(QTextCursor::End);-
469 return cursor.position();
never executed: return cursor.position();
0
470 }-
471 return text(QAccessible::Value).size();
never executed: return text(QAccessible::Value).size();
0
472}-
473-
474int QAccessibleQuickItem::cursorPosition() const-
475{-
476 QVariant pos = item()->property("cursorPosition");-
477 return pos.toInt();
never executed: return pos.toInt();
0
478}-
479-
480void QAccessibleQuickItem::setCursorPosition(int position)-
481{-
482 item()->setProperty("cursorPosition", position);-
483}
never executed: end of block
0
484-
485QString QAccessibleQuickItem::text(int startOffset, int endOffset) const-
486{-
487 if (m_doc) {
m_docDescription
TRUEnever evaluated
FALSEnever evaluated
0
488 QTextCursor cursor = QTextCursor(m_doc);-
489 cursor.setPosition(startOffset);-
490 cursor.setPosition(endOffset, QTextCursor::KeepAnchor);-
491 return cursor.selectedText();
never executed: return cursor.selectedText();
0
492 }-
493 return text(QAccessible::Value).mid(startOffset, endOffset - startOffset);
never executed: return text(QAccessible::Value).mid(startOffset, endOffset - startOffset);
0
494}-
495-
496QString QAccessibleQuickItem::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
497 int *startOffset, int *endOffset) const-
498{-
499 Q_ASSERT(startOffset);-
500 Q_ASSERT(endOffset);-
501-
502 if (m_doc) {
m_docDescription
TRUEnever evaluated
FALSEnever evaluated
0
503 QTextCursor cursor = QTextCursor(m_doc);-
504 cursor.setPosition(offset);-
505 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);-
506 cursor.setPosition(boundaries.first - 1);-
507 boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);-
508-
509 *startOffset = boundaries.first;-
510 *endOffset = boundaries.second;-
511-
512 return text(boundaries.first, boundaries.second);
never executed: return text(boundaries.first, boundaries.second);
0
513 } else {-
514 return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset);
0
515 }-
516}-
517-
518QString QAccessibleQuickItem::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
519 int *startOffset, int *endOffset) const-
520{-
521 Q_ASSERT(startOffset);-
522 Q_ASSERT(endOffset);-
523-
524 if (m_doc) {
m_docDescription
TRUEnever evaluated
FALSEnever evaluated
0
525 QTextCursor cursor = QTextCursor(m_doc);-
526 cursor.setPosition(offset);-
527 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);-
528 cursor.setPosition(boundaries.second);-
529 boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);-
530-
531 *startOffset = boundaries.first;-
532 *endOffset = boundaries.second;-
533-
534 return text(boundaries.first, boundaries.second);
never executed: return text(boundaries.first, boundaries.second);
0
535 } else {-
536 return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset);
0
537 }-
538}-
539-
540QString QAccessibleQuickItem::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
541 int *startOffset, int *endOffset) const-
542{-
543 Q_ASSERT(startOffset);-
544 Q_ASSERT(endOffset);-
545-
546 if (m_doc) {
m_docDescription
TRUEnever evaluated
FALSEnever evaluated
0
547 QTextCursor cursor = QTextCursor(m_doc);-
548 cursor.setPosition(offset);-
549 QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);-
550-
551 *startOffset = boundaries.first;-
552 *endOffset = boundaries.second;-
553 return text(boundaries.first, boundaries.second);
never executed: return text(boundaries.first, boundaries.second);
0
554 } else {-
555 return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
0
556 }-
557}-
558-
559void QAccessibleQuickItem::selection(int selectionIndex, int *startOffset, int *endOffset) const-
560{-
561 if (selectionIndex == 0) {
selectionIndex == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
562 *startOffset = item()->property("selectionStart").toInt();-
563 *endOffset = item()->property("selectionEnd").toInt();-
564 } else {
never executed: end of block
0
565 *startOffset = 0;-
566 *endOffset = 0;-
567 }
never executed: end of block
0
568}-
569-
570int QAccessibleQuickItem::selectionCount() const-
571{-
572 if (item()->property("selectionStart").toInt() != item()->property("selectionEnd").toInt())
item()->proper...nEnd").toInt()Description
TRUEnever evaluated
FALSEnever evaluated
0
573 return 1;
never executed: return 1;
0
574 return 0;
never executed: return 0;
0
575}-
576-
577void QAccessibleQuickItem::addSelection(int /* startOffset */, int /* endOffset */)-
578{-
579-
580}-
581void QAccessibleQuickItem::removeSelection(int /* selectionIndex */)-
582{-
583-
584}-
585void QAccessibleQuickItem::setSelection(int /* selectionIndex */, int /* startOffset */, int /* endOffset */)-
586{-
587-
588}-
589-
590-
591#endif // accessibility-
592-
593QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0