Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/qaccessiblewidgets.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 "qaccessiblewidgets_p.h" | - | ||||||||||||||||||
35 | #include "qabstracttextdocumentlayout.h" | - | ||||||||||||||||||
36 | #include "qapplication.h" | - | ||||||||||||||||||
37 | #include "qclipboard.h" | - | ||||||||||||||||||
38 | #include "qtextedit.h" | - | ||||||||||||||||||
39 | #include "private/qtextedit_p.h" | - | ||||||||||||||||||
40 | #include "qtextdocument.h" | - | ||||||||||||||||||
41 | #include "qtextobject.h" | - | ||||||||||||||||||
42 | #include "qplaintextedit.h" | - | ||||||||||||||||||
43 | #include "qtextboundaryfinder.h" | - | ||||||||||||||||||
44 | #include "qscrollbar.h" | - | ||||||||||||||||||
45 | #include "qdebug.h" | - | ||||||||||||||||||
46 | #include <QApplication> | - | ||||||||||||||||||
47 | #include <QStackedWidget> | - | ||||||||||||||||||
48 | #include <QToolBox> | - | ||||||||||||||||||
49 | #include <QMdiArea> | - | ||||||||||||||||||
50 | #include <QMdiSubWindow> | - | ||||||||||||||||||
51 | #include <QDialogButtonBox> | - | ||||||||||||||||||
52 | #include <limits.h> | - | ||||||||||||||||||
53 | #include <QRubberBand> | - | ||||||||||||||||||
54 | #include <QTextBrowser> | - | ||||||||||||||||||
55 | #include <QCalendarWidget> | - | ||||||||||||||||||
56 | #include <QAbstractItemView> | - | ||||||||||||||||||
57 | #include <QDockWidget> | - | ||||||||||||||||||
58 | #include <QMainWindow> | - | ||||||||||||||||||
59 | #include <QAbstractButton> | - | ||||||||||||||||||
60 | #include <private/qdockwidget_p.h> | - | ||||||||||||||||||
61 | #include <QFocusFrame> | - | ||||||||||||||||||
62 | - | |||||||||||||||||||
63 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | QString qt_accStripAmp(const QString &text); | - | ||||||||||||||||||
68 | QString qt_accHotKey(const QString &text); | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | QList<QWidget*> childWidgets(const QWidget *widget) | - | ||||||||||||||||||
71 | { | - | ||||||||||||||||||
72 | if (widget == 0)
| 0 | ||||||||||||||||||
73 | return QList<QWidget*>(); never executed: return QList<QWidget*>(); | 0 | ||||||||||||||||||
74 | QList<QObject*> list = widget->children(); | - | ||||||||||||||||||
75 | QList<QWidget*> widgets; | - | ||||||||||||||||||
76 | for (int i = 0; i < list.size(); ++i) {
| 0 | ||||||||||||||||||
77 | QWidget *w = qobject_cast<QWidget *>(list.at(i)); | - | ||||||||||||||||||
78 | if (!w)
| 0 | ||||||||||||||||||
79 | continue; never executed: continue; | 0 | ||||||||||||||||||
80 | QString objectName = w->objectName(); | - | ||||||||||||||||||
81 | if (!w->isWindow()
| 0 | ||||||||||||||||||
82 | && !qobject_cast<QFocusFrame*>(w)
| 0 | ||||||||||||||||||
83 | && !qobject_cast<QMenu*>(w)
| 0 | ||||||||||||||||||
84 | && objectName != QLatin1String("qt_rubberband")
| 0 | ||||||||||||||||||
85 | && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) {
| 0 | ||||||||||||||||||
86 | widgets.append(w); | - | ||||||||||||||||||
87 | } never executed: end of block | 0 | ||||||||||||||||||
88 | } never executed: end of block | 0 | ||||||||||||||||||
89 | return widgets; never executed: return widgets; | 0 | ||||||||||||||||||
90 | } | - | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | #if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR) | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o) | - | ||||||||||||||||||
95 | :QAccessibleTextWidget(o) | - | ||||||||||||||||||
96 | { | - | ||||||||||||||||||
97 | Q_ASSERT(widget()->inherits("QPlainTextEdit")); | - | ||||||||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||||||||
99 | - | |||||||||||||||||||
100 | QPlainTextEdit* QAccessiblePlainTextEdit::plainTextEdit() const | - | ||||||||||||||||||
101 | { | - | ||||||||||||||||||
102 | return static_cast<QPlainTextEdit *>(widget()); never executed: return static_cast<QPlainTextEdit *>(widget()); | 0 | ||||||||||||||||||
103 | } | - | ||||||||||||||||||
104 | - | |||||||||||||||||||
105 | QString QAccessiblePlainTextEdit::text(QAccessible::Text t) const | - | ||||||||||||||||||
106 | { | - | ||||||||||||||||||
107 | if (t == QAccessible::Value)
| 0 | ||||||||||||||||||
108 | return plainTextEdit()->toPlainText(); never executed: return plainTextEdit()->toPlainText(); | 0 | ||||||||||||||||||
109 | - | |||||||||||||||||||
110 | return QAccessibleWidget::text(t); never executed: return QAccessibleWidget::text(t); | 0 | ||||||||||||||||||
111 | } | - | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | void QAccessiblePlainTextEdit::setText(QAccessible::Text t, const QString &text) | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | if (t != QAccessible::Value) {
| 0 | ||||||||||||||||||
116 | QAccessibleWidget::setText(t, text); | - | ||||||||||||||||||
117 | return; never executed: return; | 0 | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | if (plainTextEdit()->isReadOnly())
| 0 | ||||||||||||||||||
120 | return; never executed: return; | 0 | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | plainTextEdit()->setPlainText(text); | - | ||||||||||||||||||
123 | } never executed: end of block | 0 | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | QAccessible::State QAccessiblePlainTextEdit::state() const | - | ||||||||||||||||||
126 | { | - | ||||||||||||||||||
127 | QAccessible::State st = QAccessibleTextWidget::state(); | - | ||||||||||||||||||
128 | if (plainTextEdit()->isReadOnly())
| 0 | ||||||||||||||||||
129 | st.readOnly = true; never executed: st.readOnly = true; | 0 | ||||||||||||||||||
130 | else | - | ||||||||||||||||||
131 | st.editable = true; never executed: st.editable = true; | 0 | ||||||||||||||||||
132 | return st; never executed: return st; | 0 | ||||||||||||||||||
133 | } | - | ||||||||||||||||||
134 | - | |||||||||||||||||||
135 | void *QAccessiblePlainTextEdit::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
136 | { | - | ||||||||||||||||||
137 | if (t == QAccessible::TextInterface)
| 0 | ||||||||||||||||||
138 | return static_cast<QAccessibleTextInterface*>(this); never executed: return static_cast<QAccessibleTextInterface*>(this); | 0 | ||||||||||||||||||
139 | else if (t == QAccessible::EditableTextInterface)
| 0 | ||||||||||||||||||
140 | return static_cast<QAccessibleEditableTextInterface*>(this); never executed: return static_cast<QAccessibleEditableTextInterface*>(this); | 0 | ||||||||||||||||||
141 | return QAccessibleWidget::interface_cast(t); never executed: return QAccessibleWidget::interface_cast(t); | 0 | ||||||||||||||||||
142 | } | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | QPoint QAccessiblePlainTextEdit::scrollBarPosition() const | - | ||||||||||||||||||
145 | { | - | ||||||||||||||||||
146 | QPoint result; | - | ||||||||||||||||||
147 | result.setX(plainTextEdit()->horizontalScrollBar() ? plainTextEdit()->horizontalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
148 | result.setY(plainTextEdit()->verticalScrollBar() ? plainTextEdit()->verticalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
149 | return result; never executed: return result; | 0 | ||||||||||||||||||
150 | } | - | ||||||||||||||||||
151 | - | |||||||||||||||||||
152 | QTextCursor QAccessiblePlainTextEdit::textCursor() const | - | ||||||||||||||||||
153 | { | - | ||||||||||||||||||
154 | return plainTextEdit()->textCursor(); never executed: return plainTextEdit()->textCursor(); | 0 | ||||||||||||||||||
155 | } | - | ||||||||||||||||||
156 | - | |||||||||||||||||||
157 | void QAccessiblePlainTextEdit::setTextCursor(const QTextCursor &textCursor) | - | ||||||||||||||||||
158 | { | - | ||||||||||||||||||
159 | plainTextEdit()->setTextCursor(textCursor); | - | ||||||||||||||||||
160 | } never executed: end of block | 0 | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | QTextDocument* QAccessiblePlainTextEdit::textDocument() const | - | ||||||||||||||||||
163 | { | - | ||||||||||||||||||
164 | return plainTextEdit()->document(); never executed: return plainTextEdit()->document(); | 0 | ||||||||||||||||||
165 | } | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | QWidget* QAccessiblePlainTextEdit::viewport() const | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | return plainTextEdit()->viewport(); never executed: return plainTextEdit()->viewport(); | 0 | ||||||||||||||||||
170 | } | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | void QAccessiblePlainTextEdit::scrollToSubstring(int startIndex, int endIndex) | - | ||||||||||||||||||
173 | { | - | ||||||||||||||||||
174 | //TODO: Not implemented | - | ||||||||||||||||||
175 | Q_UNUSED(startIndex); | - | ||||||||||||||||||
176 | Q_UNUSED(endIndex); | - | ||||||||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||||||||
178 | - | |||||||||||||||||||
179 | - | |||||||||||||||||||
180 | /*! | - | ||||||||||||||||||
181 | \class QAccessibleTextEdit | - | ||||||||||||||||||
182 | \brief The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors. | - | ||||||||||||||||||
183 | \internal | - | ||||||||||||||||||
184 | */ | - | ||||||||||||||||||
185 | - | |||||||||||||||||||
186 | /*! | - | ||||||||||||||||||
187 | \fn QAccessibleTextEdit::QAccessibleTextEdit(QWidget *widget) | - | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | Constructs a QAccessibleTextEdit object for a \a widget. | - | ||||||||||||||||||
190 | */ | - | ||||||||||||||||||
191 | QAccessibleTextEdit::QAccessibleTextEdit(QWidget *o) | - | ||||||||||||||||||
192 | : QAccessibleTextWidget(o, QAccessible::EditableText) | - | ||||||||||||||||||
193 | { | - | ||||||||||||||||||
194 | Q_ASSERT(widget()->inherits("QTextEdit")); | - | ||||||||||||||||||
195 | } never executed: end of block | 0 | ||||||||||||||||||
196 | - | |||||||||||||||||||
197 | /*! Returns the text edit. */ | - | ||||||||||||||||||
198 | QTextEdit *QAccessibleTextEdit::textEdit() const | - | ||||||||||||||||||
199 | { | - | ||||||||||||||||||
200 | return static_cast<QTextEdit *>(widget()); never executed: return static_cast<QTextEdit *>(widget()); | 0 | ||||||||||||||||||
201 | } | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | QTextCursor QAccessibleTextEdit::textCursor() const | - | ||||||||||||||||||
204 | { | - | ||||||||||||||||||
205 | return textEdit()->textCursor(); never executed: return textEdit()->textCursor(); | 0 | ||||||||||||||||||
206 | } | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | QTextDocument *QAccessibleTextEdit::textDocument() const | - | ||||||||||||||||||
209 | { | - | ||||||||||||||||||
210 | return textEdit()->document(); never executed: return textEdit()->document(); | 0 | ||||||||||||||||||
211 | } | - | ||||||||||||||||||
212 | - | |||||||||||||||||||
213 | void QAccessibleTextEdit::setTextCursor(const QTextCursor &textCursor) | - | ||||||||||||||||||
214 | { | - | ||||||||||||||||||
215 | textEdit()->setTextCursor(textCursor); | - | ||||||||||||||||||
216 | } never executed: end of block | 0 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | QWidget *QAccessibleTextEdit::viewport() const | - | ||||||||||||||||||
219 | { | - | ||||||||||||||||||
220 | return textEdit()->viewport(); never executed: return textEdit()->viewport(); | 0 | ||||||||||||||||||
221 | } | - | ||||||||||||||||||
222 | - | |||||||||||||||||||
223 | QPoint QAccessibleTextEdit::scrollBarPosition() const | - | ||||||||||||||||||
224 | { | - | ||||||||||||||||||
225 | QPoint result; | - | ||||||||||||||||||
226 | result.setX(textEdit()->horizontalScrollBar() ? textEdit()->horizontalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
227 | result.setY(textEdit()->verticalScrollBar() ? textEdit()->verticalScrollBar()->sliderPosition() : 0); | - | ||||||||||||||||||
228 | return result; never executed: return result; | 0 | ||||||||||||||||||
229 | } | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | QString QAccessibleTextEdit::text(QAccessible::Text t) const | - | ||||||||||||||||||
232 | { | - | ||||||||||||||||||
233 | if (t == QAccessible::Value)
| 0 | ||||||||||||||||||
234 | return textEdit()->toPlainText(); never executed: return textEdit()->toPlainText(); | 0 | ||||||||||||||||||
235 | - | |||||||||||||||||||
236 | return QAccessibleWidget::text(t); never executed: return QAccessibleWidget::text(t); | 0 | ||||||||||||||||||
237 | } | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | void QAccessibleTextEdit::setText(QAccessible::Text t, const QString &text) | - | ||||||||||||||||||
240 | { | - | ||||||||||||||||||
241 | if (t != QAccessible::Value) {
| 0 | ||||||||||||||||||
242 | QAccessibleWidget::setText(t, text); | - | ||||||||||||||||||
243 | return; never executed: return; | 0 | ||||||||||||||||||
244 | } | - | ||||||||||||||||||
245 | if (textEdit()->isReadOnly())
| 0 | ||||||||||||||||||
246 | return; never executed: return; | 0 | ||||||||||||||||||
247 | - | |||||||||||||||||||
248 | textEdit()->setText(text); | - | ||||||||||||||||||
249 | } never executed: end of block | 0 | ||||||||||||||||||
250 | - | |||||||||||||||||||
251 | QAccessible::State QAccessibleTextEdit::state() const | - | ||||||||||||||||||
252 | { | - | ||||||||||||||||||
253 | QAccessible::State st = QAccessibleTextWidget::state(); | - | ||||||||||||||||||
254 | if (textEdit()->isReadOnly())
| 0 | ||||||||||||||||||
255 | st.readOnly = true; never executed: st.readOnly = true; | 0 | ||||||||||||||||||
256 | else | - | ||||||||||||||||||
257 | st.editable = true; never executed: st.editable = true; | 0 | ||||||||||||||||||
258 | return st; never executed: return st; | 0 | ||||||||||||||||||
259 | } | - | ||||||||||||||||||
260 | - | |||||||||||||||||||
261 | void *QAccessibleTextEdit::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
262 | { | - | ||||||||||||||||||
263 | if (t == QAccessible::TextInterface)
| 0 | ||||||||||||||||||
264 | return static_cast<QAccessibleTextInterface*>(this); never executed: return static_cast<QAccessibleTextInterface*>(this); | 0 | ||||||||||||||||||
265 | else if (t == QAccessible::EditableTextInterface)
| 0 | ||||||||||||||||||
266 | return static_cast<QAccessibleEditableTextInterface*>(this); never executed: return static_cast<QAccessibleEditableTextInterface*>(this); | 0 | ||||||||||||||||||
267 | return QAccessibleWidget::interface_cast(t); never executed: return QAccessibleWidget::interface_cast(t); | 0 | ||||||||||||||||||
268 | } | - | ||||||||||||||||||
269 | - | |||||||||||||||||||
270 | void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) | - | ||||||||||||||||||
271 | { | - | ||||||||||||||||||
272 | QTextEdit *edit = textEdit(); | - | ||||||||||||||||||
273 | - | |||||||||||||||||||
274 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
275 | cursor.setPosition(startIndex); | - | ||||||||||||||||||
276 | QRect r = edit->cursorRect(cursor); | - | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | cursor.setPosition(endIndex); | - | ||||||||||||||||||
279 | r.setBottomRight(edit->cursorRect(cursor).bottomRight()); | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | r.moveTo(r.x() + edit->horizontalScrollBar()->value(), | - | ||||||||||||||||||
282 | r.y() + edit->verticalScrollBar()->value()); | - | ||||||||||||||||||
283 | - | |||||||||||||||||||
284 | // E V I L, but ensureVisible is not public | - | ||||||||||||||||||
285 | if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r)))
| 0 | ||||||||||||||||||
286 | qWarning("AccessibleTextEdit::scrollToSubstring failed!"); never executed: QMessageLogger(__FILE__, 286, __PRETTY_FUNCTION__).warning("AccessibleTextEdit::scrollToSubstring failed!"); | 0 | ||||||||||||||||||
287 | } never executed: end of block | 0 | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | #endif // QT_NO_TEXTEDIT && QT_NO_CURSOR | - | ||||||||||||||||||
290 | - | |||||||||||||||||||
291 | #ifndef QT_NO_STACKEDWIDGET | - | ||||||||||||||||||
292 | // ======================= QAccessibleStackedWidget ====================== | - | ||||||||||||||||||
293 | QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) | - | ||||||||||||||||||
294 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
295 | { | - | ||||||||||||||||||
296 | Q_ASSERT(qobject_cast<QStackedWidget *>(widget)); | - | ||||||||||||||||||
297 | } never executed: end of block | 0 | ||||||||||||||||||
298 | - | |||||||||||||||||||
299 | QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const | - | ||||||||||||||||||
300 | { | - | ||||||||||||||||||
301 | if (!stackedWidget()->isVisible())
| 0 | ||||||||||||||||||
302 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
303 | QWidget *currentWidget = stackedWidget()->currentWidget(); | - | ||||||||||||||||||
304 | if (!currentWidget)
| 0 | ||||||||||||||||||
305 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
306 | QPoint position = currentWidget->mapFromGlobal(QPoint(x, y)); | - | ||||||||||||||||||
307 | if (currentWidget->rect().contains(position))
| 0 | ||||||||||||||||||
308 | return child(stackedWidget()->currentIndex()); never executed: return child(stackedWidget()->currentIndex()); | 0 | ||||||||||||||||||
309 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
310 | } | - | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | int QAccessibleStackedWidget::childCount() const | - | ||||||||||||||||||
313 | { | - | ||||||||||||||||||
314 | return stackedWidget()->count(); never executed: return stackedWidget()->count(); | 0 | ||||||||||||||||||
315 | } | - | ||||||||||||||||||
316 | - | |||||||||||||||||||
317 | int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
318 | { | - | ||||||||||||||||||
319 | if (!child)
| 0 | ||||||||||||||||||
320 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | QWidget *widget = qobject_cast<QWidget*>(child->object()); | - | ||||||||||||||||||
323 | return stackedWidget()->indexOf(widget); never executed: return stackedWidget()->indexOf(widget); | 0 | ||||||||||||||||||
324 | } | - | ||||||||||||||||||
325 | - | |||||||||||||||||||
326 | QAccessibleInterface *QAccessibleStackedWidget::child(int index) const | - | ||||||||||||||||||
327 | { | - | ||||||||||||||||||
328 | if (index < 0 || index >= stackedWidget()->count())
| 0 | ||||||||||||||||||
329 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
330 | return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); never executed: return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); | 0 | ||||||||||||||||||
331 | } | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | QStackedWidget *QAccessibleStackedWidget::stackedWidget() const | - | ||||||||||||||||||
334 | { | - | ||||||||||||||||||
335 | return static_cast<QStackedWidget *>(object()); never executed: return static_cast<QStackedWidget *>(object()); | 0 | ||||||||||||||||||
336 | } | - | ||||||||||||||||||
337 | #endif // QT_NO_STACKEDWIDGET | - | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | #ifndef QT_NO_TOOLBOX | - | ||||||||||||||||||
340 | // ======================= QAccessibleToolBox ====================== | - | ||||||||||||||||||
341 | QAccessibleToolBox::QAccessibleToolBox(QWidget *widget) | - | ||||||||||||||||||
342 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
343 | { | - | ||||||||||||||||||
344 | Q_ASSERT(qobject_cast<QToolBox *>(widget)); | - | ||||||||||||||||||
345 | } never executed: end of block | 0 | ||||||||||||||||||
346 | - | |||||||||||||||||||
347 | QToolBox * QAccessibleToolBox::toolBox() const | - | ||||||||||||||||||
348 | { | - | ||||||||||||||||||
349 | return static_cast<QToolBox *>(object()); never executed: return static_cast<QToolBox *>(object()); | 0 | ||||||||||||||||||
350 | } | - | ||||||||||||||||||
351 | #endif // QT_NO_TOOLBOX | - | ||||||||||||||||||
352 | - | |||||||||||||||||||
353 | // ======================= QAccessibleMdiArea ====================== | - | ||||||||||||||||||
354 | #ifndef QT_NO_MDIAREA | - | ||||||||||||||||||
355 | QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) | - | ||||||||||||||||||
356 | : QAccessibleWidget(widget, QAccessible::LayeredPane) | - | ||||||||||||||||||
357 | { | - | ||||||||||||||||||
358 | Q_ASSERT(qobject_cast<QMdiArea *>(widget)); | - | ||||||||||||||||||
359 | } never executed: end of block | 0 | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | int QAccessibleMdiArea::childCount() const | - | ||||||||||||||||||
362 | { | - | ||||||||||||||||||
363 | return mdiArea()->subWindowList().count(); never executed: return mdiArea()->subWindowList().count(); | 0 | ||||||||||||||||||
364 | } | - | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | QAccessibleInterface *QAccessibleMdiArea::child(int index) const | - | ||||||||||||||||||
367 | { | - | ||||||||||||||||||
368 | QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList(); | - | ||||||||||||||||||
369 | QWidget *targetObject = subWindows.value(index); | - | ||||||||||||||||||
370 | if (!targetObject)
| 0 | ||||||||||||||||||
371 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
372 | return QAccessible::queryAccessibleInterface(targetObject); never executed: return QAccessible::queryAccessibleInterface(targetObject); | 0 | ||||||||||||||||||
373 | } | - | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | - | |||||||||||||||||||
376 | int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
377 | { | - | ||||||||||||||||||
378 | if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
| 0 | ||||||||||||||||||
379 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
380 | if (QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(child->object())) {
| 0 | ||||||||||||||||||
381 | return mdiArea()->subWindowList().indexOf(window); never executed: return mdiArea()->subWindowList().indexOf(window); | 0 | ||||||||||||||||||
382 | } | - | ||||||||||||||||||
383 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
384 | } | - | ||||||||||||||||||
385 | - | |||||||||||||||||||
386 | QMdiArea *QAccessibleMdiArea::mdiArea() const | - | ||||||||||||||||||
387 | { | - | ||||||||||||||||||
388 | return static_cast<QMdiArea *>(object()); never executed: return static_cast<QMdiArea *>(object()); | 0 | ||||||||||||||||||
389 | } | - | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | // ======================= QAccessibleMdiSubWindow ====================== | - | ||||||||||||||||||
392 | QAccessibleMdiSubWindow::QAccessibleMdiSubWindow(QWidget *widget) | - | ||||||||||||||||||
393 | : QAccessibleWidget(widget, QAccessible::Window) | - | ||||||||||||||||||
394 | { | - | ||||||||||||||||||
395 | Q_ASSERT(qobject_cast<QMdiSubWindow *>(widget)); | - | ||||||||||||||||||
396 | } never executed: end of block | 0 | ||||||||||||||||||
397 | - | |||||||||||||||||||
398 | QString QAccessibleMdiSubWindow::text(QAccessible::Text textType) const | - | ||||||||||||||||||
399 | { | - | ||||||||||||||||||
400 | if (textType == QAccessible::Name) {
| 0 | ||||||||||||||||||
401 | QString title = mdiSubWindow()->windowTitle(); | - | ||||||||||||||||||
402 | title.replace(QLatin1String("[*]"), QLatin1String("")); | - | ||||||||||||||||||
403 | return title; never executed: return title; | 0 | ||||||||||||||||||
404 | } | - | ||||||||||||||||||
405 | return QAccessibleWidget::text(textType); never executed: return QAccessibleWidget::text(textType); | 0 | ||||||||||||||||||
406 | } | - | ||||||||||||||||||
407 | - | |||||||||||||||||||
408 | void QAccessibleMdiSubWindow::setText(QAccessible::Text textType, const QString &text) | - | ||||||||||||||||||
409 | { | - | ||||||||||||||||||
410 | if (textType == QAccessible::Name)
| 0 | ||||||||||||||||||
411 | mdiSubWindow()->setWindowTitle(text); never executed: mdiSubWindow()->setWindowTitle(text); | 0 | ||||||||||||||||||
412 | else | - | ||||||||||||||||||
413 | QAccessibleWidget::setText(textType, text); never executed: QAccessibleWidget::setText(textType, text); | 0 | ||||||||||||||||||
414 | } | - | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | QAccessible::State QAccessibleMdiSubWindow::state() const | - | ||||||||||||||||||
417 | { | - | ||||||||||||||||||
418 | QAccessible::State state; | - | ||||||||||||||||||
419 | state.focusable = true; | - | ||||||||||||||||||
420 | if (!mdiSubWindow()->isMaximized()) {
| 0 | ||||||||||||||||||
421 | state.movable = true; | - | ||||||||||||||||||
422 | state.sizeable = true; | - | ||||||||||||||||||
423 | } never executed: end of block | 0 | ||||||||||||||||||
424 | if (mdiSubWindow()->isAncestorOf(QApplication::focusWidget())
| 0 | ||||||||||||||||||
425 | || QApplication::focusWidget() == mdiSubWindow())
| 0 | ||||||||||||||||||
426 | state.focused = true; never executed: state.focused = true; | 0 | ||||||||||||||||||
427 | if (!mdiSubWindow()->isVisible())
| 0 | ||||||||||||||||||
428 | state.invisible = true; never executed: state.invisible = true; | 0 | ||||||||||||||||||
429 | if (const QWidget *parent = mdiSubWindow()->parentWidget())
| 0 | ||||||||||||||||||
430 | if (!parent->contentsRect().contains(mdiSubWindow()->geometry()))
| 0 | ||||||||||||||||||
431 | state.offscreen = true; never executed: state.offscreen = true; | 0 | ||||||||||||||||||
432 | if (!mdiSubWindow()->isEnabled())
| 0 | ||||||||||||||||||
433 | state.disabled = true; never executed: state.disabled = true; | 0 | ||||||||||||||||||
434 | return state; never executed: return state; | 0 | ||||||||||||||||||
435 | } | - | ||||||||||||||||||
436 | - | |||||||||||||||||||
437 | int QAccessibleMdiSubWindow::childCount() const | - | ||||||||||||||||||
438 | { | - | ||||||||||||||||||
439 | if (mdiSubWindow()->widget())
| 0 | ||||||||||||||||||
440 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
441 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
442 | } | - | ||||||||||||||||||
443 | - | |||||||||||||||||||
444 | QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const | - | ||||||||||||||||||
445 | { | - | ||||||||||||||||||
446 | QMdiSubWindow *source = mdiSubWindow(); | - | ||||||||||||||||||
447 | if (index != 0 || !source->widget())
| 0 | ||||||||||||||||||
448 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | return QAccessible::queryAccessibleInterface(source->widget()); never executed: return QAccessible::queryAccessibleInterface(source->widget()); | 0 | ||||||||||||||||||
451 | } | - | ||||||||||||||||||
452 | - | |||||||||||||||||||
453 | int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
454 | { | - | ||||||||||||||||||
455 | if (child && child->object() && child->object() == mdiSubWindow()->widget())
| 0 | ||||||||||||||||||
456 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
457 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
458 | } | - | ||||||||||||||||||
459 | - | |||||||||||||||||||
460 | QRect QAccessibleMdiSubWindow::rect() const | - | ||||||||||||||||||
461 | { | - | ||||||||||||||||||
462 | if (mdiSubWindow()->isHidden())
| 0 | ||||||||||||||||||
463 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
464 | if (!mdiSubWindow()->parent())
| 0 | ||||||||||||||||||
465 | return QAccessibleWidget::rect(); never executed: return QAccessibleWidget::rect(); | 0 | ||||||||||||||||||
466 | const QPoint pos = mdiSubWindow()->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
467 | return QRect(pos, mdiSubWindow()->size()); never executed: return QRect(pos, mdiSubWindow()->size()); | 0 | ||||||||||||||||||
468 | } | - | ||||||||||||||||||
469 | - | |||||||||||||||||||
470 | QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const | - | ||||||||||||||||||
471 | { | - | ||||||||||||||||||
472 | return static_cast<QMdiSubWindow *>(object()); never executed: return static_cast<QMdiSubWindow *>(object()); | 0 | ||||||||||||||||||
473 | } | - | ||||||||||||||||||
474 | #endif // QT_NO_MDIAREA | - | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | #ifndef QT_NO_DIALOGBUTTONBOX | - | ||||||||||||||||||
477 | // ======================= QAccessibleDialogButtonBox ====================== | - | ||||||||||||||||||
478 | QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget) | - | ||||||||||||||||||
479 | : QAccessibleWidget(widget, QAccessible::Grouping) | - | ||||||||||||||||||
480 | { | - | ||||||||||||||||||
481 | Q_ASSERT(qobject_cast<QDialogButtonBox*>(widget)); | - | ||||||||||||||||||
482 | } never executed: end of block | 0 | ||||||||||||||||||
483 | - | |||||||||||||||||||
484 | #endif // QT_NO_DIALOGBUTTONBOX | - | ||||||||||||||||||
485 | - | |||||||||||||||||||
486 | #if !defined(QT_NO_TEXTBROWSER) && !defined(QT_NO_CURSOR) | - | ||||||||||||||||||
487 | QAccessibleTextBrowser::QAccessibleTextBrowser(QWidget *widget) | - | ||||||||||||||||||
488 | : QAccessibleTextEdit(widget) | - | ||||||||||||||||||
489 | { | - | ||||||||||||||||||
490 | Q_ASSERT(qobject_cast<QTextBrowser *>(widget)); | - | ||||||||||||||||||
491 | } never executed: end of block | 0 | ||||||||||||||||||
492 | - | |||||||||||||||||||
493 | QAccessible::Role QAccessibleTextBrowser::role() const | - | ||||||||||||||||||
494 | { | - | ||||||||||||||||||
495 | return QAccessible::StaticText; never executed: return QAccessible::StaticText; | 0 | ||||||||||||||||||
496 | } | - | ||||||||||||||||||
497 | #endif // QT_NO_TEXTBROWSER && QT_NO_CURSOR | - | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | #ifndef QT_NO_CALENDARWIDGET | - | ||||||||||||||||||
500 | // ===================== QAccessibleCalendarWidget ======================== | - | ||||||||||||||||||
501 | QAccessibleCalendarWidget::QAccessibleCalendarWidget(QWidget *widget) | - | ||||||||||||||||||
502 | : QAccessibleWidget(widget, QAccessible::Table) | - | ||||||||||||||||||
503 | { | - | ||||||||||||||||||
504 | Q_ASSERT(qobject_cast<QCalendarWidget *>(widget)); | - | ||||||||||||||||||
505 | } never executed: end of block | 0 | ||||||||||||||||||
506 | - | |||||||||||||||||||
507 | int QAccessibleCalendarWidget::childCount() const | - | ||||||||||||||||||
508 | { | - | ||||||||||||||||||
509 | return calendarWidget()->isNavigationBarVisible() ? 2 : 1; never executed: return calendarWidget()->isNavigationBarVisible() ? 2 : 1;
| 0 | ||||||||||||||||||
510 | } | - | ||||||||||||||||||
511 | - | |||||||||||||||||||
512 | int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
513 | { | - | ||||||||||||||||||
514 | if (!child || !child->object() || childCount() <= 0)
| 0 | ||||||||||||||||||
515 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
516 | if (qobject_cast<QAbstractItemView *>(child->object()))
| 0 | ||||||||||||||||||
517 | return childCount() - 1; // FIXME never executed: return childCount() - 1; | 0 | ||||||||||||||||||
518 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
519 | } | - | ||||||||||||||||||
520 | - | |||||||||||||||||||
521 | QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const | - | ||||||||||||||||||
522 | { | - | ||||||||||||||||||
523 | if (index < 0 || index >= childCount())
| 0 | ||||||||||||||||||
524 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
525 | - | |||||||||||||||||||
526 | if (childCount() > 1 && index == 0)
| 0 | ||||||||||||||||||
527 | return QAccessible::queryAccessibleInterface(navigationBar()); never executed: return QAccessible::queryAccessibleInterface(navigationBar()); | 0 | ||||||||||||||||||
528 | - | |||||||||||||||||||
529 | return QAccessible::queryAccessibleInterface(calendarView()); never executed: return QAccessible::queryAccessibleInterface(calendarView()); | 0 | ||||||||||||||||||
530 | } | - | ||||||||||||||||||
531 | - | |||||||||||||||||||
532 | QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const | - | ||||||||||||||||||
533 | { | - | ||||||||||||||||||
534 | return static_cast<QCalendarWidget *>(object()); never executed: return static_cast<QCalendarWidget *>(object()); | 0 | ||||||||||||||||||
535 | } | - | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | QAbstractItemView *QAccessibleCalendarWidget::calendarView() const | - | ||||||||||||||||||
538 | { | - | ||||||||||||||||||
539 | foreach (QObject *child, calendarWidget()->children()) { | - | ||||||||||||||||||
540 | if (child->objectName() == QLatin1String("qt_calendar_calendarview"))
| 0 | ||||||||||||||||||
541 | return static_cast<QAbstractItemView *>(child); never executed: return static_cast<QAbstractItemView *>(child); | 0 | ||||||||||||||||||
542 | } never executed: end of block | 0 | ||||||||||||||||||
543 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
544 | } | - | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | QWidget *QAccessibleCalendarWidget::navigationBar() const | - | ||||||||||||||||||
547 | { | - | ||||||||||||||||||
548 | foreach (QObject *child, calendarWidget()->children()) { | - | ||||||||||||||||||
549 | if (child->objectName() == QLatin1String("qt_calendar_navigationbar"))
| 0 | ||||||||||||||||||
550 | return static_cast<QWidget *>(child); never executed: return static_cast<QWidget *>(child); | 0 | ||||||||||||||||||
551 | } never executed: end of block | 0 | ||||||||||||||||||
552 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
553 | } | - | ||||||||||||||||||
554 | #endif // QT_NO_CALENDARWIDGET | - | ||||||||||||||||||
555 | - | |||||||||||||||||||
556 | #ifndef QT_NO_DOCKWIDGET | - | ||||||||||||||||||
557 | - | |||||||||||||||||||
558 | // Dock Widget - order of children: | - | ||||||||||||||||||
559 | // - Content widget | - | ||||||||||||||||||
560 | // - Float button | - | ||||||||||||||||||
561 | // - Close button | - | ||||||||||||||||||
562 | // If there is a custom title bar widget, that one becomes child 1, after the content 0 | - | ||||||||||||||||||
563 | // (in that case the buttons are ignored) | - | ||||||||||||||||||
564 | QAccessibleDockWidget::QAccessibleDockWidget(QWidget *widget) | - | ||||||||||||||||||
565 | : QAccessibleWidget(widget, QAccessible::Window) | - | ||||||||||||||||||
566 | { | - | ||||||||||||||||||
567 | } never executed: end of block | 0 | ||||||||||||||||||
568 | - | |||||||||||||||||||
569 | QDockWidgetLayout *QAccessibleDockWidget::dockWidgetLayout() const | - | ||||||||||||||||||
570 | { | - | ||||||||||||||||||
571 | return qobject_cast<QDockWidgetLayout*>(dockWidget()->layout()); never executed: return qobject_cast<QDockWidgetLayout*>(dockWidget()->layout()); | 0 | ||||||||||||||||||
572 | } | - | ||||||||||||||||||
573 | - | |||||||||||||||||||
574 | int QAccessibleDockWidget::childCount() const | - | ||||||||||||||||||
575 | { | - | ||||||||||||||||||
576 | if (dockWidget()->titleBarWidget()) {
| 0 | ||||||||||||||||||
577 | return dockWidget()->widget() ? 2 : 1; never executed: return dockWidget()->widget() ? 2 : 1;
| 0 | ||||||||||||||||||
578 | } | - | ||||||||||||||||||
579 | return dockWidgetLayout()->count(); never executed: return dockWidgetLayout()->count(); | 0 | ||||||||||||||||||
580 | } | - | ||||||||||||||||||
581 | - | |||||||||||||||||||
582 | QAccessibleInterface *QAccessibleDockWidget::child(int index) const | - | ||||||||||||||||||
583 | { | - | ||||||||||||||||||
584 | if (dockWidget()->titleBarWidget()) {
| 0 | ||||||||||||||||||
585 | if ((!dockWidget()->widget() && index == 0) || (index == 1))
| 0 | ||||||||||||||||||
586 | return QAccessible::queryAccessibleInterface(dockWidget()->titleBarWidget()); never executed: return QAccessible::queryAccessibleInterface(dockWidget()->titleBarWidget()); | 0 | ||||||||||||||||||
587 | if (index == 0)
| 0 | ||||||||||||||||||
588 | return QAccessible::queryAccessibleInterface(dockWidget()->widget()); never executed: return QAccessible::queryAccessibleInterface(dockWidget()->widget()); | 0 | ||||||||||||||||||
589 | } else { never executed: end of block | 0 | ||||||||||||||||||
590 | QLayoutItem *item = dockWidgetLayout()->itemAt(index); | - | ||||||||||||||||||
591 | if (item)
| 0 | ||||||||||||||||||
592 | return QAccessible::queryAccessibleInterface(item->widget()); never executed: return QAccessible::queryAccessibleInterface(item->widget()); | 0 | ||||||||||||||||||
593 | } never executed: end of block | 0 | ||||||||||||||||||
594 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
595 | } | - | ||||||||||||||||||
596 | - | |||||||||||||||||||
597 | int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const | - | ||||||||||||||||||
598 | { | - | ||||||||||||||||||
599 | if (!child || !child->object() || child->object()->parent() != object())
| 0 | ||||||||||||||||||
600 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
601 | - | |||||||||||||||||||
602 | if (dockWidget()->titleBarWidget() == child->object()) {
| 0 | ||||||||||||||||||
603 | return dockWidget()->widget() ? 1 : 0; never executed: return dockWidget()->widget() ? 1 : 0;
| 0 | ||||||||||||||||||
604 | } | - | ||||||||||||||||||
605 | - | |||||||||||||||||||
606 | return dockWidgetLayout()->indexOf(qobject_cast<QWidget*>(child->object())); never executed: return dockWidgetLayout()->indexOf(qobject_cast<QWidget*>(child->object())); | 0 | ||||||||||||||||||
607 | } | - | ||||||||||||||||||
608 | - | |||||||||||||||||||
609 | QRect QAccessibleDockWidget::rect() const | - | ||||||||||||||||||
610 | { | - | ||||||||||||||||||
611 | QRect rect; | - | ||||||||||||||||||
612 | - | |||||||||||||||||||
613 | if (dockWidget()->isFloating()) {
| 0 | ||||||||||||||||||
614 | rect = dockWidget()->frameGeometry(); | - | ||||||||||||||||||
615 | } else { never executed: end of block | 0 | ||||||||||||||||||
616 | rect = dockWidget()->rect(); | - | ||||||||||||||||||
617 | rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft())); | - | ||||||||||||||||||
618 | } never executed: end of block | 0 | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
621 | } | - | ||||||||||||||||||
622 | - | |||||||||||||||||||
623 | QDockWidget *QAccessibleDockWidget::dockWidget() const | - | ||||||||||||||||||
624 | { | - | ||||||||||||||||||
625 | return static_cast<QDockWidget *>(object()); never executed: return static_cast<QDockWidget *>(object()); | 0 | ||||||||||||||||||
626 | } | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | QString QAccessibleDockWidget::text(QAccessible::Text t) const | - | ||||||||||||||||||
629 | { | - | ||||||||||||||||||
630 | if (t == QAccessible::Name) {
| 0 | ||||||||||||||||||
631 | return qt_accStripAmp(dockWidget()->windowTitle()); never executed: return qt_accStripAmp(dockWidget()->windowTitle()); | 0 | ||||||||||||||||||
632 | } else if (t == QAccessible::Accelerator) {
| 0 | ||||||||||||||||||
633 | return qt_accHotKey(dockWidget()->windowTitle()); never executed: return qt_accHotKey(dockWidget()->windowTitle()); | 0 | ||||||||||||||||||
634 | } | - | ||||||||||||||||||
635 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
636 | } | - | ||||||||||||||||||
637 | #endif // QT_NO_DOCKWIDGET | - | ||||||||||||||||||
638 | - | |||||||||||||||||||
639 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
640 | - | |||||||||||||||||||
641 | QAccessibleTextWidget::QAccessibleTextWidget(QWidget *o, QAccessible::Role r, const QString &name): | - | ||||||||||||||||||
642 | QAccessibleWidget(o, r, name) | - | ||||||||||||||||||
643 | { | - | ||||||||||||||||||
644 | - | |||||||||||||||||||
645 | } never executed: end of block | 0 | ||||||||||||||||||
646 | - | |||||||||||||||||||
647 | QAccessible::State QAccessibleTextWidget::state() const | - | ||||||||||||||||||
648 | { | - | ||||||||||||||||||
649 | QAccessible::State s = QAccessibleWidget::state(); | - | ||||||||||||||||||
650 | s.selectableText = true; | - | ||||||||||||||||||
651 | s.multiLine = true; | - | ||||||||||||||||||
652 | return s; never executed: return s; | 0 | ||||||||||||||||||
653 | } | - | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | QRect QAccessibleTextWidget::characterRect(int offset) const | - | ||||||||||||||||||
656 | { | - | ||||||||||||||||||
657 | QTextBlock block = textDocument()->findBlock(offset); | - | ||||||||||||||||||
658 | if (!block.isValid())
| 0 | ||||||||||||||||||
659 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
660 | - | |||||||||||||||||||
661 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||
662 | QPointF layoutPosition = layout->position(); | - | ||||||||||||||||||
663 | int relativeOffset = offset - block.position(); | - | ||||||||||||||||||
664 | QTextLine line = layout->lineForTextPosition(relativeOffset); | - | ||||||||||||||||||
665 | - | |||||||||||||||||||
666 | QRect r; | - | ||||||||||||||||||
667 | - | |||||||||||||||||||
668 | if (line.isValid()) {
| 0 | ||||||||||||||||||
669 | qreal x = line.cursorToX(relativeOffset); | - | ||||||||||||||||||
670 | - | |||||||||||||||||||
671 | QTextCharFormat format; | - | ||||||||||||||||||
672 | QTextBlock::iterator iter = block.begin(); | - | ||||||||||||||||||
673 | if (iter.atEnd())
| 0 | ||||||||||||||||||
674 | format = block.charFormat(); never executed: format = block.charFormat(); | 0 | ||||||||||||||||||
675 | else { | - | ||||||||||||||||||
676 | while (!iter.atEnd() && !iter.fragment().contains(offset))
| 0 | ||||||||||||||||||
677 | ++iter; never executed: ++iter; | 0 | ||||||||||||||||||
678 | if (iter.atEnd()) // newline should have same format as preceding character
| 0 | ||||||||||||||||||
679 | --iter; never executed: --iter; | 0 | ||||||||||||||||||
680 | format = iter.fragment().charFormat(); | - | ||||||||||||||||||
681 | } never executed: end of block | 0 | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | QFontMetrics fm(format.font()); | - | ||||||||||||||||||
684 | const QString ch = text(offset, offset + 1); | - | ||||||||||||||||||
685 | if (!ch.isEmpty()) {
| 0 | ||||||||||||||||||
686 | int w = fm.width(ch); | - | ||||||||||||||||||
687 | int h = fm.height(); | - | ||||||||||||||||||
688 | r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y() + line.ascent() + fm.descent() - h, | - | ||||||||||||||||||
689 | w, h); | - | ||||||||||||||||||
690 | r.moveTo(viewport()->mapToGlobal(r.topLeft())); | - | ||||||||||||||||||
691 | } never executed: end of block | 0 | ||||||||||||||||||
692 | r.translate(-scrollBarPosition()); | - | ||||||||||||||||||
693 | } never executed: end of block | 0 | ||||||||||||||||||
694 | - | |||||||||||||||||||
695 | return r; never executed: return r; | 0 | ||||||||||||||||||
696 | } | - | ||||||||||||||||||
697 | - | |||||||||||||||||||
698 | int QAccessibleTextWidget::offsetAtPoint(const QPoint &point) const | - | ||||||||||||||||||
699 | { | - | ||||||||||||||||||
700 | QPoint p = viewport()->mapFromGlobal(point); | - | ||||||||||||||||||
701 | // convert to document coordinates | - | ||||||||||||||||||
702 | p += scrollBarPosition(); | - | ||||||||||||||||||
703 | return textDocument()->documentLayout()->hitTest(p, Qt::ExactHit); never executed: return textDocument()->documentLayout()->hitTest(p, Qt::ExactHit); | 0 | ||||||||||||||||||
704 | } | - | ||||||||||||||||||
705 | - | |||||||||||||||||||
706 | int QAccessibleTextWidget::selectionCount() const | - | ||||||||||||||||||
707 | { | - | ||||||||||||||||||
708 | return textCursor().hasSelection() ? 1 : 0; never executed: return textCursor().hasSelection() ? 1 : 0;
| 0 | ||||||||||||||||||
709 | } | - | ||||||||||||||||||
710 | - | |||||||||||||||||||
711 | QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *endOffset) const | - | ||||||||||||||||||
712 | { | - | ||||||||||||||||||
713 | /* The list of attributes can be found at: | - | ||||||||||||||||||
714 | http://linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes | - | ||||||||||||||||||
715 | */ | - | ||||||||||||||||||
716 | - | |||||||||||||||||||
717 | // IAccessible2 defines -1 as length and -2 as cursor position | - | ||||||||||||||||||
718 | if (offset == -2)
| 0 | ||||||||||||||||||
719 | offset = cursorPosition(); never executed: offset = cursorPosition(); | 0 | ||||||||||||||||||
720 | - | |||||||||||||||||||
721 | const int charCount = characterCount(); | - | ||||||||||||||||||
722 | - | |||||||||||||||||||
723 | // -1 doesn't make much sense here, but it's better to return something | - | ||||||||||||||||||
724 | // screen readers may ask for text attributes at the cursor pos which may be equal to length | - | ||||||||||||||||||
725 | if (offset == -1 || offset == charCount)
| 0 | ||||||||||||||||||
726 | offset = charCount - 1; never executed: offset = charCount - 1; | 0 | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | if (offset < 0 || offset > charCount) {
| 0 | ||||||||||||||||||
729 | *startOffset = -1; | - | ||||||||||||||||||
730 | *endOffset = -1; | - | ||||||||||||||||||
731 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
732 | } | - | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | - | |||||||||||||||||||
735 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
736 | cursor.setPosition(offset); | - | ||||||||||||||||||
737 | QTextBlock block = cursor.block(); | - | ||||||||||||||||||
738 | - | |||||||||||||||||||
739 | int blockStart = block.position(); | - | ||||||||||||||||||
740 | int blockEnd = blockStart + block.length(); | - | ||||||||||||||||||
741 | - | |||||||||||||||||||
742 | QTextBlock::iterator iter = block.begin(); | - | ||||||||||||||||||
743 | int lastFragmentIndex = blockStart; | - | ||||||||||||||||||
744 | while (!iter.atEnd()) {
| 0 | ||||||||||||||||||
745 | QTextFragment f = iter.fragment(); | - | ||||||||||||||||||
746 | if (f.contains(offset))
| 0 | ||||||||||||||||||
747 | break; never executed: break; | 0 | ||||||||||||||||||
748 | lastFragmentIndex = f.position() + f.length(); | - | ||||||||||||||||||
749 | ++iter; | - | ||||||||||||||||||
750 | } never executed: end of block | 0 | ||||||||||||||||||
751 | - | |||||||||||||||||||
752 | QTextCharFormat charFormat; | - | ||||||||||||||||||
753 | if (!iter.atEnd()) {
| 0 | ||||||||||||||||||
754 | QTextFragment fragment = iter.fragment(); | - | ||||||||||||||||||
755 | charFormat = fragment.charFormat(); | - | ||||||||||||||||||
756 | int pos = fragment.position(); | - | ||||||||||||||||||
757 | // text block and fragment may overlap, use the smallest common range | - | ||||||||||||||||||
758 | *startOffset = qMax(pos, blockStart); | - | ||||||||||||||||||
759 | *endOffset = qMin(pos + fragment.length(), blockEnd); | - | ||||||||||||||||||
760 | } else { never executed: end of block | 0 | ||||||||||||||||||
761 | charFormat = block.charFormat(); | - | ||||||||||||||||||
762 | *startOffset = lastFragmentIndex; | - | ||||||||||||||||||
763 | *endOffset = blockEnd; | - | ||||||||||||||||||
764 | } never executed: end of block | 0 | ||||||||||||||||||
765 | Q_ASSERT(*startOffset <= offset); | - | ||||||||||||||||||
766 | Q_ASSERT(*endOffset >= offset); | - | ||||||||||||||||||
767 | - | |||||||||||||||||||
768 | QTextBlockFormat blockFormat = cursor.blockFormat(); | - | ||||||||||||||||||
769 | - | |||||||||||||||||||
770 | QMap<QByteArray, QString> attrs; | - | ||||||||||||||||||
771 | QString family = charFormat.font().family(); | - | ||||||||||||||||||
772 | if (!family.isEmpty()) {
| 0 | ||||||||||||||||||
773 | family = family.replace('\\',QStringLiteral("\\\\")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
774 | family = family.replace(':',QStringLiteral("\\:")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
775 | family = family.replace(',',QStringLiteral("\\,")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
776 | family = family.replace('=',QStringLiteral("\\=")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
777 | family = family.replace(';',QStringLiteral("\\;")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
778 | family = family.replace('\"',QStringLiteral("\\\"")); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
779 | attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family); | - | ||||||||||||||||||
780 | } never executed: end of block | 0 | ||||||||||||||||||
781 | - | |||||||||||||||||||
782 | int fontSize = int(charFormat.font().pointSize()); | - | ||||||||||||||||||
783 | if (fontSize)
| 0 | ||||||||||||||||||
784 | attrs["font-size"] = QString::fromLatin1("%1pt").arg(fontSize); never executed: attrs["font-size"] = QString::fromLatin1("%1pt").arg(fontSize); | 0 | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | //Different weight values are not handled | - | ||||||||||||||||||
787 | attrs["font-weight"] = QString::fromLatin1(charFormat.font().weight() > QFont::Normal ? "bold" : "normal"); | - | ||||||||||||||||||
788 | - | |||||||||||||||||||
789 | QFont::Style style = charFormat.font().style(); | - | ||||||||||||||||||
790 | attrs["font-style"] = QString::fromLatin1((style == QFont::StyleItalic) ? "italic" : ((style == QFont::StyleOblique) ? "oblique": "normal")); | - | ||||||||||||||||||
791 | - | |||||||||||||||||||
792 | QTextCharFormat::UnderlineStyle underlineStyle = charFormat.underlineStyle(); | - | ||||||||||||||||||
793 | if (underlineStyle == QTextCharFormat::NoUnderline && charFormat.font().underline()) // underline could still be set in the default font
| 0 | ||||||||||||||||||
794 | underlineStyle = QTextCharFormat::SingleUnderline; never executed: underlineStyle = QTextCharFormat::SingleUnderline; | 0 | ||||||||||||||||||
795 | QString underlineStyleValue; | - | ||||||||||||||||||
796 | switch (underlineStyle) { | - | ||||||||||||||||||
797 | case QTextCharFormat::NoUnderline: never executed: case QTextCharFormat::NoUnderline: | 0 | ||||||||||||||||||
798 | break; never executed: break; | 0 | ||||||||||||||||||
799 | case QTextCharFormat::SingleUnderline: never executed: case QTextCharFormat::SingleUnderline: | 0 | ||||||||||||||||||
800 | underlineStyleValue = QStringLiteral("solid"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
801 | break; never executed: break; | 0 | ||||||||||||||||||
802 | case QTextCharFormat::DashUnderline: never executed: case QTextCharFormat::DashUnderline: | 0 | ||||||||||||||||||
803 | underlineStyleValue = QStringLiteral("dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
804 | break; never executed: break; | 0 | ||||||||||||||||||
805 | case QTextCharFormat::DotLine: never executed: case QTextCharFormat::DotLine: | 0 | ||||||||||||||||||
806 | underlineStyleValue = QStringLiteral("dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
807 | break; never executed: break; | 0 | ||||||||||||||||||
808 | case QTextCharFormat::DashDotLine: never executed: case QTextCharFormat::DashDotLine: | 0 | ||||||||||||||||||
809 | underlineStyleValue = QStringLiteral("dot-dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
810 | break; never executed: break; | 0 | ||||||||||||||||||
811 | case QTextCharFormat::DashDotDotLine: never executed: case QTextCharFormat::DashDotDotLine: | 0 | ||||||||||||||||||
812 | underlineStyleValue = QStringLiteral("dot-dot-dash"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
813 | break; never executed: break; | 0 | ||||||||||||||||||
814 | case QTextCharFormat::WaveUnderline: never executed: case QTextCharFormat::WaveUnderline: | 0 | ||||||||||||||||||
815 | underlineStyleValue = QStringLiteral("wave"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
816 | break; never executed: break; | 0 | ||||||||||||||||||
817 | case QTextCharFormat::SpellCheckUnderline: never executed: case QTextCharFormat::SpellCheckUnderline: | 0 | ||||||||||||||||||
818 | underlineStyleValue = QStringLiteral("wave"); // this is not correct, but provides good approximation at least never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
819 | break; never executed: break; | 0 | ||||||||||||||||||
820 | default: never executed: default: | 0 | ||||||||||||||||||
821 | qWarning() << "Unknown QTextCharFormat::​UnderlineStyle value " << underlineStyle << " could not be translated to IAccessible2 value"; | - | ||||||||||||||||||
822 | break; never executed: break; | 0 | ||||||||||||||||||
823 | } | - | ||||||||||||||||||
824 | if (!underlineStyleValue.isNull()) {
| 0 | ||||||||||||||||||
825 | attrs["text-underline-style"] = underlineStyleValue; | - | ||||||||||||||||||
826 | attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
827 | } // else both are "none" which is the default - no need to set them never executed: end of block | 0 | ||||||||||||||||||
828 | - | |||||||||||||||||||
829 | if (block.textDirection() == Qt::RightToLeft)
| 0 | ||||||||||||||||||
830 | attrs["writing-mode"] = QStringLiteral("rl"); never executed: attrs["writing-mode"] = ([]() -> QString { enum { Size = sizeof(u"" "rl")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "rl" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
831 | - | |||||||||||||||||||
832 | QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment(); | - | ||||||||||||||||||
833 | attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" )); | - | ||||||||||||||||||
834 | - | |||||||||||||||||||
835 | QBrush background = charFormat.background(); | - | ||||||||||||||||||
836 | if (background.style() == Qt::SolidPattern) {
| 0 | ||||||||||||||||||
837 | attrs["background-color"] = QString::fromLatin1("rgb(%1,%2,%3)").arg(background.color().red()).arg(background.color().green()).arg(background.color().blue()); | - | ||||||||||||||||||
838 | } never executed: end of block | 0 | ||||||||||||||||||
839 | - | |||||||||||||||||||
840 | QBrush foreground = charFormat.foreground(); | - | ||||||||||||||||||
841 | if (foreground.style() == Qt::SolidPattern) {
| 0 | ||||||||||||||||||
842 | attrs["color"] = QString::fromLatin1("rgb(%1,%2,%3)").arg(foreground.color().red()).arg(foreground.color().green()).arg(foreground.color().blue()); | - | ||||||||||||||||||
843 | } never executed: end of block | 0 | ||||||||||||||||||
844 | - | |||||||||||||||||||
845 | switch (blockFormat.alignment() & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter | Qt::AlignJustify)) { | - | ||||||||||||||||||
846 | case Qt::AlignLeft: never executed: case Qt::AlignLeft: | 0 | ||||||||||||||||||
847 | attrs["text-align"] = QStringLiteral("left"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
848 | break; never executed: break; | 0 | ||||||||||||||||||
849 | case Qt::AlignRight: never executed: case Qt::AlignRight: | 0 | ||||||||||||||||||
850 | attrs["text-align"] = QStringLiteral("right"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
851 | break; never executed: break; | 0 | ||||||||||||||||||
852 | case Qt::AlignHCenter: never executed: case Qt::AlignHCenter: | 0 | ||||||||||||||||||
853 | attrs["text-align"] = QStringLiteral("center"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
854 | break; never executed: break; | 0 | ||||||||||||||||||
855 | case Qt::AlignJustify: never executed: case Qt::AlignJustify: | 0 | ||||||||||||||||||
856 | attrs["text-align"] = QStringLiteral("justify"); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
857 | break; never executed: break; | 0 | ||||||||||||||||||
858 | } | - | ||||||||||||||||||
859 | - | |||||||||||||||||||
860 | QString result; | - | ||||||||||||||||||
861 | foreach (const QByteArray &attributeName, attrs.keys()) { | - | ||||||||||||||||||
862 | result.append(QString::fromLatin1(attributeName)).append(':').append(attrs[attributeName]).append(';'); | - | ||||||||||||||||||
863 | } never executed: end of block | 0 | ||||||||||||||||||
864 | - | |||||||||||||||||||
865 | return result; never executed: return result; | 0 | ||||||||||||||||||
866 | } | - | ||||||||||||||||||
867 | - | |||||||||||||||||||
868 | int QAccessibleTextWidget::cursorPosition() const | - | ||||||||||||||||||
869 | { | - | ||||||||||||||||||
870 | return textCursor().position(); never executed: return textCursor().position(); | 0 | ||||||||||||||||||
871 | } | - | ||||||||||||||||||
872 | - | |||||||||||||||||||
873 | void QAccessibleTextWidget::selection(int selectionIndex, int *startOffset, int *endOffset) const | - | ||||||||||||||||||
874 | { | - | ||||||||||||||||||
875 | *startOffset = *endOffset = 0; | - | ||||||||||||||||||
876 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
877 | - | |||||||||||||||||||
878 | if (selectionIndex != 0 || !cursor.hasSelection())
| 0 | ||||||||||||||||||
879 | return; never executed: return; | 0 | ||||||||||||||||||
880 | - | |||||||||||||||||||
881 | *startOffset = cursor.selectionStart(); | - | ||||||||||||||||||
882 | *endOffset = cursor.selectionEnd(); | - | ||||||||||||||||||
883 | } never executed: end of block | 0 | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | QString QAccessibleTextWidget::text(int startOffset, int endOffset) const | - | ||||||||||||||||||
886 | { | - | ||||||||||||||||||
887 | QTextCursor cursor(textCursor()); | - | ||||||||||||||||||
888 | - | |||||||||||||||||||
889 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
890 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
891 | - | |||||||||||||||||||
892 | return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); never executed: return cursor.selectedText().replace(QChar(QChar::ParagraphSeparator), QLatin1Char('\n')); | 0 | ||||||||||||||||||
893 | } | - | ||||||||||||||||||
894 | - | |||||||||||||||||||
895 | QPoint QAccessibleTextWidget::scrollBarPosition() const | - | ||||||||||||||||||
896 | { | - | ||||||||||||||||||
897 | return QPoint(0, 0); never executed: return QPoint(0, 0); | 0 | ||||||||||||||||||
898 | } | - | ||||||||||||||||||
899 | - | |||||||||||||||||||
900 | - | |||||||||||||||||||
901 | QString QAccessibleTextWidget::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
902 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
903 | { | - | ||||||||||||||||||
904 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
905 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
908 | cursor.setPosition(offset); | - | ||||||||||||||||||
909 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
910 | cursor.setPosition(boundaries.first - 1); | - | ||||||||||||||||||
911 | boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
912 | - | |||||||||||||||||||
913 | *startOffset = boundaries.first; | - | ||||||||||||||||||
914 | *endOffset = boundaries.second; | - | ||||||||||||||||||
915 | - | |||||||||||||||||||
916 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
917 | } | - | ||||||||||||||||||
918 | - | |||||||||||||||||||
919 | - | |||||||||||||||||||
920 | QString QAccessibleTextWidget::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
921 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
922 | { | - | ||||||||||||||||||
923 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
924 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
925 | - | |||||||||||||||||||
926 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
927 | cursor.setPosition(offset); | - | ||||||||||||||||||
928 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
929 | cursor.setPosition(boundaries.second); | - | ||||||||||||||||||
930 | boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
931 | - | |||||||||||||||||||
932 | *startOffset = boundaries.first; | - | ||||||||||||||||||
933 | *endOffset = boundaries.second; | - | ||||||||||||||||||
934 | - | |||||||||||||||||||
935 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
936 | } | - | ||||||||||||||||||
937 | - | |||||||||||||||||||
938 | QString QAccessibleTextWidget::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - | ||||||||||||||||||
939 | int *startOffset, int *endOffset) const | - | ||||||||||||||||||
940 | { | - | ||||||||||||||||||
941 | Q_ASSERT(startOffset); | - | ||||||||||||||||||
942 | Q_ASSERT(endOffset); | - | ||||||||||||||||||
943 | - | |||||||||||||||||||
944 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
945 | cursor.setPosition(offset); | - | ||||||||||||||||||
946 | QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); | - | ||||||||||||||||||
947 | - | |||||||||||||||||||
948 | *startOffset = boundaries.first; | - | ||||||||||||||||||
949 | *endOffset = boundaries.second; | - | ||||||||||||||||||
950 | - | |||||||||||||||||||
951 | return text(boundaries.first, boundaries.second); never executed: return text(boundaries.first, boundaries.second); | 0 | ||||||||||||||||||
952 | } | - | ||||||||||||||||||
953 | - | |||||||||||||||||||
954 | void QAccessibleTextWidget::setCursorPosition(int position) | - | ||||||||||||||||||
955 | { | - | ||||||||||||||||||
956 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
957 | cursor.setPosition(position); | - | ||||||||||||||||||
958 | setTextCursor(cursor); | - | ||||||||||||||||||
959 | } never executed: end of block | 0 | ||||||||||||||||||
960 | - | |||||||||||||||||||
961 | void QAccessibleTextWidget::addSelection(int startOffset, int endOffset) | - | ||||||||||||||||||
962 | { | - | ||||||||||||||||||
963 | setSelection(0, startOffset, endOffset); | - | ||||||||||||||||||
964 | } never executed: end of block | 0 | ||||||||||||||||||
965 | - | |||||||||||||||||||
966 | void QAccessibleTextWidget::removeSelection(int selectionIndex) | - | ||||||||||||||||||
967 | { | - | ||||||||||||||||||
968 | if (selectionIndex != 0)
| 0 | ||||||||||||||||||
969 | return; never executed: return; | 0 | ||||||||||||||||||
970 | - | |||||||||||||||||||
971 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
972 | cursor.clearSelection(); | - | ||||||||||||||||||
973 | setTextCursor(cursor); | - | ||||||||||||||||||
974 | } never executed: end of block | 0 | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | void QAccessibleTextWidget::setSelection(int selectionIndex, int startOffset, int endOffset) | - | ||||||||||||||||||
977 | { | - | ||||||||||||||||||
978 | if (selectionIndex != 0)
| 0 | ||||||||||||||||||
979 | return; never executed: return; | 0 | ||||||||||||||||||
980 | - | |||||||||||||||||||
981 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
982 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
983 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
984 | setTextCursor(cursor); | - | ||||||||||||||||||
985 | } never executed: end of block | 0 | ||||||||||||||||||
986 | - | |||||||||||||||||||
987 | int QAccessibleTextWidget::characterCount() const | - | ||||||||||||||||||
988 | { | - | ||||||||||||||||||
989 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
990 | cursor.movePosition(QTextCursor::End); | - | ||||||||||||||||||
991 | return cursor.position(); never executed: return cursor.position(); | 0 | ||||||||||||||||||
992 | } | - | ||||||||||||||||||
993 | - | |||||||||||||||||||
994 | QTextCursor QAccessibleTextWidget::textCursorForRange(int startOffset, int endOffset) const | - | ||||||||||||||||||
995 | { | - | ||||||||||||||||||
996 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
997 | cursor.setPosition(startOffset, QTextCursor::MoveAnchor); | - | ||||||||||||||||||
998 | cursor.setPosition(endOffset, QTextCursor::KeepAnchor); | - | ||||||||||||||||||
999 | - | |||||||||||||||||||
1000 | return cursor; never executed: return cursor; | 0 | ||||||||||||||||||
1001 | } | - | ||||||||||||||||||
1002 | - | |||||||||||||||||||
1003 | void QAccessibleTextWidget::deleteText(int startOffset, int endOffset) | - | ||||||||||||||||||
1004 | { | - | ||||||||||||||||||
1005 | QTextCursor cursor = textCursorForRange(startOffset, endOffset); | - | ||||||||||||||||||
1006 | cursor.removeSelectedText(); | - | ||||||||||||||||||
1007 | } never executed: end of block | 0 | ||||||||||||||||||
1008 | - | |||||||||||||||||||
1009 | void QAccessibleTextWidget::insertText(int offset, const QString &text) | - | ||||||||||||||||||
1010 | { | - | ||||||||||||||||||
1011 | QTextCursor cursor = textCursor(); | - | ||||||||||||||||||
1012 | cursor.setPosition(offset); | - | ||||||||||||||||||
1013 | cursor.insertText(text); | - | ||||||||||||||||||
1014 | } never executed: end of block | 0 | ||||||||||||||||||
1015 | - | |||||||||||||||||||
1016 | void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QString &text) | - | ||||||||||||||||||
1017 | { | - | ||||||||||||||||||
1018 | QTextCursor cursor = textCursorForRange(startOffset, endOffset); | - | ||||||||||||||||||
1019 | cursor.removeSelectedText(); | - | ||||||||||||||||||
1020 | cursor.insertText(text); | - | ||||||||||||||||||
1021 | } never executed: end of block | 0 | ||||||||||||||||||
1022 | #endif // QT_NO_CURSOR | - | ||||||||||||||||||
1023 | - | |||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | #ifndef QT_NO_MAINWINDOW | - | ||||||||||||||||||
1026 | QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) | - | ||||||||||||||||||
1027 | : QAccessibleWidget(widget, QAccessible::Window) { } never executed: end of block | 0 | ||||||||||||||||||
1028 | - | |||||||||||||||||||
1029 | QAccessibleInterface *QAccessibleMainWindow::child(int index) const | - | ||||||||||||||||||
1030 | { | - | ||||||||||||||||||
1031 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
1032 | if (index >= 0 && index < kids.count()) {
| 0 | ||||||||||||||||||
1033 | return QAccessible::queryAccessibleInterface(kids.at(index)); never executed: return QAccessible::queryAccessibleInterface(kids.at(index)); | 0 | ||||||||||||||||||
1034 | } | - | ||||||||||||||||||
1035 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1036 | } | - | ||||||||||||||||||
1037 | - | |||||||||||||||||||
1038 | int QAccessibleMainWindow::childCount() const | - | ||||||||||||||||||
1039 | { | - | ||||||||||||||||||
1040 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
1041 | return kids.count(); never executed: return kids.count(); | 0 | ||||||||||||||||||
1042 | } | - | ||||||||||||||||||
1043 | - | |||||||||||||||||||
1044 | int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const | - | ||||||||||||||||||
1045 | { | - | ||||||||||||||||||
1046 | QList<QWidget*> kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
1047 | return kids.indexOf(static_cast<QWidget*>(iface->object())); never executed: return kids.indexOf(static_cast<QWidget*>(iface->object())); | 0 | ||||||||||||||||||
1048 | } | - | ||||||||||||||||||
1049 | - | |||||||||||||||||||
1050 | QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const | - | ||||||||||||||||||
1051 | { | - | ||||||||||||||||||
1052 | QWidget *w = widget(); | - | ||||||||||||||||||
1053 | if (!w->isVisible())
| 0 | ||||||||||||||||||
1054 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1055 | QPoint gp = w->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
1056 | if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
| 0 | ||||||||||||||||||
1057 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1058 | - | |||||||||||||||||||
1059 | QWidgetList kids = childWidgets(mainWindow()); | - | ||||||||||||||||||
1060 | QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); | - | ||||||||||||||||||
1061 | for (int i = 0; i < kids.size(); ++i) {
| 0 | ||||||||||||||||||
1062 | QWidget *child = kids.at(i); | - | ||||||||||||||||||
1063 | if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
| 0 | ||||||||||||||||||
1064 | return QAccessible::queryAccessibleInterface(child); never executed: return QAccessible::queryAccessibleInterface(child); | 0 | ||||||||||||||||||
1065 | } | - | ||||||||||||||||||
1066 | } never executed: end of block | 0 | ||||||||||||||||||
1067 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1068 | } | - | ||||||||||||||||||
1069 | - | |||||||||||||||||||
1070 | QMainWindow *QAccessibleMainWindow::mainWindow() const | - | ||||||||||||||||||
1071 | { | - | ||||||||||||||||||
1072 | return qobject_cast<QMainWindow *>(object()); never executed: return qobject_cast<QMainWindow *>(object()); | 0 | ||||||||||||||||||
1073 | } | - | ||||||||||||||||||
1074 | - | |||||||||||||||||||
1075 | #endif //QT_NO_MAINWINDOW | - | ||||||||||||||||||
1076 | - | |||||||||||||||||||
1077 | QT_END_NAMESPACE | - | ||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |