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