Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | extern QList<QWidget*> childWidgets(const QWidget *widget); | - |
12 | | - |
13 | QString qt_accStripAmp(const QString &text); | - |
14 | QString qt_accHotKey(const QString &text); | - |
15 | QAccessibleButton::QAccessibleButton(QWidget *w) | - |
16 | : QAccessibleWidget(w) | - |
17 | { | - |
18 | ((!(button())) ? qt_assert("button()",__FILE__,8389) : qt_noop()); | - |
19 | | - |
20 | | - |
21 | | - |
22 | if (button()->isCheckable()) | - |
23 | addControllingSignal(QLatin1String("toggled(bool)")); | - |
24 | else | - |
25 | addControllingSignal(QLatin1String("clicked()")); | - |
26 | } | - |
27 | | - |
28 | | - |
29 | QAbstractButton *QAccessibleButton::button() const | - |
30 | { | - |
31 | return qobject_cast<QAbstractButton*>(object()); | - |
32 | } | - |
33 | | - |
34 | | - |
35 | QString QAccessibleButton::text(QAccessible::Text t) const | - |
36 | { | - |
37 | QString str; | - |
38 | switch (t) { | - |
39 | case QAccessible::Accelerator: | - |
40 | { | - |
41 | | - |
42 | QPushButton *pb = qobject_cast<QPushButton*>(object()); | - |
43 | if (pb && pb->isDefault()) | - |
44 | str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText); | - |
45 | | - |
46 | if (str.isEmpty()) | - |
47 | str = qt_accHotKey(button()->text()); | - |
48 | } | - |
49 | break; | - |
50 | case QAccessible::Name: | - |
51 | str = widget()->accessibleName(); | - |
52 | if (str.isEmpty()) | - |
53 | str = qt_accStripAmp(button()->text()); | - |
54 | break; | - |
55 | default: | - |
56 | break; | - |
57 | } | - |
58 | if (str.isEmpty()) | - |
59 | str = QAccessibleWidget::text(t); | - |
60 | return str; | - |
61 | } | - |
62 | | - |
63 | QAccessible::State QAccessibleButton::state() const | - |
64 | { | - |
65 | QAccessible::State state = QAccessibleWidget::state(); | - |
66 | | - |
67 | QAbstractButton *b = button(); | - |
68 | QCheckBox *cb = qobject_cast<QCheckBox *>(b); | - |
69 | if (b->isCheckable()) | - |
70 | state.checkable = true; | - |
71 | if (b->isChecked()) | - |
72 | state.checked = true; | - |
73 | else if (cb && cb->checkState() == Qt::PartiallyChecked) | - |
74 | state.checkStateMixed = true; | - |
75 | if (b->isDown()) | - |
76 | state.pressed = true; | - |
77 | QPushButton *pb = qobject_cast<QPushButton*>(b); | - |
78 | if (pb) { | - |
79 | if (pb->isDefault()) | - |
80 | state.defaultButton = true; | - |
81 | | - |
82 | if (pb->menu()) | - |
83 | state.hasPopup = true; | - |
84 | | - |
85 | } | - |
86 | | - |
87 | return state; | - |
88 | } | - |
89 | | - |
90 | QRect QAccessibleButton::rect() const | - |
91 | { | - |
92 | QAbstractButton *ab = button(); | - |
93 | if (!ab->isVisible()) | - |
94 | return QRect(); | - |
95 | | - |
96 | if (QCheckBox *cb = qobject_cast<QCheckBox *>(ab)) { | - |
97 | QPoint wpos = cb->mapToGlobal(QPoint(0, 0)); | - |
98 | QStyleOptionButton opt; | - |
99 | cb->initStyleOption(&opt); | - |
100 | return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos); | - |
101 | } else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) { | - |
102 | QPoint wpos = rb->mapToGlobal(QPoint(0, 0)); | - |
103 | QStyleOptionButton opt; | - |
104 | rb->initStyleOption(&opt); | - |
105 | return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos); | - |
106 | } | - |
107 | return QAccessibleWidget::rect(); | - |
108 | } | - |
109 | | - |
110 | QAccessible::Role QAccessibleButton::role() const | - |
111 | { | - |
112 | QAbstractButton *ab = button(); | - |
113 | | - |
114 | | - |
115 | if (QPushButton *pb = qobject_cast<QPushButton*>(ab)) { | - |
116 | if (pb->menu()) | - |
117 | return QAccessible::ButtonMenu; | - |
118 | } | - |
119 | | - |
120 | | - |
121 | if (ab->isCheckable()) | - |
122 | return ab->autoExclusive() ? QAccessible::RadioButton : QAccessible::CheckBox; | - |
123 | | - |
124 | return QAccessible::Button; | - |
125 | } | - |
126 | | - |
127 | QStringList QAccessibleButton::actionNames() const | - |
128 | { | - |
129 | QStringList names; | - |
130 | if (widget()->isEnabled()) { | - |
131 | switch (role()) { | - |
132 | case QAccessible::ButtonMenu: | - |
133 | names << showMenuAction(); | - |
134 | break; | - |
135 | case QAccessible::RadioButton: | - |
136 | names << toggleAction(); | - |
137 | break; | - |
138 | default: | - |
139 | if (button()->isCheckable()) { | - |
140 | names << toggleAction(); | - |
141 | } else { | - |
142 | names << pressAction(); | - |
143 | } | - |
144 | break; | - |
145 | } | - |
146 | } | - |
147 | names << QAccessibleWidget::actionNames(); | - |
148 | return names; | - |
149 | } | - |
150 | | - |
151 | void QAccessibleButton::doAction(const QString &actionName) | - |
152 | { | - |
153 | if (!widget()->isEnabled()) | - |
154 | return; | - |
155 | if (actionName == pressAction() || | - |
156 | actionName == showMenuAction()) { | - |
157 | | - |
158 | QPushButton *pb = qobject_cast<QPushButton*>(object()); | - |
159 | if (pb && pb->menu()) | - |
160 | pb->showMenu(); | - |
161 | else | - |
162 | | - |
163 | button()->animateClick(); | - |
164 | } else if (actionName == toggleAction()) { | - |
165 | button()->toggle(); | - |
166 | } else { | - |
167 | QAccessibleWidget::doAction(actionName); | - |
168 | } | - |
169 | } | - |
170 | | - |
171 | QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) const | - |
172 | { | - |
173 | if (actionName == pressAction()) { | - |
174 | | - |
175 | return QStringList() << button()->shortcut().toString(); | - |
176 | | - |
177 | } | - |
178 | return QStringList(); | - |
179 | } | - |
180 | QAccessibleToolButton::QAccessibleToolButton(QWidget *w) | - |
181 | : QAccessibleButton(w) | - |
182 | { | - |
183 | ((!(toolButton())) ? qt_assert("toolButton()",__FILE__,262268) : qt_noop()); | - |
184 | } | - |
185 | | - |
186 | | - |
187 | QToolButton *QAccessibleToolButton::toolButton() const | - |
188 | { | - |
189 | return qobject_cast<QToolButton*>(object()); | - |
190 | } | - |
191 | | - |
192 | | - |
193 | | - |
194 | | - |
195 | bool QAccessibleToolButton::isSplitButton() const | - |
196 | { | - |
197 | | - |
198 | return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup; | - |
199 | | - |
200 | | - |
201 | | - |
202 | } | - |
203 | | - |
204 | QAccessible::State QAccessibleToolButton::state() const | - |
205 | { | - |
206 | QAccessible::State st = QAccessibleButton::state(); | - |
207 | if (toolButton()->autoRaise()) | - |
208 | st.hotTracked = true; | - |
209 | | - |
210 | if (toolButton()->menu()) | - |
211 | st.hasPopup = true; | - |
212 | | - |
213 | return st; | - |
214 | } | - |
215 | | - |
216 | int QAccessibleToolButton::childCount() const | - |
217 | { | - |
218 | return isSplitButton() ? 1 : 0; | - |
219 | } | - |
220 | | - |
221 | QAccessible::Role QAccessibleToolButton::role() const | - |
222 | { | - |
223 | QAbstractButton *ab = button(); | - |
224 | | - |
225 | | - |
226 | QToolButton *tb = qobject_cast<QToolButton*>(ab); | - |
227 | if (!tb->menu()) | - |
228 | return tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton; | - |
229 | else if (tb->popupMode() == QToolButton::DelayedPopup) | - |
230 | return QAccessible::ButtonDropDown; | - |
231 | | - |
232 | | - |
233 | return QAccessible::ButtonMenu; | - |
234 | } | - |
235 | | - |
236 | QAccessibleInterface *QAccessibleToolButton::child(int index) const | - |
237 | { | - |
238 | | - |
239 | if (index == 0 && toolButton()->menu()) | - |
240 | { | - |
241 | return QAccessible::queryAccessibleInterface(toolButton()->menu()); | - |
242 | } | - |
243 | | - |
244 | return 0; | - |
245 | } | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | | - |
253 | QStringList QAccessibleToolButton::actionNames() const | - |
254 | { | - |
255 | QStringList names; | - |
256 | if (widget()->isEnabled()) { | - |
257 | if (toolButton()->menu()) | - |
258 | names << showMenuAction(); | - |
259 | if (toolButton()->popupMode() != QToolButton::InstantPopup) | - |
260 | names << QAccessibleButton::actionNames(); | - |
261 | } | - |
262 | return names; | - |
263 | } | - |
264 | | - |
265 | void QAccessibleToolButton::doAction(const QString &actionName) | - |
266 | { | - |
267 | if (!widget()->isEnabled()) | - |
268 | return; | - |
269 | | - |
270 | if (actionName == pressAction()) { | - |
271 | button()->click(); | - |
272 | } else if (actionName == showMenuAction()) { | - |
273 | if (toolButton()->popupMode() != QToolButton::InstantPopup) { | - |
274 | toolButton()->setDown(true); | - |
275 | | - |
276 | toolButton()->showMenu(); | - |
277 | | - |
278 | } | - |
279 | } else { | - |
280 | QAccessibleButton::doAction(actionName); | - |
281 | } | - |
282 | | - |
283 | } | - |
284 | QAccessibleDisplay::QAccessibleDisplay(QWidget *w, QAccessible::Role role) | - |
285 | : QAccessibleWidget(w, role) | - |
286 | { | - |
287 | } | - |
288 | | - |
289 | QAccessible::Role QAccessibleDisplay::role() const | - |
290 | { | - |
291 | QLabel *l = qobject_cast<QLabel*>(object()); | - |
292 | if (l) { | - |
293 | if (l->pixmap()) | - |
294 | return QAccessible::Graphic; | - |
295 | | - |
296 | if (l->picture()) | - |
297 | return QAccessible::Graphic; | - |
298 | | - |
299 | | - |
300 | if (l->movie()) | - |
301 | return QAccessible::Animation; | - |
302 | | - |
303 | | - |
304 | } else if (qobject_cast<QProgressBar*>(object())) { | - |
305 | return QAccessible::ProgressBar; | - |
306 | | - |
307 | } else if (qobject_cast<QStatusBar*>(object())) { | - |
308 | return QAccessible::StatusBar; | - |
309 | } | - |
310 | return QAccessibleWidget::role(); | - |
311 | } | - |
312 | | - |
313 | QString QAccessibleDisplay::text(QAccessible::Text t) const | - |
314 | { | - |
315 | QString str; | - |
316 | switch (t) { | - |
317 | case QAccessible::Name: | - |
318 | str = widget()->accessibleName(); | - |
319 | if (str.isEmpty()) { | - |
320 | if (qobject_cast<QLabel*>(object())) { | - |
321 | QLabel *label = qobject_cast<QLabel*>(object()); | - |
322 | str = label->text(); | - |
323 | | - |
324 | if (label->textFormat() == Qt::RichText | - |
325 | || (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) { | - |
326 | QTextDocument doc; | - |
327 | doc.setHtml(str); | - |
328 | str = doc.toPlainText(); | - |
329 | } | - |
330 | | - |
331 | if (label->buddy()) | - |
332 | str = qt_accStripAmp(str); | - |
333 | | - |
334 | } else if (qobject_cast<QLCDNumber*>(object())) { | - |
335 | QLCDNumber *l = qobject_cast<QLCDNumber*>(object()); | - |
336 | if (l->digitCount()) | - |
337 | str = QString::number(l->value()); | - |
338 | else | - |
339 | str = QString::number(l->intValue()); | - |
340 | | - |
341 | } else if (qobject_cast<QStatusBar*>(object())) { | - |
342 | return qobject_cast<QStatusBar*>(object())->currentMessage(); | - |
343 | } | - |
344 | } | - |
345 | break; | - |
346 | case QAccessible::Value: | - |
347 | | - |
348 | if (qobject_cast<QProgressBar*>(object())) | - |
349 | str = QString::number(qobject_cast<QProgressBar*>(object())->value()); | - |
350 | | - |
351 | break; | - |
352 | default: | - |
353 | break; | - |
354 | } | - |
355 | if (str.isEmpty()) | - |
356 | str = QAccessibleWidget::text(t); | - |
357 | return str; | - |
358 | } | - |
359 | | - |
360 | | - |
361 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > | - |
362 | QAccessibleDisplay::relations(QAccessible::Relation match ) const | - |
363 | { | - |
364 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match); | - |
365 | if (match & QAccessible::Labelled) { | - |
366 | QVarLengthArray<QObject *, 4> relatedObjects; | - |
367 | | - |
368 | | - |
369 | if (QLabel *label = qobject_cast<QLabel*>(object())) { | - |
370 | relatedObjects.append(label->buddy()); | - |
371 | } | - |
372 | | - |
373 | for (int i = 0; i < relatedObjects.count(); ++i) { | - |
374 | const QAccessible::Relation rel = QAccessible::Labelled; | - |
375 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(relatedObjects.at(i)); | - |
376 | if (iface) | - |
377 | rels.append(qMakePair(iface, rel)); | - |
378 | } | - |
379 | } | - |
380 | return rels; | - |
381 | } | - |
382 | | - |
383 | void *QAccessibleDisplay::interface_cast(QAccessible::InterfaceType t) | - |
384 | { | - |
385 | if (t == QAccessible::ImageInterface) | - |
386 | return static_cast<QAccessibleImageInterface*>(this); | - |
387 | return QAccessibleWidget::interface_cast(t); | - |
388 | } | - |
389 | | - |
390 | | - |
391 | QString QAccessibleDisplay::imageDescription() const | - |
392 | { | - |
393 | | - |
394 | return widget()->toolTip(); | - |
395 | | - |
396 | | - |
397 | | - |
398 | } | - |
399 | | - |
400 | | - |
401 | QSize QAccessibleDisplay::imageSize() const | - |
402 | { | - |
403 | QLabel *label = qobject_cast<QLabel *>(widget()); | - |
404 | if (!label) | - |
405 | return QSize(); | - |
406 | const QPixmap *pixmap = label->pixmap(); | - |
407 | if (!pixmap) | - |
408 | return QSize(); | - |
409 | return pixmap->size(); | - |
410 | } | - |
411 | | - |
412 | | - |
413 | QPoint QAccessibleDisplay::imagePosition() const | - |
414 | { | - |
415 | QLabel *label = qobject_cast<QLabel *>(widget()); | - |
416 | if (!label) | - |
417 | return QPoint(); | - |
418 | const QPixmap *pixmap = label->pixmap(); | - |
419 | if (!pixmap) | - |
420 | return QPoint(); | - |
421 | | - |
422 | return QPoint(label->mapToGlobal(label->pos())); | - |
423 | } | - |
424 | | - |
425 | | - |
426 | QAccessibleGroupBox::QAccessibleGroupBox(QWidget *w) | - |
427 | : QAccessibleWidget(w) | - |
428 | { | - |
429 | } | - |
430 | | - |
431 | QGroupBox* QAccessibleGroupBox::groupBox() const | - |
432 | { | - |
433 | return static_cast<QGroupBox *>(widget()); | - |
434 | } | - |
435 | | - |
436 | QString QAccessibleGroupBox::text(QAccessible::Text t) const | - |
437 | { | - |
438 | QString txt = QAccessibleWidget::text(t); | - |
439 | | - |
440 | if (txt.isEmpty()) { | - |
441 | switch (t) { | - |
442 | case QAccessible::Name: | - |
443 | txt = qt_accStripAmp(groupBox()->title()); | - |
444 | break; | - |
445 | case QAccessible::Description: | - |
446 | txt = groupBox()->toolTip(); | - |
447 | break; | - |
448 | case QAccessible::Accelerator: | - |
449 | txt = qt_accHotKey(groupBox()->title()); | - |
450 | break; | - |
451 | default: | - |
452 | break; | - |
453 | } | - |
454 | } | - |
455 | | - |
456 | return txt; | - |
457 | } | - |
458 | | - |
459 | QAccessible::State QAccessibleGroupBox::state() const | - |
460 | { | - |
461 | QAccessible::State st = QAccessibleWidget::state(); | - |
462 | st.checkable = groupBox()->isCheckable(); | - |
463 | st.checked = groupBox()->isChecked(); | - |
464 | return st; | - |
465 | } | - |
466 | | - |
467 | QAccessible::Role QAccessibleGroupBox::role() const | - |
468 | { | - |
469 | return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping; | - |
470 | } | - |
471 | | - |
472 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > | - |
473 | QAccessibleGroupBox::relations(QAccessible::Relation match ) const | - |
474 | { | - |
475 | QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match); | - |
476 | | - |
477 | if ((TRUE | never evaluated | FALSE | never evaluated |
match & QAccessible::Labelled)TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
!groupBox()->title().isEmpty())TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
478 | const QList<QWidget*> kids = childWidgets(widget()); | - |
479 | for (int i = 0; i <QWidget *kid : kids.count(); ++i) { | - |
480 | QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kids.at(i));kid); | - |
481 | if (ifaceTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
482 | rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled))); never executed: rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled))); | 0 |
483 | } never executed: end of block | 0 |
484 | } never executed: end of block | 0 |
485 | return never executed: return rels; rels;never executed: return rels; | 0 |
486 | } | - |
487 | | - |
488 | QStringList QAccessibleGroupBox::actionNames() const | - |
489 | { | - |
490 | QStringList actions = QAccessibleWidget::actionNames(); | - |
491 | | - |
492 | if (groupBox()->isCheckable()) { | - |
493 | actions.prepend(QAccessibleActionInterface::toggleAction()); | - |
494 | } | - |
495 | return actions; | - |
496 | } | - |
497 | | - |
498 | void QAccessibleGroupBox::doAction(const QString &actionName) | - |
499 | { | - |
500 | if (actionName == QAccessibleActionInterface::toggleAction()) | - |
501 | groupBox()->setChecked(!groupBox()->isChecked()); | - |
502 | } | - |
503 | | - |
504 | QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const | - |
505 | { | - |
506 | return QStringList(); | - |
507 | } | - |
508 | QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name) | - |
509 | : QAccessibleWidget(w, QAccessible::EditableText, name) | - |
510 | { | - |
511 | addControllingSignal(QLatin1String("textChanged(const QString&)")); | - |
512 | addControllingSignal(QLatin1String("returnPressed()")); | - |
513 | } | - |
514 | | - |
515 | | - |
516 | QLineEdit *QAccessibleLineEdit::lineEdit() const | - |
517 | { | - |
518 | return qobject_cast<QLineEdit*>(object()); | - |
519 | } | - |
520 | | - |
521 | QString QAccessibleLineEdit::text(QAccessible::Text t) const | - |
522 | { | - |
523 | QString str; | - |
524 | switch (t) { | - |
525 | case QAccessible::Value: | - |
526 | if (lineEdit()->echoMode() == QLineEdit::Normal) | - |
527 | str = lineEdit()->text(); | - |
528 | else if (lineEdit()->echoMode() != QLineEdit::NoEcho) | - |
529 | str = QString(lineEdit()->text().length(), QChar::fromLatin1('*')); | - |
530 | break; | - |
531 | default: | - |
532 | break; | - |
533 | } | - |
534 | if (str.isEmpty()) | - |
535 | str = QAccessibleWidget::text(t); | - |
536 | return str; | - |
537 | } | - |
538 | | - |
539 | void QAccessibleLineEdit::setText(QAccessible::Text t, const QString &text) | - |
540 | { | - |
541 | if (t != QAccessible::Value) { | - |
542 | QAccessibleWidget::setText(t, text); | - |
543 | return; | - |
544 | } | - |
545 | | - |
546 | QString newText = text; | - |
547 | if (lineEdit()->validator()) { | - |
548 | int pos = 0; | - |
549 | if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable) | - |
550 | return; | - |
551 | } | - |
552 | lineEdit()->setText(newText); | - |
553 | } | - |
554 | | - |
555 | QAccessible::State QAccessibleLineEdit::state() const | - |
556 | { | - |
557 | QAccessible::State state = QAccessibleWidget::state(); | - |
558 | | - |
559 | QLineEdit *l = lineEdit(); | - |
560 | if (l->isReadOnly()) | - |
561 | state.readOnly = true; | - |
562 | else | - |
563 | state.editable = true; | - |
564 | | - |
565 | if (l->echoMode() != QLineEdit::Normal) | - |
566 | state.passwordEdit = true; | - |
567 | | - |
568 | state.selectableText = true; | - |
569 | return state; | - |
570 | } | - |
571 | | - |
572 | void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t) | - |
573 | { | - |
574 | if (t == QAccessible::TextInterface) | - |
575 | return static_cast<QAccessibleTextInterface*>(this); | - |
576 | if (t == QAccessible::EditableTextInterface) | - |
577 | return static_cast<QAccessibleEditableTextInterface*>(this); | - |
578 | return QAccessibleWidget::interface_cast(t); | - |
579 | } | - |
580 | | - |
581 | void QAccessibleLineEdit::addSelection(int startOffset, int endOffset) | - |
582 | { | - |
583 | setSelection(0, startOffset, endOffset); | - |
584 | } | - |
585 | | - |
586 | QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset) const | - |
587 | { | - |
588 | | - |
589 | *startOffset = *endOffset = offset; | - |
590 | return QString(); | - |
591 | } | - |
592 | | - |
593 | int QAccessibleLineEdit::cursorPosition() const | - |
594 | { | - |
595 | return lineEdit()->cursorPosition(); | - |
596 | } | - |
597 | | - |
598 | QRect QAccessibleLineEdit::characterRect(int offset) const | - |
599 | { | - |
600 | int x = lineEdit()->d_func()->control->cursorToX(offset); | - |
601 | int y; | - |
602 | lineEdit()->getTextMargins(0, &y, 0, 0); | - |
603 | QFontMetrics fm(lineEdit()->font()); | - |
604 | const QString ch = text(offset, offset + 1); | - |
605 | if (ch.isEmpty()) | - |
606 | return QRect(); | - |
607 | int w = fm.width(ch); | - |
608 | int h = fm.height(); | - |
609 | QRect r(x, y, w, h); | - |
610 | r.moveTo(lineEdit()->mapToGlobal(r.topLeft())); | - |
611 | return r; | - |
612 | } | - |
613 | | - |
614 | int QAccessibleLineEdit::selectionCount() const | - |
615 | { | - |
616 | return lineEdit()->hasSelectedText() ? 1 : 0; | - |
617 | } | - |
618 | | - |
619 | int QAccessibleLineEdit::offsetAtPoint(const QPoint &point) const | - |
620 | { | - |
621 | QPoint p = lineEdit()->mapFromGlobal(point); | - |
622 | | - |
623 | return lineEdit()->cursorPositionAt(p); | - |
624 | } | - |
625 | | - |
626 | void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset) const | - |
627 | { | - |
628 | *startOffset = *endOffset = 0; | - |
629 | if (selectionIndex != 0) | - |
630 | return; | - |
631 | | - |
632 | *startOffset = lineEdit()->selectionStart(); | - |
633 | *endOffset = *startOffset + lineEdit()->selectedText().count(); | - |
634 | } | - |
635 | | - |
636 | QString QAccessibleLineEdit::text(int startOffset, int endOffset) const | - |
637 | { | - |
638 | if (startOffset > endOffset) | - |
639 | return QString(); | - |
640 | | - |
641 | if (lineEdit()->echoMode() != QLineEdit::Normal) | - |
642 | return QString(); | - |
643 | | - |
644 | return lineEdit()->text().mid(startOffset, endOffset - startOffset); | - |
645 | } | - |
646 | | - |
647 | QString QAccessibleLineEdit::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - |
648 | int *startOffset, int *endOffset) const | - |
649 | { | - |
650 | if (lineEdit()->echoMode() != QLineEdit::Normal) { | - |
651 | *startOffset = *endOffset = -1; | - |
652 | return QString(); | - |
653 | } | - |
654 | if (offset == -2) | - |
655 | offset = cursorPosition(); | - |
656 | return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset); | - |
657 | } | - |
658 | | - |
659 | QString QAccessibleLineEdit::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - |
660 | int *startOffset, int *endOffset) const | - |
661 | { | - |
662 | if (lineEdit()->echoMode() != QLineEdit::Normal) { | - |
663 | *startOffset = *endOffset = -1; | - |
664 | return QString(); | - |
665 | } | - |
666 | if (offset == -2) | - |
667 | offset = cursorPosition(); | - |
668 | return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset); | - |
669 | } | - |
670 | | - |
671 | QString QAccessibleLineEdit::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, | - |
672 | int *startOffset, int *endOffset) const | - |
673 | { | - |
674 | if (lineEdit()->echoMode() != QLineEdit::Normal) { | - |
675 | *startOffset = *endOffset = -1; | - |
676 | return QString(); | - |
677 | } | - |
678 | if (offset == -2) | - |
679 | offset = cursorPosition(); | - |
680 | return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset); | - |
681 | } | - |
682 | | - |
683 | void QAccessibleLineEdit::removeSelection(int selectionIndex) | - |
684 | { | - |
685 | if (selectionIndex != 0) | - |
686 | return; | - |
687 | | - |
688 | lineEdit()->deselect(); | - |
689 | } | - |
690 | | - |
691 | void QAccessibleLineEdit::setCursorPosition(int position) | - |
692 | { | - |
693 | lineEdit()->setCursorPosition(position); | - |
694 | } | - |
695 | | - |
696 | void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int endOffset) | - |
697 | { | - |
698 | if (selectionIndex != 0) | - |
699 | return; | - |
700 | | - |
701 | lineEdit()->setSelection(startOffset, endOffset - startOffset); | - |
702 | } | - |
703 | | - |
704 | int QAccessibleLineEdit::characterCount() const | - |
705 | { | - |
706 | return lineEdit()->text().count(); | - |
707 | } | - |
708 | | - |
709 | void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) | - |
710 | { | - |
711 | lineEdit()->setCursorPosition(endIndex); | - |
712 | lineEdit()->setCursorPosition(startIndex); | - |
713 | } | - |
714 | | - |
715 | void QAccessibleLineEdit::deleteText(int startOffset, int endOffset) | - |
716 | { | - |
717 | lineEdit()->setText(lineEdit()->text().remove(startOffset, endOffset - startOffset)); | - |
718 | } | - |
719 | | - |
720 | void QAccessibleLineEdit::insertText(int offset, const QString &text) | - |
721 | { | - |
722 | lineEdit()->setText(lineEdit()->text().insert(offset, text)); | - |
723 | } | - |
724 | | - |
725 | void QAccessibleLineEdit::replaceText(int startOffset, int endOffset, const QString &text) | - |
726 | { | - |
727 | lineEdit()->setText(lineEdit()->text().replace(startOffset, endOffset - startOffset, text)); | - |
728 | } | - |
729 | | - |
730 | | - |
731 | | - |
732 | | - |
733 | QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o) | - |
734 | : QAccessibleDisplay(o) | - |
735 | { | - |
736 | ((!(progressBar())) ? qt_assert("progressBar()",__FILE__,846852) : qt_noop()); | - |
737 | } | - |
738 | | - |
739 | void *QAccessibleProgressBar::interface_cast(QAccessible::InterfaceType t) | - |
740 | { | - |
741 | if (t == QAccessible::ValueInterface) | - |
742 | return static_cast<QAccessibleValueInterface*>(this); | - |
743 | return QAccessibleDisplay::interface_cast(t); | - |
744 | } | - |
745 | | - |
746 | QVariant QAccessibleProgressBar::currentValue() const | - |
747 | { | - |
748 | return progressBar()->value(); | - |
749 | } | - |
750 | | - |
751 | QVariant QAccessibleProgressBar::maximumValue() const | - |
752 | { | - |
753 | return progressBar()->maximum(); | - |
754 | } | - |
755 | | - |
756 | QVariant QAccessibleProgressBar::minimumValue() const | - |
757 | { | - |
758 | return progressBar()->minimum(); | - |
759 | } | - |
760 | | - |
761 | QVariant QAccessibleProgressBar::minimumStepSize() const | - |
762 | { | - |
763 | | - |
764 | | - |
765 | | - |
766 | return (progressBar()->maximum() - progressBar()->minimum()) / 100.0; | - |
767 | } | - |
768 | | - |
769 | QProgressBar *QAccessibleProgressBar::progressBar() const | - |
770 | { | - |
771 | return qobject_cast<QProgressBar *>(object()); | - |
772 | } | - |
773 | | - |
774 | | - |
775 | | - |
776 | QAccessibleWindowContainer::QAccessibleWindowContainer(QWidget *w) | - |
777 | : QAccessibleWidget(w) | - |
778 | { | - |
779 | } | - |
780 | | - |
781 | int QAccessibleWindowContainer::childCount() const | - |
782 | { | - |
783 | if (container()->containedWindow()) | - |
784 | return 1; | - |
785 | return 0; | - |
786 | } | - |
787 | | - |
788 | int QAccessibleWindowContainer::indexOfChild(const QAccessibleInterface *child) const | - |
789 | { | - |
790 | if (child->object() == container()->containedWindow()) | - |
791 | return 0; | - |
792 | return -1; | - |
793 | } | - |
794 | | - |
795 | QAccessibleInterface *QAccessibleWindowContainer::child(int i) const | - |
796 | { | - |
797 | if (i == 0) | - |
798 | return QAccessible::queryAccessibleInterface(container()->containedWindow()); | - |
799 | return 0; | - |
800 | } | - |
801 | | - |
802 | QWindowContainer *QAccessibleWindowContainer::container() const | - |
803 | { | - |
804 | return static_cast<QWindowContainer *>(widget()); | - |
805 | } | - |
806 | | - |
807 | | - |
808 | | - |
809 | | - |
| | |