OpenCoverage

simplewidgets.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/simplewidgets.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 plugins 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 "simplewidgets_p.h"-
41-
42#include <qabstractbutton.h>-
43#include <qcheckbox.h>-
44#include <qpushbutton.h>-
45#include <qprogressbar.h>-
46#include <qstatusbar.h>-
47#include <qradiobutton.h>-
48#include <qtoolbutton.h>-
49#include <qmenu.h>-
50#include <qlabel.h>-
51#include <qgroupbox.h>-
52#include <qlcdnumber.h>-
53#include <qlineedit.h>-
54#include <private/qlineedit_p.h>-
55#include <qstyle.h>-
56#include <qstyleoption.h>-
57#include <qtextdocument.h>-
58#include <qwindow.h>-
59#include <private/qwindowcontainer_p.h>-
60#include <QtCore/qvarlengtharray.h>-
61-
62#ifdef Q_OS_MAC-
63#include <qfocusframe.h>-
64#endif-
65-
66QT_BEGIN_NAMESPACE-
67-
68#ifndef QT_NO_ACCESSIBILITY-
69-
70extern QList<QWidget*> childWidgets(const QWidget *widget);-
71-
72QString qt_accStripAmp(const QString &text);-
73QString qt_accHotKey(const QString &text);-
74-
75/*!-
76 \class QAccessibleButton-
77 \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets.-
78 \internal-
79-
80 \ingroup accessibility-
81*/-
82-
83/*!-
84 Creates a QAccessibleButton object for \a w.-
85*/-
86QAccessibleButton::QAccessibleButton(QWidget *w)-
87: QAccessibleWidget(w)-
88{-
89 Q_ASSERT(button());-
90-
91 // FIXME: The checkable state of the button is dynamic,-
92 // while we only update the controlling signal once :(-
93 if (button()->isCheckable())
button()->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
94 addControllingSignal(QLatin1String("toggled(bool)"));
never executed: addControllingSignal(QLatin1String("toggled(bool)"));
0
95 else-
96 addControllingSignal(QLatin1String("clicked()"));
never executed: addControllingSignal(QLatin1String("clicked()"));
0
97}-
98-
99/*! Returns the button. */-
100QAbstractButton *QAccessibleButton::button() const-
101{-
102 return qobject_cast<QAbstractButton*>(object());
never executed: return qobject_cast<QAbstractButton*>(object());
0
103}-
104-
105/*! \reimp */-
106QString QAccessibleButton::text(QAccessible::Text t) const-
107{-
108 QString str;-
109 switch (t) {-
110 case QAccessible::Accelerator:
never executed: case QAccessible::Accelerator:
0
111 {-
112#ifndef QT_NO_SHORTCUT-
113 QPushButton *pb = qobject_cast<QPushButton*>(object());-
114 if (pb && pb->isDefault())
pbDescription
TRUEnever evaluated
FALSEnever evaluated
pb->isDefault()Description
TRUEnever evaluated
FALSEnever evaluated
0
115 str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText);
never executed: str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText);
0
116#endif-
117 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
118 str = qt_accHotKey(button()->text());
never executed: str = qt_accHotKey(button()->text());
0
119 }-
120 break;
never executed: break;
0
121 case QAccessible::Name:
never executed: case QAccessible::Name:
0
122 str = widget()->accessibleName();-
123 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
124 str = qt_accStripAmp(button()->text());
never executed: str = qt_accStripAmp(button()->text());
0
125 break;
never executed: break;
0
126 default:
never executed: default:
0
127 break;
never executed: break;
0
128 }-
129 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
130 str = QAccessibleWidget::text(t);
never executed: str = QAccessibleWidget::text(t);
0
131 return str;
never executed: return str;
0
132}-
133-
134QAccessible::State QAccessibleButton::state() const-
135{-
136 QAccessible::State state = QAccessibleWidget::state();-
137-
138 QAbstractButton *b = button();-
139 QCheckBox *cb = qobject_cast<QCheckBox *>(b);-
140 if (b->isCheckable())
b->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
141 state.checkable = true;
never executed: state.checkable = true;
0
142 if (b->isChecked())
b->isChecked()Description
TRUEnever evaluated
FALSEnever evaluated
0
143 state.checked = true;
never executed: state.checked = true;
0
144 else if (cb && cb->checkState() == Qt::PartiallyChecked)
cbDescription
TRUEnever evaluated
FALSEnever evaluated
cb->checkState...rtiallyCheckedDescription
TRUEnever evaluated
FALSEnever evaluated
0
145 state.checkStateMixed = true;
never executed: state.checkStateMixed = true;
0
146 if (b->isDown())
b->isDown()Description
TRUEnever evaluated
FALSEnever evaluated
0
147 state.pressed = true;
never executed: state.pressed = true;
0
148 QPushButton *pb = qobject_cast<QPushButton*>(b);-
149 if (pb) {
pbDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 if (pb->isDefault())
pb->isDefault()Description
TRUEnever evaluated
FALSEnever evaluated
0
151 state.defaultButton = true;
never executed: state.defaultButton = true;
0
152#ifndef QT_NO_MENU-
153 if (pb->menu())
pb->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
154 state.hasPopup = true;
never executed: state.hasPopup = true;
0
155#endif-
156 }
never executed: end of block
0
157-
158 return state;
never executed: return state;
0
159}-
160-
161QRect QAccessibleButton::rect() const-
162{-
163 QAbstractButton *ab = button();-
164 if (!ab->isVisible())
!ab->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
165 return QRect();
never executed: return QRect();
0
166-
167 if (QCheckBox *cb = qobject_cast<QCheckBox *>(ab)) {
QCheckBox *cb ...heckBox *>(ab)Description
TRUEnever evaluated
FALSEnever evaluated
0
168 QPoint wpos = cb->mapToGlobal(QPoint(0, 0));-
169 QStyleOptionButton opt;-
170 cb->initStyleOption(&opt);-
171 return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos);
never executed: return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos);
0
172 } else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) {
QRadioButton *...oButton *>(ab)Description
TRUEnever evaluated
FALSEnever evaluated
0
173 QPoint wpos = rb->mapToGlobal(QPoint(0, 0));-
174 QStyleOptionButton opt;-
175 rb->initStyleOption(&opt);-
176 return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos);
never executed: return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos);
0
177 }-
178 return QAccessibleWidget::rect();
never executed: return QAccessibleWidget::rect();
0
179}-
180-
181QAccessible::Role QAccessibleButton::role() const-
182{-
183 QAbstractButton *ab = button();-
184-
185#ifndef QT_NO_MENU-
186 if (QPushButton *pb = qobject_cast<QPushButton*>(ab)) {
QPushButton *p...shButton*>(ab)Description
TRUEnever evaluated
FALSEnever evaluated
0
187 if (pb->menu())
pb->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
188 return QAccessible::ButtonMenu;
never executed: return QAccessible::ButtonMenu;
0
189 }
never executed: end of block
0
190#endif-
191-
192 if (ab->isCheckable())
ab->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
193 return ab->autoExclusive() ? QAccessible::RadioButton : QAccessible::CheckBox;
never executed: return ab->autoExclusive() ? QAccessible::RadioButton : QAccessible::CheckBox;
0
194-
195 return QAccessible::Button;
never executed: return QAccessible::Button;
0
196}-
197-
198QStringList QAccessibleButton::actionNames() const-
199{-
200 QStringList names;-
201 if (widget()->isEnabled()) {
widget()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
202 switch (role()) {-
203 case QAccessible::ButtonMenu:
never executed: case QAccessible::ButtonMenu:
0
204 names << showMenuAction();-
205 break;
never executed: break;
0
206 case QAccessible::RadioButton:
never executed: case QAccessible::RadioButton:
0
207 names << toggleAction();-
208 break;
never executed: break;
0
209 default:
never executed: default:
0
210 if (button()->isCheckable()) {
button()->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
211 names << toggleAction();-
212 } else {
never executed: end of block
0
213 names << pressAction();-
214 }
never executed: end of block
0
215 break;
never executed: break;
0
216 }-
217 }-
218 names << QAccessibleWidget::actionNames();-
219 return names;
never executed: return names;
0
220}-
221-
222void QAccessibleButton::doAction(const QString &actionName)-
223{-
224 if (!widget()->isEnabled())
!widget()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
225 return;
never executed: return;
0
226 if (actionName == pressAction() ||
actionName == pressAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
227 actionName == showMenuAction()) {
actionName == showMenuAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
228#ifndef QT_NO_MENU-
229 QPushButton *pb = qobject_cast<QPushButton*>(object());-
230 if (pb && pb->menu())
pbDescription
TRUEnever evaluated
FALSEnever evaluated
pb->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
231 pb->showMenu();
never executed: pb->showMenu();
0
232 else-
233#endif-
234 button()->animateClick();
never executed: button()->animateClick();
0
235 } else if (actionName == toggleAction()) {
actionName == toggleAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
236 button()->toggle();-
237 } else {
never executed: end of block
0
238 QAccessibleWidget::doAction(actionName);-
239 }
never executed: end of block
0
240}-
241-
242QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) const-
243{-
244 if (actionName == pressAction()) {
actionName == pressAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
245#ifndef QT_NO_SHORTCUT-
246 return QStringList() << button()->shortcut().toString();
never executed: return QStringList() << button()->shortcut().toString();
0
247#endif-
248 }-
249 return QStringList();
never executed: return QStringList();
0
250}-
251-
252-
253#ifndef QT_NO_TOOLBUTTON-
254/*!-
255 \class QAccessibleToolButton-
256 \brief The QAccessibleToolButton class implements the QAccessibleInterface for tool buttons.-
257 \internal-
258-
259 \ingroup accessibility-
260*/-
261-
262/*!-
263 Creates a QAccessibleToolButton object for \a w.-
264*/-
265QAccessibleToolButton::QAccessibleToolButton(QWidget *w)-
266: QAccessibleButton(w)-
267{-
268 Q_ASSERT(toolButton());-
269}
never executed: end of block
0
270-
271/*! Returns the button. */-
272QToolButton *QAccessibleToolButton::toolButton() const-
273{-
274 return qobject_cast<QToolButton*>(object());
never executed: return qobject_cast<QToolButton*>(object());
0
275}-
276-
277/*!-
278 Returns \c true if this tool button is a split button.-
279*/-
280bool QAccessibleToolButton::isSplitButton() const-
281{-
282#ifndef QT_NO_MENU-
283 return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup;
never executed: return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup;
0
284#else-
285 return false;-
286#endif-
287}-
288-
289QAccessible::State QAccessibleToolButton::state() const-
290{-
291 QAccessible::State st = QAccessibleButton::state();-
292 if (toolButton()->autoRaise())
toolButton()->autoRaise()Description
TRUEnever evaluated
FALSEnever evaluated
0
293 st.hotTracked = true;
never executed: st.hotTracked = true;
0
294#ifndef QT_NO_MENU-
295 if (toolButton()->menu())
toolButton()->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
296 st.hasPopup = true;
never executed: st.hasPopup = true;
0
297#endif-
298 return st;
never executed: return st;
0
299}-
300-
301int QAccessibleToolButton::childCount() const-
302{-
303 return isSplitButton() ? 1 : 0;
never executed: return isSplitButton() ? 1 : 0;
0
304}-
305-
306QAccessible::Role QAccessibleToolButton::role() const-
307{-
308 QAbstractButton *ab = button();-
309-
310#ifndef QT_NO_MENU-
311 QToolButton *tb = qobject_cast<QToolButton*>(ab);-
312 if (!tb->menu())
!tb->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
313 return tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton;
never executed: return tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton;
0
314 else if (tb->popupMode() == QToolButton::DelayedPopup)
tb->popupMode(...::DelayedPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
315 return QAccessible::ButtonDropDown;
never executed: return QAccessible::ButtonDropDown;
0
316#endif-
317-
318 return QAccessible::ButtonMenu;
never executed: return QAccessible::ButtonMenu;
0
319}-
320-
321QAccessibleInterface *QAccessibleToolButton::child(int index) const-
322{-
323#ifndef QT_NO_MENU-
324 if (index == 0 && toolButton()->menu())
index == 0Description
TRUEnever evaluated
FALSEnever evaluated
toolButton()->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
325 {-
326 return QAccessible::queryAccessibleInterface(toolButton()->menu());
never executed: return QAccessible::queryAccessibleInterface(toolButton()->menu());
0
327 }-
328#endif-
329 return 0;
never executed: return 0;
0
330}-
331-
332/*-
333 The three different tool button types can have the following actions:-
334| DelayedPopup | ShowMenuAction + (PressedAction || CheckedAction) |-
335| MenuButtonPopup | ShowMenuAction + (PressedAction || CheckedAction) |-
336| InstantPopup | ShowMenuAction |-
337*/-
338QStringList QAccessibleToolButton::actionNames() const-
339{-
340 QStringList names;-
341 if (widget()->isEnabled()) {
widget()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
342 if (toolButton()->menu())
toolButton()->menu()Description
TRUEnever evaluated
FALSEnever evaluated
0
343 names << showMenuAction();
never executed: names << showMenuAction();
0
344 if (toolButton()->popupMode() != QToolButton::InstantPopup)
toolButton()->...::InstantPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
345 names << QAccessibleButton::actionNames();
never executed: names << QAccessibleButton::actionNames();
0
346 }
never executed: end of block
0
347 return names;
never executed: return names;
0
348}-
349-
350void QAccessibleToolButton::doAction(const QString &actionName)-
351{-
352 if (!widget()->isEnabled())
!widget()->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
353 return;
never executed: return;
0
354-
355 if (actionName == pressAction()) {
actionName == pressAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
356 button()->click();-
357 } else if (actionName == showMenuAction()) {
never executed: end of block
actionName == showMenuAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
358 if (toolButton()->popupMode() != QToolButton::InstantPopup) {
toolButton()->...::InstantPopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
359 toolButton()->setDown(true);-
360#ifndef QT_NO_MENU-
361 toolButton()->showMenu();-
362#endif-
363 }
never executed: end of block
0
364 } else {
never executed: end of block
0
365 QAccessibleButton::doAction(actionName);-
366 }
never executed: end of block
0
367-
368}-
369-
370#endif // QT_NO_TOOLBUTTON-
371-
372/*!-
373 \class QAccessibleDisplay-
374 \brief The QAccessibleDisplay class implements the QAccessibleInterface for widgets that display information.-
375 \internal-
376-
377 \ingroup accessibility-
378*/-
379-
380/*!-
381 Constructs a QAccessibleDisplay object for \a w.-
382 \a role is propagated to the QAccessibleWidget constructor.-
383*/-
384QAccessibleDisplay::QAccessibleDisplay(QWidget *w, QAccessible::Role role)-
385: QAccessibleWidget(w, role)-
386{-
387}
never executed: end of block
0
388-
389QAccessible::Role QAccessibleDisplay::role() const-
390{-
391 QLabel *l = qobject_cast<QLabel*>(object());-
392 if (l) {
lDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 if (l->pixmap())
l->pixmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
394 return QAccessible::Graphic;
never executed: return QAccessible::Graphic;
0
395#ifndef QT_NO_PICTURE-
396 if (l->picture())
l->picture()Description
TRUEnever evaluated
FALSEnever evaluated
0
397 return QAccessible::Graphic;
never executed: return QAccessible::Graphic;
0
398#endif-
399#ifndef QT_NO_MOVIE-
400 if (l->movie())
l->movie()Description
TRUEnever evaluated
FALSEnever evaluated
0
401 return QAccessible::Animation;
never executed: return QAccessible::Animation;
0
402#endif-
403#ifndef QT_NO_PROGRESSBAR-
404 } else if (qobject_cast<QProgressBar*>(object())) {
never executed: end of block
qobject_cast<Q...ar*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
405 return QAccessible::ProgressBar;
never executed: return QAccessible::ProgressBar;
0
406#endif-
407 } else if (qobject_cast<QStatusBar*>(object())) {
qobject_cast<Q...ar*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
408 return QAccessible::StatusBar;
never executed: return QAccessible::StatusBar;
0
409 }-
410 return QAccessibleWidget::role();
never executed: return QAccessibleWidget::role();
0
411}-
412-
413QString QAccessibleDisplay::text(QAccessible::Text t) const-
414{-
415 QString str;-
416 switch (t) {-
417 case QAccessible::Name:
never executed: case QAccessible::Name:
0
418 str = widget()->accessibleName();-
419 if (str.isEmpty()) {
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
420 if (qobject_cast<QLabel*>(object())) {
qobject_cast<Q...el*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
421 QLabel *label = qobject_cast<QLabel*>(object());-
422 str = label->text();-
423#ifndef QT_NO_TEXTHTMLPARSER-
424 if (label->textFormat() == Qt::RichText
label->textFor...= Qt::RichTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
425 || (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) {
label->textFor...= Qt::AutoTextDescription
TRUEnever evaluated
FALSEnever evaluated
Qt::mightBeRichText(str)Description
TRUEnever evaluated
FALSEnever evaluated
0
426 QTextDocument doc;-
427 doc.setHtml(str);-
428 str = doc.toPlainText();-
429 }
never executed: end of block
0
430#endif-
431 if (label->buddy())
label->buddy()Description
TRUEnever evaluated
FALSEnever evaluated
0
432 str = qt_accStripAmp(str);
never executed: str = qt_accStripAmp(str);
0
433#ifndef QT_NO_LCDNUMBER-
434 } else if (qobject_cast<QLCDNumber*>(object())) {
never executed: end of block
qobject_cast<Q...er*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
435 QLCDNumber *l = qobject_cast<QLCDNumber*>(object());-
436 if (l->digitCount())
l->digitCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
437 str = QString::number(l->value());
never executed: str = QString::number(l->value());
0
438 else-
439 str = QString::number(l->intValue());
never executed: str = QString::number(l->intValue());
0
440#endif-
441 } else if (qobject_cast<QStatusBar*>(object())) {
qobject_cast<Q...ar*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
442 return qobject_cast<QStatusBar*>(object())->currentMessage();
never executed: return qobject_cast<QStatusBar*>(object())->currentMessage();
0
443 }-
444 }
never executed: end of block
0
445 break;
never executed: break;
0
446 case QAccessible::Value:
never executed: case QAccessible::Value:
0
447#ifndef QT_NO_PROGRESSBAR-
448 if (qobject_cast<QProgressBar*>(object()))
qobject_cast<Q...ar*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
449 str = QString::number(qobject_cast<QProgressBar*>(object())->value());
never executed: str = QString::number(qobject_cast<QProgressBar*>(object())->value());
0
450#endif-
451 break;
never executed: break;
0
452 default:
never executed: default:
0
453 break;
never executed: break;
0
454 }-
455 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
456 str = QAccessibleWidget::text(t);
never executed: str = QAccessibleWidget::text(t);
0
457 return str;
never executed: return str;
0
458}-
459-
460/*! \reimp */-
461QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >-
462QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const-
463{-
464 QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match);-
465 if (match & QAccessible::Labelled) {
match & QAccessible::LabelledDescription
TRUEnever evaluated
FALSEnever evaluated
0
466 QVarLengthArray<QObject *, 4> relatedObjects;-
467-
468#ifndef QT_NO_SHORTCUT-
469 if (QLabel *label = qobject_cast<QLabel*>(object())) {
QLabel *label ...el*>(object())Description
TRUEnever evaluated
FALSEnever evaluated
0
470 relatedObjects.append(label->buddy());-
471 }
never executed: end of block
0
472#endif-
473 for (int i = 0; i < relatedObjects.count(); ++i) {
i < relatedObjects.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
474 const QAccessible::Relation rel = QAccessible::Labelled;-
475 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(relatedObjects.at(i));-
476 if (iface)
ifaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
477 rels.append(qMakePair(iface, rel));
never executed: rels.append(qMakePair(iface, rel));
0
478 }
never executed: end of block
0
479 }
never executed: end of block
0
480 return rels;
never executed: return rels;
0
481}-
482-
483void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t)-
484{-
485 if (t == QAccessible::ImageInterface)
t == QAccessib...ImageInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
486 return static_cast<QAccessibleImageInterface*>(this);
never executed: return static_cast<QAccessibleImageInterface*>(this);
0
487 return QAccessibleWidget::interface_cast(t);
never executed: return QAccessibleWidget::interface_cast(t);
0
488}-
489-
490/*! \internal */-
491QString QAccessibleDisplay::imageDescription() const-
492{-
493#ifndef QT_NO_TOOLTIP-
494 return widget()->toolTip();
never executed: return widget()->toolTip();
0
495#else-
496 return QString::null;-
497#endif-
498}-
499-
500/*! \internal */-
501QSize QAccessibleDisplay::imageSize() const-
502{-
503 QLabel *label = qobject_cast<QLabel *>(widget());-
504 if (!label)
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
0
505 return QSize();
never executed: return QSize();
0
506 const QPixmap *pixmap = label->pixmap();-
507 if (!pixmap)
!pixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
508 return QSize();
never executed: return QSize();
0
509 return pixmap->size();
never executed: return pixmap->size();
0
510}-
511-
512/*! \internal */-
513QPoint QAccessibleDisplay::imagePosition() const-
514{-
515 QLabel *label = qobject_cast<QLabel *>(widget());-
516 if (!label)
!labelDescription
TRUEnever evaluated
FALSEnever evaluated
0
517 return QPoint();
never executed: return QPoint();
0
518 const QPixmap *pixmap = label->pixmap();-
519 if (!pixmap)
!pixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
520 return QPoint();
never executed: return QPoint();
0
521-
522 return QPoint(label->mapToGlobal(label->pos()));
never executed: return QPoint(label->mapToGlobal(label->pos()));
0
523}-
524-
525#ifndef QT_NO_GROUPBOX-
526QAccessibleGroupBox::QAccessibleGroupBox(QWidget *w)-
527: QAccessibleWidget(w)-
528{-
529}
never executed: end of block
0
530-
531QGroupBox* QAccessibleGroupBox::groupBox() const-
532{-
533 return static_cast<QGroupBox *>(widget());
never executed: return static_cast<QGroupBox *>(widget());
0
534}-
535-
536QString QAccessibleGroupBox::text(QAccessible::Text t) const-
537{-
538 QString txt = QAccessibleWidget::text(t);-
539-
540 if (txt.isEmpty()) {
txt.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
541 switch (t) {-
542 case QAccessible::Name:
never executed: case QAccessible::Name:
0
543 txt = qt_accStripAmp(groupBox()->title());-
544 break;
never executed: break;
0
545 case QAccessible::Description:
never executed: case QAccessible::Description:
0
546 txt = groupBox()->toolTip();-
547 break;
never executed: break;
0
548 case QAccessible::Accelerator:
never executed: case QAccessible::Accelerator:
0
549 txt = qt_accHotKey(groupBox()->title());-
550 break;
never executed: break;
0
551 default:
never executed: default:
0
552 break;
never executed: break;
0
553 }-
554 }-
555-
556 return txt;
never executed: return txt;
0
557}-
558-
559QAccessible::State QAccessibleGroupBox::state() const-
560{-
561 QAccessible::State st = QAccessibleWidget::state();-
562 st.checkable = groupBox()->isCheckable();-
563 st.checked = groupBox()->isChecked();-
564 return st;
never executed: return st;
0
565}-
566-
567QAccessible::Role QAccessibleGroupBox::role() const-
568{-
569 return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping;
never executed: return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping;
0
570}-
571-
572QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >-
573QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const-
574{-
575 QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match);-
576-
577 if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) {
(match & QAcce...ble::Labelled)Description
TRUEnever evaluated
FALSEnever evaluated
(!groupBox()->...e().isEmpty())Description
TRUEnever evaluated
FALSEnever evaluated
0
578 const QList<QWidget*> kids = childWidgets(widget());-
579 for (QWidget *kid : kids) {-
580 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kid);-
581 if (iface)
ifaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
582 rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled)));
never executed: rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled)));
0
583 }
never executed: end of block
0
584 }
never executed: end of block
0
585 return rels;
never executed: return rels;
0
586}-
587-
588QStringList QAccessibleGroupBox::actionNames() const-
589{-
590 QStringList actions = QAccessibleWidget::actionNames();-
591-
592 if (groupBox()->isCheckable()) {
groupBox()->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
0
593 actions.prepend(QAccessibleActionInterface::toggleAction());-
594 }
never executed: end of block
0
595 return actions;
never executed: return actions;
0
596}-
597-
598void QAccessibleGroupBox::doAction(const QString &actionName)-
599{-
600 if (actionName == QAccessibleActionInterface::toggleAction())
actionName == ...toggleAction()Description
TRUEnever evaluated
FALSEnever evaluated
0
601 groupBox()->setChecked(!groupBox()->isChecked());
never executed: groupBox()->setChecked(!groupBox()->isChecked());
0
602}
never executed: end of block
0
603-
604QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const-
605{-
606 return QStringList();
never executed: return QStringList();
0
607}-
608-
609#endif-
610-
611#ifndef QT_NO_LINEEDIT-
612/*!-
613 \class QAccessibleLineEdit-
614 \brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text-
615 \internal-
616-
617 \ingroup accessibility-
618*/-
619-
620/*!-
621 Constructs a QAccessibleLineEdit object for \a w.-
622 \a name is propagated to the QAccessibleWidget constructor.-
623*/-
624QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name)-
625: QAccessibleWidget(w, QAccessible::EditableText, name)-
626{-
627 addControllingSignal(QLatin1String("textChanged(const QString&)"));-
628 addControllingSignal(QLatin1String("returnPressed()"));-
629}
never executed: end of block
0
630-
631/*! Returns the line edit. */-
632QLineEdit *QAccessibleLineEdit::lineEdit() const-
633{-
634 return qobject_cast<QLineEdit*>(object());
never executed: return qobject_cast<QLineEdit*>(object());
0
635}-
636-
637QString QAccessibleLineEdit::text(QAccessible::Text t) const-
638{-
639 QString str;-
640 switch (t) {-
641 case QAccessible::Value:
never executed: case QAccessible::Value:
0
642 if (lineEdit()->echoMode() == QLineEdit::Normal)
lineEdit()->ec...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
643 str = lineEdit()->text();
never executed: str = lineEdit()->text();
0
644 else if (lineEdit()->echoMode() != QLineEdit::NoEcho)
lineEdit()->ec...neEdit::NoEchoDescription
TRUEnever evaluated
FALSEnever evaluated
0
645 str = QString(lineEdit()->text().length(), QChar::fromLatin1('*'));
never executed: str = QString(lineEdit()->text().length(), QChar::fromLatin1('*'));
0
646 break;
never executed: break;
0
647 default:
never executed: default:
0
648 break;
never executed: break;
0
649 }-
650 if (str.isEmpty())
str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
651 str = QAccessibleWidget::text(t);
never executed: str = QAccessibleWidget::text(t);
0
652 return str;
never executed: return str;
0
653}-
654-
655void QAccessibleLineEdit::setText(QAccessible::Text t, const QString &text)-
656{-
657 if (t != QAccessible::Value) {
t != QAccessible::ValueDescription
TRUEnever evaluated
FALSEnever evaluated
0
658 QAccessibleWidget::setText(t, text);-
659 return;
never executed: return;
0
660 }-
661-
662 QString newText = text;-
663 if (lineEdit()->validator()) {
lineEdit()->validator()Description
TRUEnever evaluated
FALSEnever evaluated
0
664 int pos = 0;-
665 if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable)
lineEdit()->va...or::AcceptableDescription
TRUEnever evaluated
FALSEnever evaluated
0
666 return;
never executed: return;
0
667 }
never executed: end of block
0
668 lineEdit()->setText(newText);-
669}
never executed: end of block
0
670-
671QAccessible::State QAccessibleLineEdit::state() const-
672{-
673 QAccessible::State state = QAccessibleWidget::state();-
674-
675 QLineEdit *l = lineEdit();-
676 if (l->isReadOnly())
l->isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
0
677 state.readOnly = true;
never executed: state.readOnly = true;
0
678 else-
679 state.editable = true;
never executed: state.editable = true;
0
680-
681 if (l->echoMode() != QLineEdit::Normal)
l->echoMode() ...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
682 state.passwordEdit = true;
never executed: state.passwordEdit = true;
0
683-
684 state.selectableText = true;-
685 return state;
never executed: return state;
0
686}-
687-
688void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t)-
689{-
690 if (t == QAccessible::TextInterface)
t == QAccessib...:TextInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
691 return static_cast<QAccessibleTextInterface*>(this);
never executed: return static_cast<QAccessibleTextInterface*>(this);
0
692 if (t == QAccessible::EditableTextInterface)
t == QAccessib...eTextInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
693 return static_cast<QAccessibleEditableTextInterface*>(this);
never executed: return static_cast<QAccessibleEditableTextInterface*>(this);
0
694 return QAccessibleWidget::interface_cast(t);
never executed: return QAccessibleWidget::interface_cast(t);
0
695}-
696-
697void QAccessibleLineEdit::addSelection(int startOffset, int endOffset)-
698{-
699 setSelection(0, startOffset, endOffset);-
700}
never executed: end of block
0
701-
702QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset) const-
703{-
704 // QLineEdit doesn't have text attributes-
705 *startOffset = *endOffset = offset;-
706 return QString();
never executed: return QString();
0
707}-
708-
709int QAccessibleLineEdit::cursorPosition() const-
710{-
711 return lineEdit()->cursorPosition();
never executed: return lineEdit()->cursorPosition();
0
712}-
713-
714QRect QAccessibleLineEdit::characterRect(int offset) const-
715{-
716 int x = lineEdit()->d_func()->control->cursorToX(offset);-
717 int y;-
718 lineEdit()->getTextMargins(0, &y, 0, 0);-
719 QFontMetrics fm(lineEdit()->font());-
720 const QString ch = text(offset, offset + 1);-
721 if (ch.isEmpty())
ch.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
722 return QRect();
never executed: return QRect();
0
723 int w = fm.width(ch);-
724 int h = fm.height();-
725 QRect r(x, y, w, h);-
726 r.moveTo(lineEdit()->mapToGlobal(r.topLeft()));-
727 return r;
never executed: return r;
0
728}-
729-
730int QAccessibleLineEdit::selectionCount() const-
731{-
732 return lineEdit()->hasSelectedText() ? 1 : 0;
never executed: return lineEdit()->hasSelectedText() ? 1 : 0;
0
733}-
734-
735int QAccessibleLineEdit::offsetAtPoint(const QPoint &point) const-
736{-
737 QPoint p = lineEdit()->mapFromGlobal(point);-
738-
739 return lineEdit()->cursorPositionAt(p);
never executed: return lineEdit()->cursorPositionAt(p);
0
740}-
741-
742void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset) const-
743{-
744 *startOffset = *endOffset = 0;-
745 if (selectionIndex != 0)
selectionIndex != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
746 return;
never executed: return;
0
747-
748 *startOffset = lineEdit()->selectionStart();-
749 *endOffset = *startOffset + lineEdit()->selectedText().count();-
750}
never executed: end of block
0
751-
752QString QAccessibleLineEdit::text(int startOffset, int endOffset) const-
753{-
754 if (startOffset > endOffset)
startOffset > endOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
755 return QString();
never executed: return QString();
0
756-
757 if (lineEdit()->echoMode() != QLineEdit::Normal)
lineEdit()->ec...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
758 return QString();
never executed: return QString();
0
759-
760 return lineEdit()->text().mid(startOffset, endOffset - startOffset);
never executed: return lineEdit()->text().mid(startOffset, endOffset - startOffset);
0
761}-
762-
763QString QAccessibleLineEdit::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
764 int *startOffset, int *endOffset) const-
765{-
766 if (lineEdit()->echoMode() != QLineEdit::Normal) {
lineEdit()->ec...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
767 *startOffset = *endOffset = -1;-
768 return QString();
never executed: return QString();
0
769 }-
770 if (offset == -2)
offset == -2Description
TRUEnever evaluated
FALSEnever evaluated
0
771 offset = cursorPosition();
never executed: offset = cursorPosition();
0
772 return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset);
0
773}-
774-
775QString QAccessibleLineEdit::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
776 int *startOffset, int *endOffset) const-
777{-
778 if (lineEdit()->echoMode() != QLineEdit::Normal) {
lineEdit()->ec...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
779 *startOffset = *endOffset = -1;-
780 return QString();
never executed: return QString();
0
781 }-
782 if (offset == -2)
offset == -2Description
TRUEnever evaluated
FALSEnever evaluated
0
783 offset = cursorPosition();
never executed: offset = cursorPosition();
0
784 return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset);
0
785}-
786-
787QString QAccessibleLineEdit::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,-
788 int *startOffset, int *endOffset) const-
789{-
790 if (lineEdit()->echoMode() != QLineEdit::Normal) {
lineEdit()->ec...neEdit::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
791 *startOffset = *endOffset = -1;-
792 return QString();
never executed: return QString();
0
793 }-
794 if (offset == -2)
offset == -2Description
TRUEnever evaluated
FALSEnever evaluated
0
795 offset = cursorPosition();
never executed: offset = cursorPosition();
0
796 return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
never executed: return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset);
0
797}-
798-
799void QAccessibleLineEdit::removeSelection(int selectionIndex)-
800{-
801 if (selectionIndex != 0)
selectionIndex != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
802 return;
never executed: return;
0
803-
804 lineEdit()->deselect();-
805}
never executed: end of block
0
806-
807void QAccessibleLineEdit::setCursorPosition(int position)-
808{-
809 lineEdit()->setCursorPosition(position);-
810}
never executed: end of block
0
811-
812void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int endOffset)-
813{-
814 if (selectionIndex != 0)
selectionIndex != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
815 return;
never executed: return;
0
816-
817 lineEdit()->setSelection(startOffset, endOffset - startOffset);-
818}
never executed: end of block
0
819-
820int QAccessibleLineEdit::characterCount() const-
821{-
822 return lineEdit()->text().count();
never executed: return lineEdit()->text().count();
0
823}-
824-
825void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex)-
826{-
827 lineEdit()->setCursorPosition(endIndex);-
828 lineEdit()->setCursorPosition(startIndex);-
829}
never executed: end of block
0
830-
831void QAccessibleLineEdit::deleteText(int startOffset, int endOffset)-
832{-
833 lineEdit()->setText(lineEdit()->text().remove(startOffset, endOffset - startOffset));-
834}
never executed: end of block
0
835-
836void QAccessibleLineEdit::insertText(int offset, const QString &text)-
837{-
838 lineEdit()->setText(lineEdit()->text().insert(offset, text));-
839}
never executed: end of block
0
840-
841void QAccessibleLineEdit::replaceText(int startOffset, int endOffset, const QString &text)-
842{-
843 lineEdit()->setText(lineEdit()->text().replace(startOffset, endOffset - startOffset, text));-
844}
never executed: end of block
0
845-
846#endif // QT_NO_LINEEDIT-
847-
848#ifndef QT_NO_PROGRESSBAR-
849QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o)-
850 : QAccessibleDisplay(o)-
851{-
852 Q_ASSERT(progressBar());-
853}
never executed: end of block
0
854-
855void *QAccessibleProgressBar::interface_cast(QAccessible::InterfaceType t)-
856{-
857 if (t == QAccessible::ValueInterface)
t == QAccessib...ValueInterfaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 return static_cast<QAccessibleValueInterface*>(this);
never executed: return static_cast<QAccessibleValueInterface*>(this);
0
859 return QAccessibleDisplay::interface_cast(t);
never executed: return QAccessibleDisplay::interface_cast(t);
0
860}-
861-
862QVariant QAccessibleProgressBar::currentValue() const-
863{-
864 return progressBar()->value();
never executed: return progressBar()->value();
0
865}-
866-
867QVariant QAccessibleProgressBar::maximumValue() const-
868{-
869 return progressBar()->maximum();
never executed: return progressBar()->maximum();
0
870}-
871-
872QVariant QAccessibleProgressBar::minimumValue() const-
873{-
874 return progressBar()->minimum();
never executed: return progressBar()->minimum();
0
875}-
876-
877QVariant QAccessibleProgressBar::minimumStepSize() const-
878{-
879 // This is arbitrary since any value between min and max is valid.-
880 // Some screen readers (orca use it to calculate how many digits to display though,-
881 // so it makes sense to return a "sensible" value. Providing 100 increments seems ok.-
882 return (progressBar()->maximum() - progressBar()->minimum()) / 100.0;
never executed: return (progressBar()->maximum() - progressBar()->minimum()) / 100.0;
0
883}-
884-
885QProgressBar *QAccessibleProgressBar::progressBar() const-
886{-
887 return qobject_cast<QProgressBar *>(object());
never executed: return qobject_cast<QProgressBar *>(object());
0
888}-
889#endif-
890-
891-
892QAccessibleWindowContainer::QAccessibleWindowContainer(QWidget *w)-
893 : QAccessibleWidget(w)-
894{-
895}
never executed: end of block
0
896-
897int QAccessibleWindowContainer::childCount() const-
898{-
899 if (container()->containedWindow())
container()->containedWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
900 return 1;
never executed: return 1;
0
901 return 0;
never executed: return 0;
0
902}-
903-
904int QAccessibleWindowContainer::indexOfChild(const QAccessibleInterface *child) const-
905{-
906 if (child->object() == container()->containedWindow())
child->object(...tainedWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
907 return 0;
never executed: return 0;
0
908 return -1;
never executed: return -1;
0
909}-
910-
911QAccessibleInterface *QAccessibleWindowContainer::child(int i) const-
912{-
913 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
914 return QAccessible::queryAccessibleInterface(container()->containedWindow());
never executed: return QAccessible::queryAccessibleInterface(container()->containedWindow());
0
915 return 0;
never executed: return 0;
0
916}-
917-
918QWindowContainer *QAccessibleWindowContainer::container() const-
919{-
920 return static_cast<QWindowContainer *>(widget());
never executed: return static_cast<QWindowContainer *>(widget());
0
921}-
922-
923#endif // QT_NO_ACCESSIBILITY-
924-
925QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9