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