Qt 4.8
qaccessiblewidgets.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qaccessiblewidgets.h"
44 #include "qapplication.h"
45 #include "qclipboard.h"
46 #include "qtextedit.h"
47 #include "private/qtextedit_p.h"
48 #include "qtextdocument.h"
49 #include "qtextobject.h"
50 #include "qplaintextedit.h"
51 #include "qscrollbar.h"
52 #include "qdebug.h"
53 #include <QApplication>
54 #include <QStackedWidget>
55 #include <QToolBox>
56 #include <QMdiArea>
57 #include <QMdiSubWindow>
58 #include <QWorkspace>
59 #include <QDialogButtonBox>
60 #include <limits.h>
61 #include <QRubberBand>
62 #include <QTextBrowser>
63 #include <QCalendarWidget>
64 #include <QAbstractItemView>
65 #include <QDockWidget>
66 #include <QMainWindow>
67 #include <QAbstractButton>
68 #include <private/qdockwidget_p.h>
69 #include <QtGui/QFocusFrame>
70 
71 #ifndef QT_NO_ACCESSIBILITY
72 
74 
75 using namespace QAccessible2;
76 
79 
80 QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
81 {
82  if (widget == 0)
83  return QList<QWidget*>();
84  QList<QObject*> list = widget->children();
85  QList<QWidget*> widgets;
86  for (int i = 0; i < list.size(); ++i) {
87  QWidget *w = qobject_cast<QWidget *>(list.at(i));
88  if (!w)
89  continue;
90  QString objectName = w->objectName();
91  if ((includeTopLevel || !w->isWindow())
92  && !qobject_cast<QFocusFrame*>(w)
93  && !qobject_cast<QMenu*>(w)
94  && objectName != QLatin1String("qt_rubberband")
95  && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) {
96  widgets.append(w);
97  }
98  }
99  return widgets;
100 }
101 
102 static inline int distance(QWidget *source, QWidget *target,
103  QAccessible::RelationFlag relation)
104 {
105  if (!source || !target)
106  return -1;
107 
108  int returnValue = -1;
109  switch (relation) {
110  case QAccessible::Up:
111  if (target->y() <= source->y())
112  returnValue = source->y() - target->y();
113  break;
114  case QAccessible::Down:
115  if (target->y() >= source->y() + source->height())
116  returnValue = target->y() - (source->y() + source->height());
117  break;
118  case QAccessible::Right:
119  if (target->x() >= source->x() + source->width())
120  returnValue = target->x() - (source->x() + source->width());
121  break;
122  case QAccessible::Left:
123  if (target->x() <= source->x())
124  returnValue = source->x() - target->x();
125  break;
126  default:
127  break;
128  }
129  return returnValue;
130 }
131 
133  QAccessible::RelationFlag relation, int entry)
134 {
135 #if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE)
136  Q_UNUSED(area);
137 #endif
138 #ifndef QT_NO_MDIAREA
139  const QMdiArea *mdiArea = qobject_cast<QMdiArea *>(area);
140 #endif
141 #ifndef QT_NO_WORKSPACE
142  const QWorkspace *workspace = qobject_cast<QWorkspace *>(area);
143 #endif
144  if (true
145 #ifndef QT_NO_MDIAREA
146  && !mdiArea
147 #endif
148 #ifndef QT_NO_WORKSPACE
149  && !workspace
150 #endif
151  )
152  return 0;
153 
154  QWidgetList windows;
155 #ifndef QT_NO_MDIAREA
156  if (mdiArea) {
157  foreach (QMdiSubWindow *window, mdiArea->subWindowList())
158  windows.append(window);
159  } else
160 #endif
161  {
162 #ifndef QT_NO_WORKSPACE
163  foreach (QWidget *window, workspace->windowList())
164  windows.append(window->parentWidget());
165 #endif
166  }
167 
168  if (windows.isEmpty() || entry < 1 || entry > windows.count())
169  return 0;
170 
171  QWidget *source = windows.at(entry - 1);
172  QMap<int, QWidget *> candidates;
173  foreach (QWidget *window, windows) {
174  if (source == window)
175  continue;
176  int candidateDistance = distance(source, window, relation);
177  if (candidateDistance >= 0)
178  candidates.insert(candidateDistance, window);
179  }
180 
181  int minimumDistance = INT_MAX;
182  QWidget *target = 0;
183  foreach (QWidget *candidate, candidates) {
184  switch (relation) {
185  case QAccessible::Up:
186  case QAccessible::Down:
187  if (qAbs(candidate->x() - source->x()) < minimumDistance) {
188  target = candidate;
189  minimumDistance = qAbs(candidate->x() - source->x());
190  }
191  break;
192  case QAccessible::Left:
193  case QAccessible::Right:
194  if (qAbs(candidate->y() - source->y()) < minimumDistance) {
195  target = candidate;
196  minimumDistance = qAbs(candidate->y() - source->y());
197  }
198  break;
199  default:
200  break;
201  }
202  if (minimumDistance == 0)
203  break;
204  }
205 
206 #ifndef QT_NO_WORKSPACE
207  if (workspace) {
208  foreach (QWidget *widget, workspace->windowList()) {
209  if (widget->parentWidget() == target)
210  target = widget;
211  }
212  }
213 #endif
214  return target;
215 }
216 
217 #ifndef QT_NO_TEXTEDIT
218 
228 static QTextBlock qTextBlockAt(const QTextDocument *doc, int pos)
229 {
230  Q_ASSERT(pos >= 0);
231 
232  QTextBlock block = doc->begin();
233  int i = 0;
234  while (block.isValid() && i < pos) {
235  block = block.next();
236  ++i;
237  }
238  return block;
239 }
240 
242 {
243  int child = 0;
244  while (block.isValid()) {
245  block = block.previous();
246  ++child;
247  }
248 
249  return child;
250 }
251 
254 {
255 }
256 
258 {
259  return static_cast<QPlainTextEdit *>(widget());
260 }
261 
263 {
264  QPoint result;
265  result.setX(plainTextEdit()->horizontalScrollBar() ? plainTextEdit()->horizontalScrollBar()->sliderPosition() : 0);
266  result.setY(plainTextEdit()->verticalScrollBar() ? plainTextEdit()->verticalScrollBar()->sliderPosition() : 0);
267  return result;
268 }
269 
271 {
272  return plainTextEdit()->textCursor();
273 }
274 
276 {
277  plainTextEdit()->setTextCursor(textCursor);
278 }
279 
281 {
282  return 0;
283 }
284 
286 {
287  return plainTextEdit()->document();
288 }
289 
291 {
292  return plainTextEdit()->viewport();
293 }
294 
295 void QAccessiblePlainTextEdit::scrollToSubstring(int startIndex, int endIndex)
296 {
297  //TODO: Not implemented
298  Q_UNUSED(startIndex);
299  Q_UNUSED(endIndex);
300 }
301 
302 
310 {
311  Q_ASSERT(widget()->inherits("QTextEdit"));
313 }
314 
317 {
318  return static_cast<QTextEdit *>(widget());
319 }
320 
322 {
323  return textEdit()->textCursor();
324 }
325 
327 {
328  return textEdit()->document();
329 }
330 
332 {
333  textEdit()->setTextCursor(textCursor);
334 }
335 
337 {
338  return textEdit()->viewport();
339 }
340 
342 {
343  QPoint result;
344  result.setX(textEdit()->horizontalScrollBar() ? textEdit()->horizontalScrollBar()->sliderPosition() : 0);
345  result.setY(textEdit()->verticalScrollBar() ? textEdit()->verticalScrollBar()->sliderPosition() : 0);
346  return result;
347 }
348 
350 {
351  if (child <= childOffset)
352  return QAccessibleWidgetEx::rect(child);
353 
354  QTextEdit *edit = textEdit();
355  QTextBlock block = qTextBlockAt(edit->document(), child - childOffset - 1);
356  if (!block.isValid())
357  return QRect();
358 
359  QRect rect = edit->document()->documentLayout()->blockBoundingRect(block).toRect();
360  rect.translate(-edit->horizontalScrollBar()->value(), -edit->verticalScrollBar()->value());
361 
362  rect = edit->viewport()->rect().intersect(rect);
363  if (rect.isEmpty())
364  return QRect();
365 
366  return rect.translated(edit->viewport()->mapToGlobal(QPoint(0, 0)));
367 }
368 
369 int QAccessibleTextEdit::childAt(int x, int y) const
370 {
371  QTextEdit *edit = textEdit();
372  if (!edit->isVisible())
373  return -1;
374 
375  QPoint point = edit->viewport()->mapFromGlobal(QPoint(x, y));
376  QTextBlock block = edit->cursorForPosition(point).block();
377  if (block.isValid())
378  return qTextBlockPosition(block) + childOffset;
379 
380  return QAccessibleWidgetEx::childAt(x, y);
381 }
382 
385 {
386  if (t == Value) {
387  if (child > childOffset)
388  return qTextBlockAt(textEdit()->document(), child - childOffset - 1).text();
389  if (!child)
390  return textEdit()->toPlainText();
391  }
392 
393  return QAccessibleWidgetEx::text(t, child);
394 }
395 
397 void QAccessibleTextEdit::setText(Text t, int child, const QString &text)
398 {
399  if (t != Value || (child > 0 && child <= childOffset)) {
400  QAccessibleWidgetEx::setText(t, child, text);
401  return;
402  }
403  if (textEdit()->isReadOnly())
404  return;
405 
406  if (!child) {
407  textEdit()->setText(text);
408  return;
409  }
410  QTextBlock block = qTextBlockAt(textEdit()->document(), child - childOffset - 1);
411  if (!block.isValid())
412  return;
413 
414  QTextCursor cursor(block);
416  cursor.insertText(text);
417 }
418 
421 {
422  if (child > childOffset)
423  return EditableText;
424  return QAccessibleWidgetEx::role(child);
425 }
426 
428  const QVariantList &params)
429 {
430  if (child)
431  return QVariant();
432 
433  switch (method) {
434  case ListSupportedMethods: {
438  QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
439  }
440  case SetCursorPosition:
441  setCursorPosition(params.value(0).toInt());
442  return true;
443  case GetCursorPosition:
444  return textEdit()->textCursor().position();
445  default:
446  return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
447  }
448 }
449 
451 {
452  return childOffset + textEdit()->document()->blockCount();
453 }
454 #endif // QT_NO_TEXTEDIT
455 
456 #ifndef QT_NO_STACKEDWIDGET
457 // ======================= QAccessibleStackedWidget ======================
460 {
461  Q_ASSERT(qobject_cast<QStackedWidget *>(widget));
462 }
463 
465 {
466  return QVariant();
467 }
468 
469 
470 int QAccessibleStackedWidget::childAt(int x, int y) const
471 {
472  if (!stackedWidget()->isVisible())
473  return -1;
474  QWidget *currentWidget = stackedWidget()->currentWidget();
475  if (!currentWidget)
476  return -1;
477  QPoint position = currentWidget->mapFromGlobal(QPoint(x, y));
478  if (currentWidget->rect().contains(position))
479  return 1;
480  return -1;
481 }
482 
484 {
485  return stackedWidget()->count();
486 }
487 
489 {
490  if (!child)
491  return -1;
492 
493  QWidget* widget = qobject_cast<QWidget*>(child->object());
494  int index = stackedWidget()->indexOf(widget);
495  if (index >= 0) // one based counting of children
496  return index + 1;
497  return -1;
498 }
499 
501 {
502  *target = 0;
503 
504  QObject *targetObject = 0;
505  switch (relation) {
506  case Child:
507  if (entry < 1 || entry > stackedWidget()->count())
508  return -1;
509  targetObject = stackedWidget()->widget(entry-1);
510  break;
511  default:
512  return QAccessibleWidgetEx::navigate(relation, entry, target);
513  }
514  *target = QAccessible::queryAccessibleInterface(targetObject);
515  return *target ? 0 : -1;
516 }
517 
519 {
520  return static_cast<QStackedWidget *>(object());
521 }
522 #endif // QT_NO_STACKEDWIDGET
523 
524 #ifndef QT_NO_TOOLBOX
525 // ======================= QAccessibleToolBox ======================
528 {
529  Q_ASSERT(qobject_cast<QToolBox *>(widget));
530 }
531 
532 QString QAccessibleToolBox::text(Text textType, int child) const
533 {
534  if (textType != Value || child <= 0 || child > toolBox()->count())
535  return QAccessibleWidgetEx::text(textType, child);
536  return toolBox()->itemText(child - 1);
537 }
538 
539 void QAccessibleToolBox::setText(Text textType, int child, const QString &text)
540 {
541  if (textType != Value || child <= 0 || child > toolBox()->count()) {
542  QAccessibleWidgetEx::setText(textType, child, text);
543  return;
544  }
545  toolBox()->setItemText(child - 1, text);
546 }
547 
549 {
550  QWidget *childWidget = toolBox()->widget(child - 1);
551  if (!childWidget)
552  return QAccessibleWidgetEx::state(child);
554  if (toolBox()->currentWidget() == childWidget)
555  childState |= QAccessible::Expanded;
556  else
557  childState |= QAccessible::Collapsed;
558  return childState;
559 }
560 
562 {
563  return QVariant();
564 }
565 
567 {
568  return toolBox()->count();
569 }
570 
572 {
573  if (!child)
574  return -1;
575  QWidget *childWidget = qobject_cast<QWidget *>(child->object());
576  if (!childWidget)
577  return -1;
578  int index = toolBox()->indexOf(childWidget);
579  if (index != -1)
580  ++index;
581  return index;
582 }
583 
584 int QAccessibleToolBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
585 {
586  *target = 0;
587  if (entry <= 0 || entry > toolBox()->count())
588  return QAccessibleWidgetEx::navigate(relation, entry, target);
589  int index = -1;
590  if (relation == QAccessible::Up)
591  index = entry - 2;
592  else if (relation == QAccessible::Down)
593  index = entry;
595  return *target ? 0: -1;
596 }
597 
599 {
600  return static_cast<QToolBox *>(object());
601 }
602 #endif // QT_NO_TOOLBOX
603 
604 // ======================= QAccessibleMdiArea ======================
605 #ifndef QT_NO_MDIAREA
608 {
609  Q_ASSERT(qobject_cast<QMdiArea *>(widget));
610 }
611 
613 {
614  if (child < 0)
615  return QAccessibleWidgetEx::state(child);
616  if (child == 0)
617  return QAccessible::Normal;
618  QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
619  if (subWindows.isEmpty() || child > subWindows.count())
620  return QAccessibleWidgetEx::state(child);
621  if (subWindows.at(child - 1) == mdiArea()->activeSubWindow())
622  return QAccessible::Focused;
623  return QAccessible::Normal;
624 }
625 
627 {
628  return QVariant();
629 }
630 
632 {
633  return mdiArea()->subWindowList().count();
634 }
635 
637 {
638  if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
639  return -1;
640  if (QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(child->object())) {
641  int index = mdiArea()->subWindowList().indexOf(window);
642  if (index != -1)
643  return ++index;
644  }
645  return -1;
646 }
647 
648 int QAccessibleMdiArea::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
649 {
650  *target = 0;
651  QWidget *targetObject = 0;
652  QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
653  switch (relation) {
654  case Child:
655  if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
656  return -1;
657  targetObject = subWindows.at(entry - 1);
658  break;
659  case Up:
660  case Down:
661  case Left:
662  case Right:
663  targetObject = mdiAreaNavigate(mdiArea(), relation, entry);
664  break;
665  default:
666  return QAccessibleWidgetEx::navigate(relation, entry, target);
667  }
668  *target = QAccessible::queryAccessibleInterface(targetObject);
669  return *target ? 0: -1;
670 }
671 
673 {
674  return static_cast<QMdiArea *>(object());
675 }
676 
677 // ======================= QAccessibleMdiSubWindow ======================
680 {
681  Q_ASSERT(qobject_cast<QMdiSubWindow *>(widget));
682 }
683 
684 QString QAccessibleMdiSubWindow::text(Text textType, int child) const
685 {
686  if (textType == QAccessible::Name && (child == 0 || child == 1)) {
687  QString title = mdiSubWindow()->windowTitle();
688  title.replace(QLatin1String("[*]"), QLatin1String(""));
689  return title;
690  }
691  return QAccessibleWidgetEx::text(textType, child);
692 }
693 
694 void QAccessibleMdiSubWindow::setText(Text textType, int child, const QString &text)
695 {
696  if (textType == QAccessible::Name && (child == 0 || child == 1))
697  mdiSubWindow()->setWindowTitle(text);
698  else
699  QAccessibleWidgetEx::setText(textType, child, text);
700 }
701 
703 {
704  if (child != 0 || !mdiSubWindow()->parent())
705  return QAccessibleWidgetEx::state(child);
707  if (!mdiSubWindow()->isMaximized())
711  state |= QAccessible::Focused;
712  if (!mdiSubWindow()->isVisible())
713  state |= QAccessible::Invisible;
714  if (!mdiSubWindow()->parentWidget()->contentsRect().contains(mdiSubWindow()->geometry()))
715  state |= QAccessible::Offscreen;
716  if (!mdiSubWindow()->isEnabled())
717  state |= QAccessible::Unavailable;
718  return state;
719 }
720 
722 {
723  return QVariant();
724 }
725 
727 {
728  if (mdiSubWindow()->widget())
729  return 1;
730  return 0;
731 }
732 
734 {
735  if (child && child->object() && child->object() == mdiSubWindow()->widget())
736  return 1;
737  return -1;
738 }
739 
741 {
742  *target = 0;
743 
744  if (!mdiSubWindow()->parent())
745  return QAccessibleWidgetEx::navigate(relation, entry, target);
746 
747  QWidget *targetObject = 0;
748  QMdiSubWindow *source = mdiSubWindow();
749  switch (relation) {
750  case Child:
751  if (entry != 1 || !source->widget())
752  return -1;
753  targetObject = source->widget();
754  break;
755  case Up:
756  case Down:
757  case Left:
758  case Right: {
759  if (entry != 0)
760  break;
761  QWidget *parent = source->parentWidget();
762  while (parent && !parent->inherits("QMdiArea"))
763  parent = parent->parentWidget();
764  QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parent);
765  if (!mdiArea)
766  break;
767  int index = mdiArea->subWindowList().indexOf(source);
768  if (index == -1)
769  break;
770  if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) {
772  return *target ? 0 : -1;
773  }
774  break;
775  }
776  default:
777  return QAccessibleWidgetEx::navigate(relation, entry, target);
778  }
779  *target = QAccessible::queryAccessibleInterface(targetObject);
780  return *target ? 0: -1;
781 }
782 
784 {
785  if (mdiSubWindow()->isHidden())
786  return QRect();
787  if (!mdiSubWindow()->parent())
788  return QAccessibleWidgetEx::rect(child);
789  const QPoint pos = mdiSubWindow()->mapToGlobal(QPoint(0, 0));
790  if (child == 0)
791  return QRect(pos, mdiSubWindow()->size());
792  if (child == 1 && mdiSubWindow()->widget()) {
793  if (mdiSubWindow()->widget()->isHidden())
794  return QRect();
795  const QRect contentsRect = mdiSubWindow()->contentsRect();
796  return QRect(pos.x() + contentsRect.x(), pos.y() + contentsRect.y(),
797  contentsRect.width(), contentsRect.height());
798  }
799  return QRect();
800 }
801 
802 int QAccessibleMdiSubWindow::childAt(int x, int y) const
803 {
804  if (!mdiSubWindow()->isVisible())
805  return -1;
806  if (!mdiSubWindow()->parent())
807  return QAccessibleWidgetEx::childAt(x, y);
808  const QRect globalGeometry = rect(0);
809  if (!globalGeometry.isValid())
810  return -1;
811  const QRect globalChildGeometry = rect(1);
812  if (globalChildGeometry.isValid() && globalChildGeometry.contains(QPoint(x, y)))
813  return 1;
814  if (globalGeometry.contains(QPoint(x, y)))
815  return 0;
816  return -1;
817 }
818 
820 {
821  return static_cast<QMdiSubWindow *>(object());
822 }
823 #endif // QT_NO_MDIAREA
824 
825 // ======================= QAccessibleWorkspace ======================
826 #ifndef QT_NO_WORKSPACE
829 {
830  Q_ASSERT(qobject_cast<QWorkspace *>(widget));
831 }
832 
834 {
835  if (child < 0)
836  return QAccessibleWidgetEx::state(child);
837  if (child == 0)
838  return QAccessible::Normal;
839  QWidgetList subWindows = workspace()->windowList();
840  if (subWindows.isEmpty() || child > subWindows.count())
841  return QAccessibleWidgetEx::state(child);
842  if (subWindows.at(child - 1) == workspace()->activeWindow())
843  return QAccessible::Focused;
844  return QAccessible::Normal;
845 }
846 
848 {
849  return QVariant();
850 }
851 
853 {
854  return workspace()->windowList().count();
855 }
856 
858 {
859  if (!child || !child->object() || workspace()->windowList().isEmpty())
860  return -1;
861  if (QWidget *window = qobject_cast<QWidget *>(child->object())) {
863  if (index != -1)
864  return ++index;
865  }
866  return -1;
867 }
868 
869 int QAccessibleWorkspace::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
870 {
871  *target = 0;
872  QWidget *targetObject = 0;
873  QWidgetList subWindows = workspace()->windowList();
874  switch (relation) {
875  case Child:
876  if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
877  return -1;
878  targetObject = subWindows.at(entry - 1);
879  break;
880  case Up:
881  case Down:
882  case Left:
883  case Right:
884  targetObject = mdiAreaNavigate(workspace(), relation, entry);
885  break;
886  default:
887  return QAccessibleWidgetEx::navigate(relation, entry, target);
888  }
889  *target = QAccessible::queryAccessibleInterface(targetObject);
890  return *target ? 0: -1;
891 }
892 
894 {
895  return static_cast<QWorkspace *>(object());
896 }
897 #endif
898 
899 #ifndef QT_NO_DIALOGBUTTONBOX
900 // ======================= QAccessibleDialogButtonBox ======================
902  : QAccessibleWidgetEx(widget, Grouping)
903 {
904  Q_ASSERT(qobject_cast<QDialogButtonBox*>(widget));
905 }
906 
908 {
909  return QVariant();
910 }
911 #endif // QT_NO_DIALOGBUTTONBOX
912 
913 #ifndef QT_NO_TEXTBROWSER
915  : QAccessibleTextEdit(widget)
916 {
917  Q_ASSERT(qobject_cast<QTextBrowser *>(widget));
918 }
919 
921 {
922  if (child != 0)
923  return QAccessibleTextEdit::role(child);
925 }
926 #endif // QT_NO_TEXTBROWSER
927 
928 #ifndef QT_NO_CALENDARWIDGET
929 // ===================== QAccessibleCalendarWidget ========================
931  : QAccessibleWidgetEx(widget, Table)
932 {
933  Q_ASSERT(qobject_cast<QCalendarWidget *>(widget));
934 }
935 
937 {
938  return QVariant();
939 }
940 
942 {
943  return calendarWidget()->isNavigationBarVisible() ? 2 : 1;
944 }
945 
947 {
948  if (!child || !child->object() || childCount() <= 0)
949  return -1;
950  if (qobject_cast<QAbstractItemView *>(child->object()))
951  return childCount();
952  return 1;
953 }
954 
956 {
957  *target = 0;
958  if (entry <= 0 || entry > childCount())
959  return QAccessibleWidgetEx::navigate(relation, entry, target);
960  QWidget *targetWidget = 0;
961  switch (relation) {
962  case Child:
963  if (childCount() == 1) {
964  targetWidget = calendarView();
965  } else {
966  if (entry == 1)
967  targetWidget = navigationBar();
968  else
969  targetWidget = calendarView();
970  }
971  break;
972  case Up:
973  if (entry == 2)
974  targetWidget = navigationBar();
975  break;
976  case Down:
977  if (entry == 1 && childCount() == 2)
978  targetWidget = calendarView();
979  break;
980  default:
981  return QAccessibleWidgetEx::navigate(relation, entry, target);
982  }
983  *target = queryAccessibleInterface(targetWidget);
984  return *target ? 0: -1;
985 }
986 
988 {
989  if (!calendarWidget()->isVisible() || child > childCount())
990  return QRect();
991  if (child == 0)
992  return QAccessibleWidgetEx::rect(child);
993  QWidget *childWidget = 0;
994  if (childCount() == 2)
995  childWidget = child == 1 ? navigationBar() : calendarView();
996  else
997  childWidget = calendarView();
998  return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size());
999 }
1000 
1001 int QAccessibleCalendarWidget::childAt(int x, int y) const
1002 {
1003  const QPoint globalTargetPos = QPoint(x, y);
1004  if (!rect(0).contains(globalTargetPos))
1005  return -1;
1006  if (rect(1).contains(globalTargetPos))
1007  return 1;
1008  if (rect(2).contains(globalTargetPos))
1009  return 2;
1010  return 0;
1011 }
1012 
1014 {
1015  return static_cast<QCalendarWidget *>(object());
1016 }
1017 
1019 {
1020  foreach (QObject *child, calendarWidget()->children()) {
1021  if (child->objectName() == QLatin1String("qt_calendar_calendarview"))
1022  return static_cast<QAbstractItemView *>(child);
1023  }
1024  return 0;
1025 }
1026 
1028 {
1029  foreach (QObject *child, calendarWidget()->children()) {
1030  if (child->objectName() == QLatin1String("qt_calendar_navigationbar"))
1031  return static_cast<QWidget *>(child);
1032  }
1033  return 0;
1034 }
1035 #endif // QT_NO_CALENDARWIDGET
1036 
1037 #ifndef QT_NO_DOCKWIDGET
1039  : QAccessibleWidgetEx(widget, Window)
1040 {
1041 
1042 }
1043 
1045 {
1046  if (relation == Child) {
1047  if (entry == 1) {
1048  *iface = new QAccessibleTitleBar(dockWidget());
1049  return 0;
1050  } else if (entry == 2) {
1051  if (dockWidget()->widget())
1053  return 0;
1054  }
1055  *iface = 0;
1056  return -1;
1057  }
1058  return QAccessibleWidgetEx::navigate(relation, entry, iface);
1059 }
1060 
1061 int QAccessibleDockWidget::childAt(int x, int y) const
1062 {
1063  for (int i = childCount(); i >= 0; --i) {
1064  if (rect(i).contains(x,y))
1065  return i;
1066  }
1067  return -1;
1068 }
1069 
1071 {
1072  return dockWidget()->widget() ? 2 : 1;
1073 }
1074 
1076 {
1077  if (child) {
1078  if (child->role(0) == TitleBar) {
1079  return 1;
1080  } else {
1081  return 2; //###
1082  }
1083  }
1084  return -1;
1085 }
1086 
1088 {
1089  switch (child) {
1090  case 0:
1091  return Window;
1092  case 1:
1093  return TitleBar;
1094  case 2:
1095  //###
1096  break;
1097  default:
1098  break;
1099  }
1100  return NoRole;
1101 }
1102 
1104 {
1105  //### mark tabified widgets as invisible
1106  return QAccessibleWidgetEx::state(child);
1107 }
1108 
1110 {
1111  QRect rect;
1112  bool mapToGlobal = true;
1113  if (child == 0) {
1114  if (dockWidget()->isFloating()) {
1115  rect = dockWidget()->frameGeometry();
1116  mapToGlobal = false;
1117  } else {
1118  rect = dockWidget()->rect();
1119  }
1120  }else if (child == 1) {
1122  rect = layout->titleArea();
1123  }else if (child == 2) {
1124  if (dockWidget()->widget())
1125  rect = dockWidget()->widget()->geometry();
1126  }
1127  if (rect.isNull())
1128  return rect;
1129 
1130  if (mapToGlobal)
1131  rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft()));
1132 
1133  return rect;
1134 }
1135 
1137 {
1138  return QVariant();
1139 }
1140 
1142 {
1143  return static_cast<QDockWidget *>(object());
1144 }
1145 
1147 // QAccessibleTitleBar
1150  : m_dockWidget(widget)
1151 {
1152 
1153 }
1154 
1155 int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
1156 {
1157  if (entry == 0 || relation == Self) {
1158  *iface = new QAccessibleTitleBar(dockWidget());
1159  return 0;
1160  }
1161  switch (relation) {
1162  case Child:
1163  case FocusChild:
1164  if (entry >= 1) {
1166  int index = 1;
1167  int role;
1169  QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
1170  if (!w->isVisible())
1171  continue;
1172  if (index == entry)
1173  break;
1174  ++index;
1175  }
1176  *iface = 0;
1177  return role > QDockWidgetLayout::FloatButton ? -1 : index;
1178  }
1179  break;
1180  case Ancestor:
1181  {
1183  int index;
1184  if (entry == 1) {
1185  *iface = target;
1186  return 0;
1187  }
1188  index = target->navigate(Ancestor, entry - 1, iface);
1189  delete target;
1190  return index;
1191 
1192  break;}
1193  case Sibling:
1194  return navigate(Child, entry, iface);
1195  break;
1196  default:
1197  break;
1198  }
1199  *iface = 0;
1200  return -1;
1201 }
1202 
1203 QAccessible::Relation QAccessibleTitleBar::relationTo(int /*child*/, const QAccessibleInterface * /*other*/, int /*otherChild*/) const
1204 {
1205  return Unrelated; //###
1206 }
1207 
1209 {
1210  return -1;
1211 }
1212 
1214 {
1216  int count = 0;
1219  if (w && w->isVisible())
1220  ++count;
1221  }
1222  return count;
1223 }
1224 
1226 {
1227  if (!child) {
1228  if (t == Name || t == Value) {
1229  return qt_accStripAmp(dockWidget()->windowTitle());
1230  }
1231  }
1232  return QString();
1233 }
1234 
1236 {
1238  if (child) {
1240  QAbstractButton *b = static_cast<QAbstractButton *>(layout->widgetForRole((QDockWidgetLayout::Role)child));
1241  if (b) {
1242  if (b->isDown())
1243  state |= Pressed;
1244  }
1245  } else {
1246  QDockWidget *w = dockWidget();
1247  if (w->testAttribute(Qt::WA_WState_Visible) == false)
1248  state |= Invisible;
1249  if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow())
1250  state |= Focusable;
1251  if (w->hasFocus())
1252  state |= Focused;
1253  if (!w->isEnabled())
1254  state |= Unavailable;
1255  }
1256 
1257  return state;
1258 }
1259 
1261 {
1262  bool mapToGlobal = true;
1263  QRect rect;
1264  if (child == 0) {
1265  if (dockWidget()->isFloating()) {
1266  rect = dockWidget()->frameGeometry();
1267  if (dockWidget()->widget()) {
1268  QPoint globalPos = dockWidget()->mapToGlobal(dockWidget()->widget()->rect().topLeft());
1269  globalPos.ry()--;
1270  rect.setBottom(globalPos.y());
1271  mapToGlobal = false;
1272  }
1273  } else {
1275  rect = layout->titleArea();
1276  }
1277  }else if (child >= 1 && child <= childCount()) {
1279  int index = 1;
1282  if (!w || !w->isVisible())
1283  continue;
1284  if (index == child) {
1285  rect = w->geometry();
1286  break;
1287  }
1288  ++index;
1289  }
1290  }
1291  if (rect.isNull())
1292  return rect;
1293 
1294  if (mapToGlobal)
1295  rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft()));
1296  return rect;
1297 }
1298 
1299 int QAccessibleTitleBar::childAt(int x, int y) const
1300 {
1301  for (int i = childCount(); i >= 0; --i) {
1302  if (rect(i).contains(x,y))
1303  return i;
1304  }
1305  return -1;
1306 }
1307 
1309 {
1310  return 0;
1311 }
1312 
1314 {
1316 }
1317 
1319 {
1320  return m_dockWidget;
1321 }
1322 
1323 QString QAccessibleTitleBar::actionText(int action, Text t, int child) const
1324 {
1325  QString str;
1326  if (child >= 1 && child <= childCount()) {
1327  if (t == Name) {
1328  switch (action) {
1329  case Press:
1330  case DefaultAction:
1331  if (child == QDockWidgetLayout::CloseButton) {
1332  str = QDockWidget::tr("Close");
1333  } else if (child == QDockWidgetLayout::FloatButton) {
1334  str = dockWidget()->isFloating() ? QDockWidget::tr("Dock")
1335  : QDockWidget::tr("Float");
1336  }
1337  break;
1338  default:
1339  break;
1340  }
1341  }
1342  }
1343  return str;
1344 }
1345 
1346 bool QAccessibleTitleBar::doAction(int action, int child, const QVariantList& /*params*/)
1347 {
1348  if (!child || !dockWidget()->isEnabled())
1349  return false;
1350 
1351  switch (action) {
1352  case DefaultAction:
1353  case Press: {
1355  QAbstractButton *btn = static_cast<QAbstractButton *>(layout->widgetForRole((QDockWidgetLayout::Role)child));
1356  if (btn)
1357  btn->animateClick();
1358  return true;
1359  break;}
1360  default:
1361  break;
1362  }
1363 
1364  return false;
1365 }
1366 
1367 int QAccessibleTitleBar::userActionCount (int /*child*/) const
1368 {
1369  return 0;
1370 }
1371 
1373 {
1374  switch (child) {
1375  case 0:
1376  return TitleBar;
1377  break;
1378  default:
1379  if (child >= 1 && child <= childCount())
1380  return PushButton;
1381  break;
1382  }
1383 
1384  return NoRole;
1385 }
1386 
1387 void QAccessibleTitleBar::setText(Text /*t*/, int /*child*/, const QString &/*text*/)
1388 {
1389 
1390 }
1391 
1393 {
1394  return dockWidget();
1395 }
1396 
1397 #endif // QT_NO_DOCKWIDGET
1398 
1400  QAccessibleWidgetEx(o, r, name)
1401 {
1402 }
1403 
1404 void QAccessibleTextWidget::setAttributes(int startOffset, int endOffset, const QString& attributes)
1405 {
1406  //TODO: not implemented
1407  Q_UNUSED(startOffset);
1408  Q_UNUSED(endOffset);
1409  Q_UNUSED(attributes);
1410 }
1411 
1413 {
1414  QTextBlock block = textDocument()->findBlock(offset);
1415  if (!block.isValid())
1416  return QRect();
1417 
1418  QTextLayout *layout = block.layout();
1419  QPointF layoutPosition = layout->position();
1420  int relativeOffset = offset - block.position();
1421  QTextLine line = layout->lineForTextPosition(relativeOffset);
1422 
1423  QRect r;
1424 
1425  if (line.isValid()) {
1426  qreal x = line.cursorToX(relativeOffset);
1427  qreal w = 0;
1428 
1429  if ((relativeOffset - line.textStart())< line.textLength()) {
1430  w = line.cursorToX(relativeOffset + 1) - x;
1431  } else {
1432  // If the width of a character is not known, IAccessible2 tells to return the width of a default character
1433  int averageCharWidth = QFontMetrics(textCursor().charFormat().font()).averageCharWidth();
1434  if (block.blockFormat().layoutDirection() == Qt::RightToLeft)
1435  averageCharWidth *= -1;
1436 
1437  r.setWidth(averageCharWidth);
1438  }
1439  int height = line.height();
1440 
1441  // make sure that height does not include leading. (only ascent + descent + 1)
1442  if (line.leadingIncluded())
1443  height -= qRound(line.leading());
1444  r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y(),
1445  w, height);
1446 
1447  if (coordType == RelativeToScreen) {
1448  r.moveTo(viewport()->mapToGlobal(r.topLeft()));
1449  }
1450 
1452  }
1453 
1454  return r;
1455 }
1456 
1458 {
1459  QPoint p = point;
1460  if (coordType == RelativeToScreen)
1461  p = viewport()->mapFromGlobal(p);
1462 
1463  p += scrollBarPosition();
1464 
1466 }
1467 
1469 {
1470  return textCursor().hasSelection() ? 1 : 0;
1471 }
1472 
1473 QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *endOffset)
1474 {
1475  /* The list of attributes can be found at:
1476  http://linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2/textattributes
1477  */
1478 
1479  if (offset >= characterCount()) {
1480  *startOffset = -1;
1481  *endOffset = -1;
1482  return QString();
1483  }
1484 
1485  QMap<QString, QString> attrs;
1486 
1487  QTextCursor cursor = textCursor();
1488 
1489  //cursor.charFormat returns the format of the previous character
1490  cursor.setPosition(offset + 1);
1491  QTextCharFormat charFormat = cursor.charFormat();
1492 
1493  cursor.setPosition(offset);
1494  QTextBlockFormat blockFormat = cursor.blockFormat();
1495 
1496  QTextCharFormat charFormatComp;
1497  QTextBlockFormat blockFormatComp;
1498 
1499  *startOffset = offset;
1500  cursor.setPosition(*startOffset);
1501  while (*startOffset > 0) {
1502  charFormatComp = cursor.charFormat();
1503  cursor.setPosition(*startOffset - 1);
1504  blockFormatComp = cursor.blockFormat();
1505  if ((charFormat == charFormatComp) && (blockFormat == blockFormatComp))
1506  (*startOffset)--;
1507  else
1508  break;
1509  }
1510 
1511  int limit = characterCount() + 1;
1512  *endOffset = offset + 1;
1513  cursor.setPosition(*endOffset);
1514  while (*endOffset < limit) {
1515  blockFormatComp = cursor.blockFormat();
1516  cursor.setPosition(*endOffset + 1);
1517  charFormatComp = cursor.charFormat();
1518  if ((charFormat == charFormatComp) && (cursor.blockFormat() == blockFormatComp))
1519  (*endOffset)++;
1520  else
1521  break;
1522  }
1523 
1524  QString family = charFormat.fontFamily();
1525  if (!family.isEmpty()) {
1526  family = family.replace('\\',"\\\\");
1527  family = family.replace(':',"\\:");
1528  family = family.replace(',',"\\,");
1529  family = family.replace('=',"\\=");
1530  family = family.replace(';',"\\;");
1531  family = family.replace('\"',"\\\"");
1532  attrs["font-family"] = '"'+family+'"';
1533  }
1534 
1535  int fontSize = int(charFormat.fontPointSize());
1536  if (fontSize)
1537  attrs["font-size"] = QString::number(fontSize).append("pt");
1538 
1539  //Different weight values are not handled
1540  attrs["font-weight"] = (charFormat.fontWeight() > QFont::Normal) ? "bold" : "normal";
1541 
1542  QFont::Style style = charFormat.font().style();
1543  attrs["font-style"] = (style == QFont::StyleItalic) ? "italic" : ((style == QFont::StyleOblique) ? "oblique": "normal");
1544 
1545  attrs["text-underline-style"] = charFormat.font().underline() ? "solid" : "none";
1546 
1547  QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment();
1548  attrs["text-position"] = (alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" );
1549 
1550  QBrush background = charFormat.background();
1551  if (background.style() == Qt::SolidPattern) {
1552  attrs["background-color"] = QString("rgb(%1,%2,%3)").arg(background.color().red()).arg(background.color().green()).arg(background.color().blue());
1553  }
1554 
1555  QBrush foreground = charFormat.foreground();
1556  if (foreground.style() == Qt::SolidPattern) {
1557  attrs["color"] = QString("rgb(%1,%2,%3)").arg(foreground.color().red()).arg(foreground.color().green()).arg(foreground.color().blue());
1558  }
1559 
1560  switch (blockFormat.alignment() & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter | Qt::AlignJustify)) {
1561  case Qt::AlignLeft:
1562  attrs["text-align"] = "left";
1563  break;
1564  case Qt::AlignRight:
1565  attrs["text-align"] = "right";
1566  break;
1567  case Qt::AlignHCenter:
1568  attrs["text-align"] = "center";
1569  break;
1570  case Qt::AlignJustify:
1571  attrs["text-align"] = "left";
1572  break;
1573  }
1574 
1575  QString result;
1576  foreach (const QString &attributeName, attrs.keys()) {
1577  result.append(attributeName).append(':').append(attrs[attributeName]).append(';');
1578  }
1579 
1580  return result;
1581 }
1582 
1584 {
1585  return textCursor().position();
1586 }
1587 
1588 void QAccessibleTextWidget::selection(int selectionIndex, int *startOffset, int *endOffset)
1589 {
1590  *startOffset = *endOffset = 0;
1591  QTextCursor cursor = textCursor();
1592 
1593  if (selectionIndex != 0 || !cursor.hasSelection())
1594  return;
1595 
1596  *startOffset = cursor.selectionStart();
1597  *endOffset = cursor.selectionEnd();
1598 }
1599 
1600 QString QAccessibleTextWidget::text(int startOffset, int endOffset)
1601 {
1602  QTextCursor cursor = textCursor();
1603 
1604  cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
1605  cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
1606 
1607  return cursor.selectedText();
1608 }
1609 
1611 {
1612  return QPoint(0, 0);
1613 }
1614 
1616 {
1617  if (offset >= characterCount())
1619  if (offset < 0)
1620  return QPair<int, int>(0, 0);
1621 
1622  QTextCursor cursor = textCursor();
1623 
1624  QPair<int, int> result;
1625 
1626  cursor.setPosition(offset);
1627  switch (boundaryType) {
1628  case CharBoundary:
1629  result.first = cursor.position();
1631  result.second = cursor.position();
1632  break;
1633  case WordBoundary:
1634  cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
1635  result.first = cursor.position();
1636  cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
1637  result.second = cursor.position();
1638  break;
1639  case SentenceBoundary:
1640  // TODO - what's a sentence?
1641  case LineBoundary:
1642  cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
1643  result.first = cursor.position();
1644  cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
1645  result.second = cursor.position();
1646  break;
1647  case ParagraphBoundary:
1648  cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
1649  result.first = cursor.position();
1650  cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
1651  result.second = cursor.position();
1652  break;
1653  case NoBoundary:
1654  result.first = 0;
1655  result.second = characterCount();
1656  break;
1657  default:
1658  qDebug("QAccessibleTextWidget::getBoundaries: Unknown boundary type %d", boundaryType);
1659  result.first = -1;
1660  result.second = -1;
1661  }
1662  return result;
1663 }
1664 
1666  int *startOffset, int *endOffset)
1667 {
1668  Q_ASSERT(startOffset);
1669  Q_ASSERT(endOffset);
1670 
1671  QPair<int, int> boundaries = getBoundaries(offset, boundaryType);
1672  boundaries = getBoundaries(boundaries.first - 1, boundaryType);
1673 
1674  *startOffset = boundaries.first;
1675  *endOffset = boundaries.second;
1676 
1677  return text(boundaries.first, boundaries.second);
1678 }
1679 
1681  int *startOffset, int *endOffset)
1682 {
1683  Q_ASSERT(startOffset);
1684  Q_ASSERT(endOffset);
1685 
1686  QPair<int, int> boundaries = getBoundaries(offset, boundaryType);
1687  boundaries = getBoundaries(boundaries.second, boundaryType);
1688 
1689  *startOffset = boundaries.first;
1690  *endOffset = boundaries.second;
1691 
1692  return text(boundaries.first, boundaries.second);
1693 }
1694 
1696  int *startOffset, int *endOffset)
1697 {
1698  Q_ASSERT(startOffset);
1699  Q_ASSERT(endOffset);
1700 
1701  QPair<int, int> boundaries = getBoundaries(offset, boundaryType);
1702 
1703  *startOffset = boundaries.first;
1704  *endOffset = boundaries.second;
1705 
1706  return text(boundaries.first, boundaries.second);
1707 }
1708 
1710 {
1711  QTextCursor cursor = textCursor();
1712  cursor.setPosition(position);
1713  setTextCursor(cursor);
1714 }
1715 
1716 void QAccessibleTextWidget::addSelection(int startOffset, int endOffset)
1717 {
1718  setSelection(0, startOffset, endOffset);
1719 }
1720 
1722 {
1723  if (selectionIndex != 0)
1724  return;
1725 
1726  QTextCursor cursor = textCursor();
1727  cursor.clearSelection();
1728  setTextCursor(cursor);
1729 }
1730 
1731 void QAccessibleTextWidget::setSelection(int selectionIndex, int startOffset, int endOffset)
1732 {
1733  if (selectionIndex != 0)
1734  return;
1735 
1736  QTextCursor cursor = textCursor();
1737  cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
1738  cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
1739  setTextCursor(cursor);
1740 }
1741 
1743 {
1744  QTextCursor cursor = textCursor();
1746  return cursor.position();
1747 }
1748 
1749 QTextCursor QAccessibleTextWidget::textCursorForRange(int startOffset, int endOffset) const
1750 {
1751  QTextCursor cursor = textCursor();
1752  cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
1753  cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
1754 
1755  return cursor;
1756 }
1757 
1758 void QAccessibleTextWidget::deleteText(int startOffset, int endOffset)
1759 {
1760  QTextCursor cursor = textCursorForRange(startOffset, endOffset);
1761 
1762  cursor.removeSelectedText();
1763 }
1764 
1766 {
1767  QTextCursor cursor = textCursor();
1768  cursor.setPosition(offset);
1769 
1770  cursor.insertText(text);
1771 }
1772 
1773 void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QString &text)
1774 {
1775  QTextCursor cursor = textCursorForRange(startOffset, endOffset);
1776 
1777  cursor.removeSelectedText();
1778  cursor.insertText(text);
1779 }
1780 
1781 void QAccessibleTextWidget::copyText(int startOffset, int endOffset)
1782 {
1783 #ifndef QT_NO_CLIPBOARD
1784  QString text = this->text(startOffset, endOffset);
1786 #endif
1787 }
1788 
1789 void QAccessibleTextWidget::cutText(int startOffset, int endOffset)
1790 {
1791 #ifndef QT_NO_CLIPBOARD
1792  QString text = this->text(startOffset, endOffset);
1794  deleteText(startOffset, endOffset);
1795 #endif
1796 }
1797 
1799 {
1800 #ifndef QT_NO_CLIPBOARD
1802  insertText(offset, text);
1803 #endif
1804 }
1805 
1806 #ifndef QT_NO_TEXTEDIT
1807 void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex)
1808 {
1809  QTextEdit *edit = textEdit();
1810 
1811  QTextCursor cursor(edit->document());
1812  cursor.setPosition(startIndex);
1813  QRect r = edit->cursorRect(cursor);
1814 
1815  cursor.setPosition(endIndex);
1816  r.setBottomRight(edit->cursorRect(cursor).bottomRight());
1817 
1818  r.moveTo(r.x() + edit->horizontalScrollBar()->value(),
1819  r.y() + edit->verticalScrollBar()->value());
1820 
1821  // E V I L, but ensureVisible is not public
1822  if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r)))
1823  qWarning("AccessibleTextEdit::scrollToSubstring failed!");
1824 }
1825 
1826 void QAccessibleTextEdit::copyText(int startOffset, int endOffset)
1827 {
1828 #ifndef QT_NO_CLIPBOARD
1829  QTextCursor previousCursor = textEdit()->textCursor();
1830  QTextCursor cursor = textCursorForRange(startOffset, endOffset);
1831 
1832  if (!cursor.hasSelection())
1833  return;
1834 
1835  textEdit()->setTextCursor(cursor);
1836  textEdit()->copy();
1837  textEdit()->setTextCursor(previousCursor);
1838 #endif
1839 }
1840 
1841 void QAccessibleTextEdit::cutText(int startOffset, int endOffset)
1842 {
1843 #ifndef QT_NO_CLIPBOARD
1844  QTextCursor cursor = textCursorForRange(startOffset, endOffset);
1845 
1846  if (!cursor.hasSelection())
1847  return;
1848 
1849  textEdit()->setTextCursor(cursor);
1850  textEdit()->cut();
1851 #endif
1852 }
1853 
1855 {
1856  QTextEdit *edit = textEdit();
1857 
1858  QTextCursor oldCursor = edit->textCursor();
1859  QTextCursor newCursor = oldCursor;
1860  newCursor.setPosition(offset);
1861 
1862  edit->setTextCursor(newCursor);
1863 #ifndef QT_NO_CLIPBOARD
1864  edit->paste();
1865 #endif
1866  edit->setTextCursor(oldCursor);
1867 }
1868 
1869 void QAccessibleTextEdit::setAttributes(int startOffset, int endOffset, const QString &attributes)
1870 {
1871  // TODO
1872  Q_UNUSED(startOffset);
1873  Q_UNUSED(endOffset);
1874  Q_UNUSED(attributes);
1875 }
1876 
1877 #endif // QT_NO_TEXTEDIT
1878 
1879 #ifndef QT_NO_MAINWINDOW
1881  : QAccessibleWidgetEx(widget, Window) { }
1882 
1884 {
1885  return QVariant();
1886 }
1887 
1889 {
1890  QList<QWidget*> kids = childWidgets(mainWindow(), true);
1891  return kids.count();
1892 }
1893 
1895 {
1896  QList<QWidget*> kids = childWidgets(mainWindow(), true);
1897  int childIndex = kids.indexOf(static_cast<QWidget*>(iface->object()));
1898  return childIndex == -1 ? -1 : ++childIndex;
1899 }
1900 
1902 {
1903  if (relation == Child && entry >= 1) {
1904  QList<QWidget*> kids = childWidgets(mainWindow(), true);
1905  if (entry <= kids.count()) {
1906  *iface = QAccessible::queryAccessibleInterface(kids.at(entry - 1));
1907  return *iface ? 0 : -1;
1908  }
1909  }
1910  return QAccessibleWidgetEx::navigate(relation, entry, iface);
1911 }
1912 
1913 int QAccessibleMainWindow::childAt(int x, int y) const
1914 {
1915  QWidget *w = widget();
1916  if (!w->isVisible())
1917  return -1;
1918  QPoint gp = w->mapToGlobal(QPoint(0, 0));
1919  if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
1920  return -1;
1921 
1922  QWidgetList kids = childWidgets(mainWindow(), true);
1923  QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y));
1924  for (int i = 0; i < kids.size(); ++i) {
1925  QWidget *child = kids.at(i);
1926  if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
1927  return i + 1;
1928  }
1929  }
1930  return 0;
1931 }
1932 
1934 {
1935  return qobject_cast<QMainWindow *>(object());
1936 }
1937 
1938 #endif //QT_NO_MAINWINDOW
1939 
1941 
1942 #endif // QT_NO_ACCESSIBILITY
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QAccessibleTextBrowser(QWidget *widget)
QMdiArea * mdiArea() const
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
QList< QWidget * > childWidgets(const QWidget *widget, bool includeTopLevel)
T qobject_cast(QObject *object)
Definition: qobject.h:375
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
QWorkspace * workspace() const
void cutText(int startOffset, int endOffset)
QTextDocument * textDocument() const
QTextCursor cursorForPosition(const QPoint &pos) const
returns a QTextCursor at position pos (in viewport coordinates).
Definition: qtextedit.cpp:1863
QFont font() const
Returns the font for this character format.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QString text() const
Returns the block&#39;s contents as plain text.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
The QAccessible2 namespace defines constants relating to IAccessible2-based interfaces.
Definition: qaccessible.h:347
QPointF position() const
The global position of the layout.
QAccessibleTextEdit(QWidget *o)
Constructs a QAccessibleTextEdit object for a widget.
QToolBox * toolBox() const
The QToolBox class provides a column of tabbed widget items.
Definition: qtoolbox.h:58
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
double qreal
Definition: qglobal.h:1193
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
QTextEdit * textEdit() const
Returns the text edit.
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
void setTextCursor(const QTextCursor &textCursor)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
qreal y() const
Returns the line&#39;s y position.
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
QString itemText(int index) const
Returns the text of the item at position index, or an empty string if index is out of range...
Definition: qtoolbox.cpp:689
#define QT_NO_WORKSPACE
QPointer< QWidget > widget
QTextCursor textCursorForRange(int startOffset, int endOffset) const
virtual QTextCursor textCursor() const =0
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
QAccessibleTextWidget(QWidget *o, Role r=EditableText, const QString &name=QString())
int childCount() const
Returns the number of children that belong to this object.
int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType)
QTextBlock begin() const
Returns the document&#39;s first text block.
QString text(int startOffset, int endOffset)
int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
int childCount() const
Returns the number of children that belong to this object.
QRect contentsRect() const
Returns the area inside the widget&#39;s margins.
Definition: qwidget.cpp:7544
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
int childCount() const
Returns the number of children that belong to this object.
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition: qfont.cpp:1320
int blockCount
Returns the number of text blocks in the document.
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
bool isVisible() const
Definition: qwidget.h:1005
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn&#39;t have a selection.
QString objectName
the name of this object
Definition: qobject.h:114
The QCalendarWidget class provides a monthly based calendar widget allowing the user to select a date...
QTextDocument * document() const
Returns a pointer to the underlying document.
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QAccessibleMainWindow(QWidget *widget)
Role
This enum defines the role of an accessible object.
Definition: qaccessible.h:188
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void paste()
Pastes the text from the clipboard into the text edit at the current cursor position.
Definition: qtextedit.cpp:1036
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QRect intersect(const QRect &r) const
Use intersected(rectangle) instead.
Definition: qrect.h:476
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
bool doAction(int action, int child, const QVariantList &params=QVariantList())
Asks the object, or the object&#39;s child if child is not 0, to execute action using the parameters...
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
#define QT_NO_MDIAREA
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
T1 first
Definition: qpair.h:65
Style style() const
Returns the style of the font.
Definition: qfont.cpp:1223
virtual void setTextCursor(const QTextCursor &)=0
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
QAccessibleStackedWidget(QWidget *widget)
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QAccessibleCalendarWidget(QWidget *widget)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void insertText(int offset, const QString &text)
int textLength() const
Returns the length of the text in the line.
Role role(int child) const
Reimplemented Function
T2 second
Definition: qpair.h:66
bool isDown() const
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
qreal leading() const
Returns the line&#39;s leading.
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QString text(Text t, int child) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
QDockWidget * dockWidget() const
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setCursorPosition(int position)
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QWidget * widget() const
Returns the widget for the dock widget.
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:334
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
void setItemText(int index, const QString &text)
Sets the text of the item at position index to text.
Definition: qtoolbox.cpp:639
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int indexOfChild(const QAccessibleInterface *iface) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
bool isActiveWindow() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool hasFocus() const
Definition: qwidget.cpp:6583
virtual QObject * object() const =0
Returns a pointer to the QObject this interface implementation provides information for...
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
void setText(const QString &, Mode mode=Clipboard)
Copies text into the clipboard as plain text.
Definition: qclipboard.cpp:375
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int childCount() const
Returns the number of children that belong to this object.
Qt::Alignment alignment() const
Returns the paragraph&#39;s alignment.
Definition: qtextformat.h:561
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
QString selectedText() const
Returns the current selection&#39;s text (which may be empty).
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
void insertText(const QString &text)
Inserts text at the current position, using the current character format.
Qt::FocusPolicy focusPolicy() const
QWidgetList windowList(WindowOrder order=CreationOrder) const
Returns a list of all visible or minimized child windows.
QPair< int, int > getBoundaries(int offset, QAccessible2::BoundaryType boundaryType)
int childCount() const
Returns the number of children that belong to this object.
Qt::LayoutDirection layoutDirection() const
Returns the document&#39;s layout direction.
Definition: qtextformat.h:340
bool isNavigationBarVisible() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void setText(Text t, int child, const QString &text)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
Definition: qtextedit.cpp:813
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
QWidget * widget(int) const
Returns the widget at the given index, or 0 if there is no such widget.
The QWorkspace widget provides a workspace window that can be used in an MDI application.
Definition: qworkspace.h:60
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
int position() const
Returns the index of the block&#39;s first character within the document.
QRect cursorRect(const QTextCursor &cursor) const
returns a rectangle (in viewport coordinates) that includes the cursor.
Definition: qtextedit.cpp:1873
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
QString toPlainText() const
Returns the text of the text edit as plain text.
Definition: qtextedit.h:189
bool leadingIncluded() const
Returns true if positive leading is included into the line&#39;s height; otherwise returns false...
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
int count
the number of widgets contained by this stacked widget
QWidget * viewport() const
Returns the viewport widget.
Q_CORE_EXPORT void qDebug(const char *,...)
void setAttributes(int startOffset, int endOffset, const QString &attributes)
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
int childCount() const
Returns the number of children that belong to this object.
VerticalAlignment
This enum describes the ways that adjacent characters can be vertically aligned.
Definition: qtextformat.h:375
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
QPlainTextEdit * plainTextEdit() const
NSWindow * window
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void setText(Text t, int control, const QString &text)
Reimplemented Function
qreal cursorToX(int *cursorPos, Edge edge=Leading) const
Converts the cursor position cursorPos to the corresponding x position inside the line...
int value() const
void scrollToSubstring(int startIndex, int endIndex)
QWidget * widget(int index) const
Returns the widget at position index, or 0 if there is no such item.
Definition: qtoolbox.cpp:571
int averageCharWidth() const
Returns the average width of glyphs in the font.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
static int qTextBlockPosition(QTextBlock block)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
QPoint bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:291
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
void deleteText(int startOffset, int endOffset)
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
QWidget * widget() const
Returns the current internal widget.
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QDockWidget * dockWidget() const
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
RelationFlag
This enum type defines bit flags that can be combined to indicate the relationship between two access...
Definition: qaccessible.h:268
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
QAccessibleToolBox(QWidget *widget)
Method
This enum describes the possible types of methods that can be invoked on an accessible object...
Definition: qaccessible.h:311
void setTextCursor(const QTextCursor &textCursor)
const char * name
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition: qmdiarea.h:59
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QCalendarWidget * calendarWidget() const
const char * layout
QString attributes(int offset, int *startOffset, int *endOffset)
static QTextBlock qTextBlockAt(const QTextDocument *doc, int pos)
QList< QMdiSubWindow * > subWindowList(WindowOrder order=CreationOrder) const
Returns a list of all subwindows in the MDI area.
Definition: qmdiarea.cpp:1888
void setText(Text t, int child, const QString &text)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
int fontWeight() const
Returns the text format&#39;s font weight.
Definition: qtextformat.h:413
QPoint scrollBarPosition() const
Q_CORE_EXPORT void qWarning(const char *,...)
int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
int childCount() const
Returns the number of children that belong to this object.
QRect characterRect(int offset, QAccessible2::CoordinateType coordType)
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int indexOf(QWidget *widget) const
Returns the index of widget, or -1 if the item does not exist.
Definition: qtoolbox.cpp:584
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
The QPlainTextEdit class provides a widget that is used to edit and display plain text...
QString windowTitle() const
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
QAccessibleTitleBar(QDockWidget *widget)
QMdiSubWindow * mdiSubWindow() const
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
void select(SelectionType selection)
Selects text in the document according to the given selection.
QList< Key > keys() const
Returns a list containing all the keys in the map in ascending order.
Definition: qmap.h:818
void copyText(int startOffset, int endOffset)
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
int position() const
Returns the absolute position of the cursor within the document.
QBrush background() const
Returns the brush used to paint the document&#39;s background.
Definition: qtextformat.h:345
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
QTextCursor textCursor() const
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text)
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
Style
This enum describes the different styles of glyphs that are used to display text. ...
Definition: qfont.h:111
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
void removeSelectedText()
If there is a selection, its content is deleted; otherwise does nothing.
QRect rect() const
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
QTextBlock block() const
Returns the block that contains the cursor.
void setBottomRight(const QPoint &p)
Set the bottom-right corner of the rectangle to the given position.
Definition: qrect.h:273
int childCount() const
Returns the number of children that belong to this object.
bool isEnabled() const
Definition: qwidget.h:948
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
void clearSelection()
Clears the current selection by setting the anchor to the cursor position.
QWidget * currentWidget() const
Returns the current widget, or 0 if there are no child widgets.
Role role(int child) const
Reimplemented Function
QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset)
virtual QTextDocument * textDocument() const =0
QTextCursor textCursor() const
void setAttributes(int startOffset, int endOffset, const QString &attributes)
void addSelection(int startOffset, int endOffset)
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
virtual QWidget * viewport() const =0
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QAccessibleDockWidget(QWidget *widget)
VerticalAlignment verticalAlignment() const
Returns the vertical alignment used for characters with this format.
Definition: qtextformat.h:486
QMdiSubWindow * activeSubWindow() const
Returns a pointer to the current active subwindow.
Definition: qmdiarea.cpp:1832
virtual Role role(int child) const =0
Returns the role of the object, or of the object&#39;s child if child is not 0.
The QAbstractItemView class provides the basic functionality for item view classes.
The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors.
QMainWindow * mainWindow() const
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
Definition: qtextedit.cpp:824
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
QStackedWidget * stackedWidget() const
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QTextDocument * textDocument() const
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QRect titleArea() const
virtual QRectF blockBoundingRect(const QTextBlock &block) const =0
Returns the bounding rectangle of block.
QAccessibleMdiArea(QWidget *widget)
QString & append(QChar c)
Definition: qstring.cpp:1777
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
QVariant invokeMethodEx(Method method, int child, const QVariantList &params)
void selection(int selectionIndex, int *startOffset, int *endOffset)
virtual QPoint scrollBarPosition() const
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QString textBeforeOffset(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset)
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
State
Definition: qaudio.h:59
QAccessibleMdiSubWindow(QWidget *widget)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
QTextBlock findBlock(int pos) const
Returns the text block that contains the {pos}-th character.
QWidget * widget() const
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
QRect frameGeometry() const
QDockWidgetLayout * dockWidgetLayout() const
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QString text(Text textType, int child) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
void setText(Text textType, int child, const QString &text)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
int indexOf(QWidget *) const
Returns the index of the given widget, or -1 if the given widget is not a child of the QStackedWidget...
void setWidth(int w)
Sets the width of the rectangle to the given width.
Definition: qrect.h:442
QBrush foreground() const
Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
Definition: qtextformat.h:352
QWidget * viewport() const
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child...
Definition: qwidget.cpp:8573
QString objectName() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
bool isFloating() const
Definition: qdockwidget.h:96
int childCount() const
Returns the number of children that belong to this object.
int count
The number of items contained in the toolbox.
Definition: qtoolbox.h:62
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
void removeSelection(int selectionIndex)
QAccessibleDialogButtonBox(QWidget *widget)
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.
void setText(Text textType, int child, const QString &text)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset)
void cutText(int startOffset, int endOffset)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
quint16 index
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
int userActionCount(int child) const
Returns the number of custom actions of the object, or of the object&#39;s child if child is not 0...
int childCount() const
Returns the number of children that belong to this object.
QAccessibleWorkspace(QWidget *widget)
int childCount() const
Returns the number of children that belong to this object.
QWidget * widgetForRole(Role r) const
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void replaceText(int startOffset, int endOffset, const QString &text)
int childCount() const
Returns the number of children that belong to this object.
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
QString text(Text t, int child) const
Reimplemented Function
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const =0
Returns the cursor postion for the given point with the specified accuracy.
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
qreal fontPointSize() const
Returns the font size used to display text in this format.
Definition: qtextformat.h:408
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const
Returns the relationship between this object&#39;s \a child and the \a other object&#39;s \a otherChild...
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QString text(Text t, int child) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
static QWidget * mdiAreaNavigate(QWidget *area, QAccessible::RelationFlag relation, int entry)
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QAbstractItemView * calendarView() const
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
void copyText(int startOffset, int endOffset)
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time...
void pasteText(int offset)
QString fontFamily() const
Returns the text format&#39;s font family.
Definition: qtextformat.h:403
QString actionText(int action, Text t, int child) const
Returns the text property t of the action action supported by the object, or of the object&#39;s child if...
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
QPointer< QDockWidget > m_dockWidget
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
QString text(Mode mode=Clipboard) const
Returns the clipboard text as plain text, or an empty string if the clipboard does not contain any te...
Definition: qclipboard.cpp:357
void setText(const QString &text)
Sets the text edit&#39;s text.
Definition: qtextedit.cpp:2591
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
#define INT_MAX
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
qreal height() const
Returns the line&#39;s height.
void scrollToSubstring(int startIndex, int endIndex)
int indexOfChild(const QAccessibleInterface *child) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
The QMdiSubWindow class provides a subwindow class for QMdiArea.
Definition: qmdisubwindow.h:60
QString text(Text textType, int child) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn&#39;t have a selection.
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
#define text
Definition: qobjectdefs.h:80
The QAccessible class provides enums and static functions relating to accessibility.
Definition: qaccessible.h:64
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
static int area(const QSize &s)
Definition: qicon.cpp:155
void animateClick(int msec=100)
Performs an animated click: the button is pressed immediately, and released msec milliseconds later (...
The Text item allows you to add formatted text to a scene.
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QWidget * activeWindow() const
Returns a pointer to the widget corresponding to the active child window, or 0 if no window is active...
void setSelection(int selectionIndex, int startOffset, int endOffset)
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block&#39;s contents. ...