Qt 4.8
qaccessiblewidget.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 QtGui module 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 "qaccessiblewidget.h"
43 
44 #ifndef QT_NO_ACCESSIBILITY
45 
46 #include "qaction.h"
47 #include "qapplication.h"
48 #include "qgroupbox.h"
49 #include "qlabel.h"
50 #include "qtooltip.h"
51 #include "qwhatsthis.h"
52 #include "qwidget.h"
53 #include "qdebug.h"
54 #include <qmath.h>
55 #include <QRubberBand>
56 #include <QtGui/QFocusFrame>
57 #include <QtGui/QMenu>
58 
60 
62 {
63  QList<QObject*> list = widget->children();
64  QList<QWidget*> widgets;
65  for (int i = 0; i < list.size(); ++i) {
66  QWidget *w = qobject_cast<QWidget *>(list.at(i));
67  if (w && !w->isWindow()
68  && !qobject_cast<QFocusFrame*>(w)
69 #if !defined(QT_NO_MENU)
70  && !qobject_cast<QMenu*>(w)
71 #endif
72  && w->objectName() != QLatin1String("qt_rubberband"))
73  widgets.append(w);
74  }
75  return widgets;
76 }
77 
79 {
80  if (!widget)
81  return QString();
82  QWidget *parent = widget->parentWidget();
83  if (!parent)
84  return QString();
85 #ifndef QT_NO_SHORTCUT
86  QObjectList ol = parent->children();
87  for (int i = 0; i < ol.size(); ++i) {
88  QLabel *label = qobject_cast<QLabel*>(ol.at(i));
89  if (label && label->buddy() == widget)
90  return label->text();
91  }
92 #endif
93 
94 #ifndef QT_NO_GROUPBOX
95  QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
96  if (groupbox)
97  return groupbox->title();
98 #endif
99 
100  return QString();
101 }
102 
103 /* This function will return the offset of the '&' in the text that would be
104  preceding the accelerator character.
105  If this text does not have an accelerator, -1 will be returned. */
106 static int qt_accAmpIndex(const QString &text)
107 {
108 #ifndef QT_NO_SHORTCUT
109  if (text.isEmpty())
110  return -1;
111 
112  int fa = 0;
113  QChar ac;
114  while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
115  ++fa;
116  if (fa < text.length()) {
117  // ignore "&&"
118  if (text.at(fa) == QLatin1Char('&')) {
119  ++fa;
120  continue;
121  } else {
122  return fa - 1;
123  break;
124  }
125  }
126  }
127 
128  return -1;
129 #else
130  Q_UNUSED(text);
131  return -1;
132 #endif
133 }
134 
136 {
137  QString newText(text);
138  int ampIndex = qt_accAmpIndex(newText);
139  if (ampIndex != -1)
140  newText.remove(ampIndex, 1);
141 
142  return newText.replace(QLatin1String("&&"), QLatin1String("&"));
143 }
144 
146 {
147  int ampIndex = qt_accAmpIndex(text);
148  if (ampIndex != -1)
149  return (QString)QKeySequence(Qt::ALT) + text.at(ampIndex + 1);
150 
151  return QString();
152 }
153 
155 {
156 public:
158  :role(Client)
159  {}
160 
169 };
170 
201 {
202  Q_ASSERT(widget());
203  d = new QAccessibleWidgetPrivate();
204  d->role = role;
205  d->name = name;
206  d->asking = 0;
207 }
208 
213 {
214  delete d;
215 }
216 
221 {
222  return qobject_cast<QWidget*>(object());
223 }
224 
230 {
231  QObject *parent = object()->parent();
232  if (!parent)
233  parent = qApp;
234  return parent;
235 }
236 
238 int QAccessibleWidget::childAt(int x, int y) const
239 {
240  QWidget *w = widget();
241  if (!w->isVisible())
242  return -1;
243  QPoint gp = w->mapToGlobal(QPoint(0, 0));
244  if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
245  return -1;
246 
247  QWidgetList list = childWidgets(w);
248  int ccount = childCount();
249 
250  // a complex child
251  if (list.size() < ccount) {
252  for (int i = 1; i <= ccount; ++i) {
253  if (rect(i).contains(x, y))
254  return i;
255  }
256  return 0;
257  }
258 
259  QPoint rp = w->mapFromGlobal(QPoint(x, y));
260  for (int i = 0; i<list.size(); ++i) {
261  QWidget *child = list.at(i);
262  if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
263  return i + 1;
264  }
265  }
266  return 0;
267 }
268 
271 {
272  if (child) {
273  qWarning("QAccessibleWidget::rect: This implementation does not support subelements! "
274  "(ID %d unknown for %s)", child, widget()->metaObject()->className());
275  }
276 
277  QWidget *w = widget();
278  if (!w->isVisible())
279  return QRect();
280  QPoint wpos = w->mapToGlobal(QPoint(0, 0));
281 
282  return QRect(wpos.x(), wpos.y(), w->width(), w->height());
283 }
284 
286 #include <private/qobject_p.h>
288 
290 {
292 public:
293  inline bool isSender(const QObject *receiver, const char *signal) const
294  { return d_func()->isSender(receiver, signal); }
295  inline QObjectList receiverList(const char *signal) const
296  { return d_func()->receiverList(signal); }
297  inline QObjectList senderList() const
298  { return d_func()->senderList(); }
299 };
300 
308 {
310  if (object()->metaObject()->indexOfSignal(s) < 0)
311  qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className());
313 }
314 
324 {
325  d->value = value;
326 }
327 
337 {
338  d->description = desc;
339 }
340 
350 {
351  d->help = help;
352 }
353 
363 {
364  d->accelerator = accel;
365 }
366 
367 static inline bool isAncestor(const QObject *obj, const QObject *child)
368 {
369  while (child) {
370  if (child == obj)
371  return true;
372  child = child->parent();
373  }
374  return false;
375 }
376 
377 
379 QAccessible::Relation QAccessibleWidget::relationTo(int child,
380  const QAccessibleInterface *other, int otherChild) const
381 {
382  Relation relation = Unrelated;
383  if (d->asking == this) // recursive call
384  return relation;
385 
386  QObject *o = other ? other->object() : 0;
387  if (!o)
388  return relation;
389 
390  QWidget *focus = widget()->focusWidget();
391  if (object() == focus && isAncestor(o, focus))
392  relation |= FocusChild;
393 
394  QACConnectionObject *connectionObject = (QACConnectionObject*)object();
395  for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
396  if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) {
397  relation |= Controller;
398  break;
399  }
400  }
401  // test for passive relationships.
402  // d->asking protects from endless recursion.
403  d->asking = this;
404  int inverse = other->relationTo(otherChild, this, child);
405  d->asking = 0;
406 
407  if (inverse & Controller)
408  relation |= Controlled;
409  if (inverse & Label)
410  relation |= Labelled;
411 
412  if(o == object()) {
413  if (child && !otherChild)
414  return relation | Child;
415  if (!child && otherChild)
416  return relation | Ancestor;
417  if (!child && !otherChild)
418  return relation | Self;
419  }
420 
421  QObject *parent = object()->parent();
422  if (o == parent)
423  return relation | Child;
424 
425  if (o->parent() == parent) {
426  relation |= Sibling;
428  Q_ASSERT(sibIface);
429  QRect wg = rect(0);
430  QRect sg = sibIface->rect(0);
431  if (wg.intersects(sg)) {
432  QAccessibleInterface *pIface = 0;
433  sibIface->navigate(Ancestor, 1, &pIface);
434  if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) {
435  int wi = pIface->indexOfChild(this);
436  int si = pIface->indexOfChild(sibIface);
437 
438  if (wi > si)
439  relation |= QAccessible::Covers;
440  else
441  relation |= QAccessible::Covered;
442  }
443  delete pIface;
444  } else {
445  QPoint wc = wg.center();
446  QPoint sc = sg.center();
447  if (wc.x() < sc.x())
448  relation |= QAccessible::Left;
449  else if(wc.x() > sc.x())
450  relation |= QAccessible::Right;
451  if (wc.y() < sc.y())
452  relation |= QAccessible::Up;
453  else if (wc.y() > sc.y())
454  relation |= QAccessible::Down;
455  }
456  delete sibIface;
457 
458  return relation;
459  }
460 
461  if (isAncestor(o, object()))
462  return relation | Descendent;
463  if (isAncestor(object(), o))
464  return relation | Ancestor;
465 
466  return relation;
467 }
468 
471  QAccessibleInterface **target) const
472 {
473  if (!target)
474  return -1;
475 
476  *target = 0;
477  QObject *targetObject = 0;
478 
479  QWidgetList childList = childWidgets(widget());
480  bool complexWidget = childList.size() < childCount();
481 
482  switch (relation) {
483  // Hierarchical
484  case Self:
485  targetObject = object();
486  break;
487  case Child:
488  if (complexWidget) {
489  if (entry > 0 && entry <= childCount())
490  return entry;
491  return -1;
492  }else {
493  if (entry > 0 && childList.size() >= entry)
494  targetObject = childList.at(entry - 1);
495  }
496  break;
497  case Ancestor:
498  {
499  if (entry <= 0)
500  return -1;
501  targetObject = widget()->parentWidget();
502  int i;
503  for (i = entry; i > 1 && targetObject; --i)
504  targetObject = targetObject->parent();
505  if (!targetObject && i == 1)
506  targetObject = qApp;
507  }
508  break;
509  case Sibling:
510  {
512  if (!iface)
513  return -1;
514 
515  iface->navigate(Child, entry, target);
516  delete iface;
517  if (*target)
518  return 0;
519  }
520  break;
521 
522  // Geometrical
523  case QAccessible::Left:
524  if (complexWidget && entry) {
525  if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical
526  return -1;
527  return entry - 1;
528  }
529  // fall through
530  case QAccessible::Right:
531  if (complexWidget && entry) {
532  if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical
533  return -1;
534  return entry + 1;
535  }
536  // fall through
537  case QAccessible::Up:
538  if (complexWidget && entry) {
539  if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal
540  return - 1;
541  return entry - 1;
542  }
543  // fall through
544  case QAccessible::Down:
545  if (complexWidget && entry) {
546  if (entry >= childCount() || widget()->width() > widget()->height() + 20) // looks horizontal
547  return - 1;
548  return entry + 1;
549  } else {
551  if (!pIface)
552  return -1;
553 
554  QRect startg = rect(0);
555  QPoint startc = startg.center();
556  QAccessibleInterface *candidate = 0;
557  int mindist = 100000;
558  int sibCount = pIface->childCount();
559  for (int i = 0; i < sibCount; ++i) {
560  QAccessibleInterface *sibling = 0;
561  pIface->navigate(Child, i+1, &sibling);
562  Q_ASSERT(sibling);
563  if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) {
564  //ignore ourself and invisible siblings
565  delete sibling;
566  continue;
567  }
568 
569  QRect sibg = sibling->rect(0);
570  QPoint sibc = sibg.center();
571  QPoint sibp;
572  QPoint startp;
573  QPoint distp;
574  switch (relation) {
575  case QAccessible::Left:
576  startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
577  sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
578  if (QPoint(sibc - startc).x() >= 0) {
579  delete sibling;
580  continue;
581  }
582  distp = sibp - startp;
583  break;
584  case QAccessible::Right:
585  startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
586  sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
587  if (QPoint(sibc - startc).x() <= 0) {
588  delete sibling;
589  continue;
590  }
591  distp = sibp - startp;
592  break;
593  case QAccessible::Up:
594  startp = QPoint(startg.left() + startg.width() / 2, startg.top());
595  sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
596  if (QPoint(sibc - startc).y() >= 0) {
597  delete sibling;
598  continue;
599  }
600  distp = sibp - startp;
601  break;
602  case QAccessible::Down:
603  startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
604  sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
605  if (QPoint(sibc - startc).y() <= 0) {
606  delete sibling;
607  continue;
608  }
609  distp = sibp - startp;
610  break;
611  default:
612  break;
613  }
614 
615  int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y());
616  if (dist < mindist) {
617  delete candidate;
618  candidate = sibling;
619  mindist = dist;
620  } else {
621  delete sibling;
622  }
623  }
624  delete pIface;
625  *target = candidate;
626  if (*target)
627  return 0;
628  }
629  break;
630  case Covers:
631  if (entry > 0) {
633  if (!pIface)
634  return -1;
635 
636  QRect r = rect(0);
637  int sibCount = pIface->childCount();
638  QAccessibleInterface *sibling = 0;
639  for (int i = pIface->indexOfChild(this) + 1; i <= sibCount && entry; ++i) {
640  pIface->navigate(Child, i, &sibling);
641  if (!sibling || (sibling->state(0) & Invisible)) {
642  delete sibling;
643  sibling = 0;
644  continue;
645  }
646  if (sibling->rect(0).intersects(r))
647  --entry;
648  if (!entry)
649  break;
650  delete sibling;
651  sibling = 0;
652  }
653  delete pIface;
654  *target = sibling;
655  if (*target)
656  return 0;
657  }
658  break;
659  case Covered:
660  if (entry > 0) {
662  if (!pIface)
663  return -1;
664 
665  QRect r = rect(0);
666  int index = pIface->indexOfChild(this);
667  QAccessibleInterface *sibling = 0;
668  for (int i = 1; i < index && entry; ++i) {
669  pIface->navigate(Child, i, &sibling);
670  Q_ASSERT(sibling);
671  if (!sibling || (sibling->state(0) & Invisible)) {
672  delete sibling;
673  sibling = 0;
674  continue;
675  }
676  if (sibling->rect(0).intersects(r))
677  --entry;
678  if (!entry)
679  break;
680  delete sibling;
681  sibling = 0;
682  }
683  delete pIface;
684  *target = sibling;
685  if (*target)
686  return 0;
687  }
688  break;
689 
690  // Logical
691  case FocusChild:
692  {
693  if (widget()->hasFocus()) {
694  targetObject = object();
695  break;
696  }
697 
698  QWidget *fw = widget()->focusWidget();
699  if (!fw)
700  return -1;
701 
702  if (isAncestor(widget(), fw) || fw == widget())
703  targetObject = fw;
704  /* ###
705  QWidget *parent = fw;
706  while (parent && !targetObject) {
707  parent = parent->parentWidget();
708  if (parent == widget())
709  targetObject = fw;
710  }
711  */
712  }
713  break;
714  case Label:
715  if (entry > 0) {
717  if (!pIface)
718  return -1;
719 
720  // first check for all siblings that are labels to us
721  // ideally we would go through all objects and check, but that
722  // will be too expensive
723  int sibCount = pIface->childCount();
724  QAccessibleInterface *candidate = 0;
725  for (int i = 0; i < sibCount && entry; ++i) {
726  const int childId = pIface->navigate(Child, i+1, &candidate);
727  Q_ASSERT(childId >= 0);
728  if (childId > 0)
729  candidate = pIface;
730  if (candidate->relationTo(childId, this, 0) & Label)
731  --entry;
732  if (!entry)
733  break;
734  if (candidate != pIface)
735  delete candidate;
736  candidate = 0;
737  }
738  if (!candidate) {
739  if (pIface->relationTo(0, this, 0) & Label)
740  --entry;
741  if (!entry)
742  candidate = pIface;
743  }
744  if (pIface != candidate)
745  delete pIface;
746 
747  *target = candidate;
748  if (*target)
749  return 0;
750  }
751  break;
752  case Labelled: // only implemented in subclasses
753  break;
754  case Controller:
755  if (entry > 0) {
756  // check all senders we are connected to,
757  // and figure out which one are controllers to us
758  QACConnectionObject *connectionObject = (QACConnectionObject*)object();
759  QObjectList allSenders = connectionObject->senderList();
760  QObjectList senders;
761  for (int s = 0; s < allSenders.size(); ++s) {
762  QObject *sender = allSenders.at(s);
764  if (!candidate)
765  continue;
766  if (candidate->relationTo(0, this, 0)&Controller)
767  senders << sender;
768  delete candidate;
769  }
770  if (entry <= senders.size())
771  targetObject = senders.at(entry-1);
772  }
773  break;
774  case Controlled:
775  if (entry > 0) {
776  QObjectList allReceivers;
777  QACConnectionObject *connectionObject = (QACConnectionObject*)object();
778  for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
779  QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toAscii());
780  allReceivers += receivers;
781  }
782  if (entry <= allReceivers.size())
783  targetObject = allReceivers.at(entry-1);
784  }
785  break;
786  default:
787  break;
788  }
789 
790  *target = QAccessible::queryAccessibleInterface(targetObject);
791  return *target ? 0 : -1;
792 }
793 
796 {
798  return cl.size();
799 }
800 
803 {
805  int index = cl.indexOf(qobject_cast<QWidget *>(child->object()));
806  if (index != -1)
807  ++index;
808  return index;
809 }
810 
811 // from qwidget.cpp
812 extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*);
813 
816 {
817  QString str;
818 
819  switch (t) {
820  case Name:
821  if (!d->name.isEmpty()) {
822  str = d->name;
823  } else if (!widget()->accessibleName().isEmpty()) {
824  str = widget()->accessibleName();
825  } else if (!child && widget()->isWindow()) {
826  if (widget()->isMinimized())
827  str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget());
828  else
829  str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget());
830  } else {
832  }
833  break;
834  case Description:
835  if (!d->description.isEmpty())
836  str = d->description;
837  else if (!widget()->accessibleDescription().isEmpty())
838  str = widget()->accessibleDescription();
839 #ifndef QT_NO_TOOLTIP
840  else
841  str = widget()->toolTip();
842 #endif
843  break;
844  case Help:
845  if (!d->help.isEmpty())
846  str = d->help;
847 #ifndef QT_NO_WHATSTHIS
848  else
849  str = widget()->whatsThis();
850 #endif
851  break;
852  case Accelerator:
853  if (!d->accelerator.isEmpty())
854  str = d->accelerator;
855  else
856  str = qt_accHotKey(buddyString(widget()));
857  break;
858  case Value:
859  str = d->value;
860  break;
861  default:
862  break;
863  }
864  return str;
865 }
866 
867 #ifndef QT_NO_ACTION
868 
871 {
872  if (child)
873  return 0;
874  return widget()->actions().count();
875 }
876 
878 QString QAccessibleWidget::actionText(int action, Text t, int child) const
879 {
880  if (action == DefaultAction)
881  action = SetFocus;
882 
883  if (action > 0 && !child) {
884  QAction *act = widget()->actions().value(action - 1);
885  if (act) {
886  switch (t) {
887  case Name:
888  return act->text();
889  case Description:
890  return act->toolTip();
891 #ifndef QT_NO_SHORTCUT
892  case Accelerator:
893  return act->shortcut().toString();
894 #endif
895  default:
896  break;
897  }
898  }
899  }
900 
901  return QAccessibleObject::actionText(action, t, child);
902 }
903 
905 bool QAccessibleWidget::doAction(int action, int child, const QVariantList &params)
906 {
907  if (action == SetFocus || action == DefaultAction) {
908  if (child || !widget()->isEnabled())
909  return false;
910 
911  if ((widget()->focusPolicy() == Qt::NoFocus) && (!widget()->isWindow()))
912  return false;
913 
914  if (!widget()->isWindow())
915  widget()->setFocus();
916 
917  widget()->activateWindow();
918 
919  return true;
920  } else if (action > 0) {
921  if (QAction *act = widget()->actions().value(action - 1)) {
922  act->trigger();
923  return true;
924  }
925  }
926  return QAccessibleObject::doAction(action, child, params);
927 }
928 
929 #endif // QT_NO_ACTION
930 
933 {
934  if (!child)
935  return d->role;
936 
937  QWidgetList childList = childWidgets(widget());
938  if (childList.count() > 0 && child <= childList.count()) {
939  QWidget *targetWidget = childList.at(child - 1);
941  if (iface) {
942  QAccessible::Role role = iface->role(0);
943  delete iface;
944  return role;
945  }
946  }
947 
948  return NoRole;
949 }
950 
953 {
954  if (child)
955  return Normal;
956 
958 
959  QWidget *w = widget();
960  if (w->testAttribute(Qt::WA_WState_Visible) == false)
961  state |= Invisible;
962  if (w->focusPolicy() != Qt::NoFocus)
963  state |= Focusable;
964  if (w->hasFocus())
965  state |= Focused;
966  if (!w->isEnabled())
967  state |= Unavailable;
968  if (w->isWindow()) {
970  state |= Movable;
971  if (w->minimumSize() != w->maximumSize())
972  state |= Sizeable;
973  }
974 
975  return state;
976 }
977 
978 // ### Qt 5: remove me - binary compatibility hack
981 {
982  Q_ASSERT(widget());
983  d = new QAccessibleWidgetPrivate();
984  d->role = role;
985  d->name = name;
986  d->asking = 0;
987 }
988 
990 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childCount(); }
992 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::indexOfChild(child); }
993 QAccessible::Relation QAccessibleWidgetEx::relationTo(int child, const QAccessibleInterface *other, int otherChild) const
994 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::relationTo(child, other, otherChild); }
995 
996 int QAccessibleWidgetEx::childAt(int x, int y) const
997 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childAt(x, y); }
999 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::rect(child); }
1001 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::navigate(rel, entry, target); }
1002 
1004 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::text(t, child); }
1006 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::role(child); }
1008 { return (reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::state(child))
1009  | HasInvokeExtension; }
1010 
1011 QString QAccessibleWidgetEx::actionText(int action, Text t, int child) const
1012 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::actionText(action, t, child); }
1013 bool QAccessibleWidgetEx::doAction(int action, int child, const QVariantList &params)
1014 { return reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::doAction(action, child, params); }
1015 
1017 { delete d; }
1019 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::widget(); }
1021 { return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::parentObject(); }
1022 
1024 { reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::addControllingSignal(signal); }
1026 { reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setValue(value); }
1028 { reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setDescription(desc); }
1030 { reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setHelp(help); }
1032 { reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setAccelerator(accel); }
1033 
1034 QVariant QAccessibleWidgetEx::invokeMethodEx(Method method, int child, const QVariantList & /*params*/)
1035 {
1036  if (child)
1037  return QVariant();
1038 
1039  switch (method) {
1040  case ListSupportedMethods: {
1043  return QVariant::fromValue(set);
1044  }
1045  case ForegroundColor:
1046  return widget()->palette().color(widget()->foregroundRole());
1047  case BackgroundColor:
1048  return widget()->palette().color(widget()->backgroundRole());
1049  default:
1050  return QVariant();
1051  }
1052 }
1053 
1055 
1056 #endif //QT_NO_ACCESSIBILITY
QString accessibleName
the widget&#39;s name as seen by assistive technologies
Definition: qwidget.h:213
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
T qobject_cast(QObject *object)
Definition: qobject.h:375
QSize maximumSize
the widget&#39;s maximum size in pixels
Definition: qwidget.h:173
QSize minimumSize
the widget&#39;s minimum size
Definition: qwidget.h:172
QAccessibleWidgetPrivate * d
QPalette palette
the widget&#39;s palette
Definition: qwidget.h:180
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
virtual int indexOfChild(const QAccessibleInterface *) const =0
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
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...
double qreal
Definition: qglobal.h:1193
QString whatsThis
the widget&#39;s What&#39;s This help text.
Definition: qwidget.h:210
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QKeySequence shortcut
the action&#39;s primary shortcut key
Definition: qaction.h:83
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
int childCount() const
Reimplemented Function
bool isVisible() const
Definition: qwidget.h:1005
virtual State state(int child) const =0
Returns the current state of the object, or of the object&#39;s child if child is not 0...
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...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Role
This enum defines the role of an accessible object.
Definition: qaccessible.h:188
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString text
the action&#39;s descriptive text
Definition: qaction.h:76
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QAccessibleWidgetPrivate * d
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int userActionCount(int child) const
Reimplemented Function
QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
virtual int childCount() const =0
Returns the number of children that belong to this object.
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
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...
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setHelp(const QString &help)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void addControllingSignal(const QString &signal)
Registers signal as a controlling signal.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
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...
T * qobject_cast(QObject *object)
Definition: qobject.h:375
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...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QWidget * widget() const
Returns the associated widget.
void setValue(const QString &value)
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
bool doAction(int action, int child, const QVariantList &params)
Reimplemented Function
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
const char * className
Definition: qwizard.cpp:137
static QList< QWidget * > childWidgets(const QWidget *widget)
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
const QAccessibleInterface * asking
void setAccelerator(const QString &accel)
int indexOfChild(const QAccessibleInterface *child) const
Reimplemented Function
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const
Reimplemented Function
QWidget * buddy() const
Returns this label&#39;s buddy, or 0 if no buddy is currently set.
Definition: qlabel.cpp:1319
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QRect rect(int child) const
Reimplemented Function
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
static int qt_accAmpIndex(const QString &text)
virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const =0
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
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
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
void setDescription(const QString &desc)
Sets the description of this interface implementation to desc.
RelationFlag
This enum type defines bit flags that can be combined to indicate the relationship between two access...
Definition: qaccessible.h:268
Method
This enum describes the possible types of methods that can be invoked on an accessible object...
Definition: qaccessible.h:311
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int childAt(int x, int y) const
Reimplemented Function
Q_CORE_EXPORT void qWarning(const char *,...)
#define QT_NO_WHATSTHIS
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QGroupBox widget provides a group box frame with a title.
Definition: qgroupbox.h:57
QString toString(SequenceFormat format=PortableText) const
Return a string representation of the key sequence, based on format.
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
QString accessibleDescription
the widget&#39;s description as seen by assistive technologies
Definition: qwidget.h:214
void setAccelerator(const QString &accel)
Sets the accelerator of this interface implementation to accel.
QString toolTip
the action&#39;s tooltip
Definition: qaction.h:78
QString actionText(int action, Text t, int child) const
Reimplemented Function
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
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
int childCount() const
Returns the number of children that belong to this object.
bool isEnabled() const
Definition: qwidget.h:948
The QAccessibleWidget class implements the QAccessibleInterface for QWidgets.
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
QString actionText(int action, Text t, int child) const
Reimplemented Function
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
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.
#define QT_NO_MENU
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QVariant invokeMethodEx(Method method, int child, const QVariantList &params)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
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
virtual Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const =0
Returns the relationship between this object&#39;s \a child and the \a other object&#39;s \a otherChild...
Role role(int child) const
Reimplemented Function
QAccessibleWidget(QWidget *o, Role r=Client, const QString &name=QString())
Creates a QAccessibleWidget object for widget w.
State
Definition: qaudio.h:59
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
void addControllingSignal(const QString &signal)
QObjectList receiverList(const char *signal) const
QWidget * widget() const
QObject * parentObject() const
Returns the associated widget&#39;s parent object, which is either the parent widget, or qApp for top-lev...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setDescription(const QString &desc)
~QAccessibleWidget()
Destroys this object.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
QString objectName() const
QObject * parentObject() const
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QAccessibleObject class implements parts of the QAccessibleInterface for QObjects.
QObject * object() const
Reimplemented Function
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
quint16 index
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QString title
the group box title text
Definition: qgroupbox.h:61
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
The QFocusFrame widget provides a focus frame which can be outside of a widget&#39;s normal paintable are...
Definition: qfocusframe.h:56
virtual QRect rect(int child) const =0
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
bool doAction(int action, int child, const QVariantList &params)
Asks the object, or the object&#39;s child if child is not 0, to execute action using the parameters...
QObjectList senderList() const
QString text
the label&#39;s text
Definition: qlabel.h:58
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
void setValue(const QString &value)
Sets the value of this interface implementation to value.
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.
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text)
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
QString toolTip
the widget&#39;s tooltip
Definition: qwidget.h:204
QAccessibleWidgetEx(QWidget *o, Role r=Client, const QString &name=QString())
int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
Reimplemented Function
bool isSender(const QObject *receiver, const char *signal) const
#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
qreal qSqrt(qreal v)
Definition: qmath.h:205
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
#define text
Definition: qobjectdefs.h:80
The QAccessible class provides enums and static functions relating to accessibility.
Definition: qaccessible.h:64
static bool isAncestor(const QObject *obj, const QObject *child)
bool doAction(int action, int child, const QVariantList &params)
Reimplemented Function
The Text item allows you to add formatted text to a scene.
void setHelp(const QString &help)
Sets the help of this interface implementation to help.
static QString buddyString(const QWidget *widget)
QString text(Text t, int child) const
Reimplemented Function
State state(int child) const
Reimplemented Function