Qt 4.8
complexwidgets.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 "complexwidgets.h"
43 
44 #include <qapplication.h>
45 #include <qabstractbutton.h>
46 #include <qevent.h>
47 #include <qheaderview.h>
48 #include <qtabbar.h>
49 #include <qcombobox.h>
50 #include <qlistview.h>
51 #include <qtableview.h>
52 #include <qlineedit.h>
53 #include <qstyle.h>
54 #include <qstyleoption.h>
55 #include <qtooltip.h>
56 #include <qwhatsthis.h>
57 #include <qtreeview.h>
58 #include <private/qtabbar_p.h>
59 #include <QAbstractScrollArea>
60 #include <QScrollArea>
61 #include <QScrollBar>
62 #include <QDebug>
63 
64 #ifndef QT_NO_ACCESSIBILITY
65 
67 
69 
70 #ifndef QT_NO_ITEMVIEWS
71 /*
72 The MSDN article "Exposing Data Tables through Microsoft Active Accessibility" explains
73 how data tables should be exposed. Url: http://msdn2.microsoft.com/en-us/library/ms971325.aspx
74 Basically, the model is like this:
75 
76 ROLE_SYSTEM_TABLE
77  |- ROLE_SYSTEM_ROW
78  | |- ROLE_SYSTEM_ROWHEADER
79  | |- ROLE_SYSTEM_COLUMNHEADER
80  | |- ROLE_SYSTEM_COLUMNHEADER
81  | |- ROLE_SYSTEM_COLUMNHEADER
82  | '- ..
83  |- ROLE_SYSTEM_ROW
84  | |- ROLE_SYSTEM_ROWHEADER
85  | |- ROLE_SYSTEM_CELL
86  | |- ROLE_SYSTEM_CELL
87  | |- ROLE_SYSTEM_CELL
88  | '- ..
89  |- ROLE_SYSTEM_ROW
90  | |- ROLE_SYSTEM_ROWHEADER
91  | |- ROLE_SYSTEM_CELL
92  | |- ROLE_SYSTEM_CELL
93  | |- ROLE_SYSTEM_CELL
94  | '- ..
95  '- ..
96 
97 The headers of QTreeView is also represented like this.
98 */
100  : row(index), view(aView), m_header(isHeader)
101 {
102 }
103 
105 {
106  QHeaderView *header = 0;
107  if (m_header) {
108  if (false) {
109 #ifndef QT_NO_TABLEVIEW
110  } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
111  header = tv->horizontalHeader();
112 #endif
113 #ifndef QT_NO_TREEVIEW
114  } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
115  header = tv->header();
116 #endif
117  }
118  }
119  return header;
120 }
121 
123 {
124  QHeaderView *header = 0;
125 #ifndef QT_NO_TABLEVIEW
126  if (const QTableView *tv = qobject_cast<const QTableView*>(view))
127  header = tv->verticalHeader();
128 #endif
129  return header;
130 }
131 
133 {
134  int logical = -1;
135  if (header->sectionsHidden()) {
136  int kid = 0;
137  for (int i = 0; i < header->count(); ++i) {
138  if (!header->isSectionHidden(i))
139  ++kid;
140  if (kid == child) {
141  logical = i;
142  break;
143  }
144  }
145  } else {
146  logical = child - 1;
147  }
148  return logical;
149 }
150 
152 {
153  QRect r;
154  if (view && view->isVisible()) {
155  if (QHeaderView *header = horizontalHeader()) {
156  if (!child) {
157  r = header->rect();
158  } else {
159  if (QHeaderView *vheader = verticalHeader()) {
160  if (child == 1) {
161  int w = vheader->width();
162  int h = header->height();
163  r.setRect(0, 0, w, h);
164  }
165  --child;
166  }
167  if (child) {
168  int logical = logicalFromChild(header, child);
169  int w = header->sectionSize(logical);
170  r.setRect(header->sectionViewportPosition(logical), 0, w, header->height());
171  r.translate(header->mapTo(view, QPoint(0, 0)));
172  }
173  }
174  } else if (row.isValid()) {
175  if (!child) {
176  QModelIndex parent = row.parent();
177  const int colCount = row.model()->columnCount(parent);
178  for (int i = 0; i < colCount; ++i)
179  r |= view->visualRect(row.model()->index(row.row(), i, parent));
180  r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
181 
182  if (const QHeaderView *vheader = verticalHeader()) { // include the section of the vertical header
183  QRect re;
184  int logicalRow = row.row();
185  int h = vheader->sectionSize(logicalRow);
186  re.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
187  re.translate(vheader->mapTo(view, QPoint(0, 0)));
188  r |= re;
189  }
190  } else {
191  if (QHeaderView *vheader = verticalHeader()) {
192  if (child == 1) {
193  int logicalRow = row.row();
194  int h = vheader->sectionSize(logicalRow);
195  r.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
196  r.translate(vheader->mapTo(view, QPoint(0, 0)));
197  }
198  --child;
199  }
200  if (child) {
201  r = view->visualRect(childIndex(child));
202  r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
203  }
204  }
205  }
206  }
207  if (!r.isNull())
208  r.translate(view->mapToGlobal(QPoint(0, 0)));
209 
210  return r;
211 }
212 
214 {
215  int level = 0;
216  QModelIndex idx = row;
217  while (idx.isValid()) {
218  idx = idx.parent();
219  ++level;
220  }
221  return level;
222 }
223 
225 {
226  QString value;
227  if (m_header) {
228  if (!child)
229  return QString();
230  if (verticalHeader()) {
231  if (child == 1)
232  return QString();
233  --child;
234  }
235  QHeaderView *header = horizontalHeader();
236  int logical = logicalFromChild(header, child);
238  if (value.isEmpty())
239  value = view->model()->headerData(logical, Qt::Horizontal).toString();
240  return value;
241  } else {
242  if (!child) { // for one-column views (i.e. QListView)
243  if (children().count() >= 1)
244  child = 1;
245  else
246  return QString();
247  }
248  if (verticalHeader()) {
249  if (child == 1) {
250  int logical = row.row();
252  if (value.isEmpty())
253  value = view->model()->headerData(logical, Qt::Vertical).toString();
254  return value;
255  } else {
256  --child;
257  }
258  }
259  }
260  if (value.isEmpty()) {
261  QModelIndex idx = childIndex(child);
262  if (idx.isValid()) {
263  value = idx.model()->data(idx, Qt::AccessibleTextRole).toString();
264  if (value.isEmpty())
265  value = idx.model()->data(idx, Qt::DisplayRole).toString();
266  }
267  }
268  return value;
269 }
270 
272 {
273  QString value;
274  if (t == Name) {
275  value = text_helper(child);
276  } else if (t == Value) {
277 #ifndef QT_NO_TREEVIEW
278  if (qobject_cast<const QTreeView*>(view)) {
279  if (child == 0)
280  value = QString::number(treeLevel());
281  } else
282 #endif
283  {
284  value = text_helper(child);
285  }
286  } else if (t == Description) {
287 #ifndef QT_NO_TREEVIEW
288  if (child == 0 && qobject_cast<const QTreeView*>(view)) {
289  // We store the tree coordinates of the current item in the description.
290  // This enables some screen readers to report where the focus is
291  // in a tree view. (works in JAWS). Also, Firefox does the same thing.
292  // For instance the description "L2, 4 of 25 with 24" means
293  // "L2": Tree Level 2
294  // "4 of 25": We are item 4 out of in total 25 other siblings
295  // "with 24": We have 24 children. (JAWS does not read this number)
296 
297  // level
298  int level = treeLevel();
299 
300  QAbstractItemModel *m = view->model();
301  // totalSiblings and itemIndex
302  QModelIndex parent = row.parent();
303  int rowCount = m->rowCount(parent);
304  int itemIndex = -1;
305  int totalSiblings = 0;
306  for (int i = 0 ; i < rowCount; ++i) {
307  QModelIndex sibling = row.sibling(i, 0);
308  if (!view->isIndexHidden(sibling))
309  ++totalSiblings;
310  if (row == sibling)
311  itemIndex = totalSiblings;
312  }
313  int totalChildren = m->rowCount(row); // JAWS does not report child count, so we do
314  // this simple and efficient.
315  // (don't check if they are all visible).
316  value = QString::fromAscii("L%1, %2 of %3 with %4").arg(level).arg(itemIndex).arg(totalSiblings).arg(totalChildren);
317  } else
318 #endif // QT_NO_TREEVIEW
319  {
320  if (!m_header) {
321  if (child == 0 && children().count() >= 1)
322  child = 1;
323  if (verticalHeader()) {
324  if (child == 1) {
325  value = view->model()->headerData(row.row(), Qt::Vertical).toString();
326  }
327  --child;
328  }
329  if (child) {
330  QModelIndex idx = childIndex(child);
331  value = idx.model()->data(idx, Qt::AccessibleDescriptionRole).toString();
332  }
333 
334  }
335  }
336  }
337  return value;
338 }
339 
340 void QAccessibleItemRow::setText(Text t, int child, const QString &text)
341 {
342  if (m_header) {
343  if (child)
344  view->model()->setHeaderData(child - 1, Qt::Horizontal, text);
345  // child == 0 means the cell to the left of the horizontal header, which is empty!?
346  } else {
347  if (!child) {
348  if (children().count() == 1)
349  child = 1;
350  else
351  return;
352  }
353 
354  if (verticalHeader()) {
355  if (child == 1) {
357  return;
358  }
359  --child;
360  }
361  QModelIndex idx = childIndex(child);
362  if (!idx.isValid())
363  return;
364 
365  switch (t) {
366  case Description:
367  const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text,
369  break;
370  case Value:
371  const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text, Qt::EditRole);
372  break;
373  default:
374  break;
375  }
376  }
377 }
378 
380 {
381  QList<QModelIndex> kids = children();
382  Q_ASSERT(child >= 1 && child <= kids.count());
383  return kids.at(child - 1);
384 }
385 
387 {
388  QList<QModelIndex> kids;
389  for (int i = 0; i < row.model()->columnCount(row.parent()); ++i) {
390  QModelIndex idx = row.model()->index(row.row(), i, row.parent());
391  if (!view->isIndexHidden(idx)) {
392  kids << idx;
393  }
394  }
395  return kids;
396 }
397 
399 {
400  return m_header ? true : row.isValid();
401 }
402 
404 {
405  return 0;
406 }
407 
409 {
410  int count = 0;
411  if (QHeaderView *header = horizontalHeader()) {
412  count = header->count() - header->hiddenSectionCount();
413  } else {
414  count = children().count();
415  }
416 #ifndef QT_NO_TABLEVIEW
417  if (qobject_cast<const QTableView*>(view)) {
418  if (verticalHeader())
419  ++count;
420  }
421 #endif
422  return count;
423 }
424 
426 {
427  if (!iface || iface->role(0) != Row)
428  return -1;
429 
430  //### meaningless code?
431  QList<QModelIndex> kids = children();
432  QModelIndex idx = static_cast<const QAccessibleItemRow *>(iface)->row;
433  if (!idx.isValid())
434  return -1;
435  return kids.indexOf(idx) + 1;
436 }
437 
438 QAccessible::Relation QAccessibleItemRow::relationTo(int child, const QAccessibleInterface *other,
439  int otherChild) const
440 {
441  if (!child && !otherChild && other->object() == view)
442  return Child;
443  if (!child && !otherChild && other == this)
444  return Self;
445  if (!child && otherChild && other == this)
446  return Ancestor;
447  if (child && otherChild && other == this)
448  return Sibling;
449  return Unrelated;
450 }
451 
452 int QAccessibleItemRow::childAt(int x, int y) const
453 {
454  if (!view || !view->isVisible())
455  return -1;
456 
457  for (int i = childCount(); i >= 0; --i) {
458  if (rect(i).contains(x, y))
459  return i;
460  }
461  return -1;
462 }
463 
465  QAccessible::Relation rel)
466 {
467  switch (rel) {
468  case QAccessible::Up:
470  case QAccessible::Down:
472  case QAccessible::Left:
474  case QAccessible::Right:
476  default:
477  Q_ASSERT(false);
478  }
479  // should never be reached.
481 }
482 
484  QAccessibleInterface **iface) const
485 {
486  *iface = 0;
487  if (!view)
488  return -1;
489 
490  switch (relation) {
491  case Ancestor: {
492  if (!index)
493  return -1;
495  if (index == 1) {
496  *iface = ancestor;
497  return 0;
498  } else if (index > 1) {
499  int ret = ancestor->navigate(Ancestor, index - 1, iface);
500  delete ancestor;
501  return ret;
502  }
503  }
504  case Child: {
505  if (!index)
506  return -1;
507  if (index < 1 && index > childCount())
508  return -1;
509 
510  return index;}
511  case Sibling:
512  if (index) {
513  QAccessibleInterface *ifaceParent = 0;
514  navigate(Ancestor, 1, &ifaceParent);
515  if (ifaceParent) {
516  int entry = ifaceParent->navigate(Child, index, iface);
517  delete ifaceParent;
518  return entry;
519  }
520  }
521  return -1;
522  case Up:
523  case Down:
524  case Left:
525  case Right: {
526  // This is in the "not so nice" category. In order to find out which item
527  // is geometrically around, we have to set the current index, navigate
528  // and restore the index as well as the old selection
529  view->setUpdatesEnabled(false);
530  const QModelIndex oldIdx = view->currentIndex();
531  QList<QModelIndex> kids = children();
532  const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row);
533  const QItemSelection oldSelection = view->selectionModel()->selection();
534  view->setCurrentIndex(currentIndex);
535  const QModelIndex idx = view->moveCursor(toCursorAction(relation), Qt::NoModifier);
536  view->setCurrentIndex(oldIdx);
538  view->setUpdatesEnabled(true);
539  if (!idx.isValid())
540  return -1;
541 
542  if (idx.parent() != row.parent() || idx.row() != row.row())
543  *iface = new QAccessibleItemRow(view, idx);
544  return index ? kids.indexOf(idx) + 1 : 0; }
545  default:
546  break;
547  }
548 
549  return -1;
550 }
551 
553 {
554  if (false) {
555 #ifndef QT_NO_TREEVIEW
556  } else if (qobject_cast<const QTreeView*>(view)) {
557  if (horizontalHeader()) {
558  if (!child)
559  return Row;
560  return ColumnHeader;
561  }
562  return TreeItem;
563 #endif
564 #ifndef QT_NO_LISTVIEW
565  } else if (qobject_cast<const QListView*>(view)) {
566  return ListItem;
567 #endif
568 #ifndef QT_NO_TABLEVIEW
569  } else if (qobject_cast<const QTableView *>(view)) {
570  if (!child)
571  return Row;
572  if (child == 1) {
573  if (verticalHeader())
574  return RowHeader;
575  }
576  if (m_header)
577  return ColumnHeader;
578 #endif
579  }
580  return Cell;
581 }
582 
584 {
585  State st = Normal;
586 
587  if (!view)
588  return st;
589 
590  QAccessibleInterface *parent = 0;
591  QRect globalRect;
592  if (navigate(Ancestor, 1, &parent) == 0) {
593  globalRect = parent->rect(0);
594  delete parent;
595  }
596  if (!globalRect.intersects(rect(child)))
597  st |= Invisible;
598 
599  if (!horizontalHeader()) {
600  if (!(st & Invisible)) {
601  if (child) {
602  if (QHeaderView *vheader = verticalHeader() ) {
603  if (child == 1) {
604  if (!vheader->isVisible())
605  st |= Invisible;
606  }
607  --child;
608  }
609  if (child) {
610  QModelIndex idx = childIndex(child);
611  if (!idx.isValid())
612  return st;
613 
614  if (view->selectionModel()->isSelected(idx))
615  st |= Selected;
616  if (view->selectionModel()->currentIndex() == idx)
617  st |= Focused;
618  if (idx.model()->data(idx, Qt::CheckStateRole).toInt() == Qt::Checked)
619  st |= Checked;
620 
621  Qt::ItemFlags flags = idx.flags();
622  if (flags & Qt::ItemIsSelectable) {
623  st |= Selectable;
625  st |= MultiSelectable;
627  st |= ExtSelectable;
628  }
629  }
630  } else {
631  Qt::ItemFlags flags = row.flags();
632  if (flags & Qt::ItemIsSelectable) {
633  st |= Selectable;
634  st |= Focusable;
635  }
637  st |= Selected;
638  if (view->selectionModel()->currentIndex().row() == row.row())
639  st |= Focused;
640  }
641  }
642  }
643 
644  return st;
645 }
646 
648 {
649  return 0;
650 }
651 
653 {
654  return QString();
655 }
656 
657 static QItemSelection rowAt(const QModelIndex &idx)
658 {
659  return QItemSelection(idx.sibling(idx.row(), 0),
660  idx.sibling(idx.row(), idx.model()->columnCount(idx.parent())));
661 }
662 
663 bool QAccessibleItemRow::doAction(int action, int child, const QVariantList & /*params*/)
664 {
665  if (!view)
666  return false;
667 
668  if (verticalHeader())
669  --child;
670 
671  QModelIndex idx = child ? childIndex(child) : QModelIndex(row);
672  if (!idx.isValid())
673  return false;
674 
675  QItemSelectionModel::SelectionFlags command = QItemSelectionModel::NoUpdate;
676 
677  switch (action) {
678  case SetFocus:
679  view->setCurrentIndex(idx);
680  return true;
681  case ExtendSelection:
682  if (!child)
683  return false;
686  return true;
687  case Select:
689  break;
690  case ClearSelection:
691  command = QItemSelectionModel::Clear;
692  break;
693  case RemoveSelection:
695  break;
696  case AddToSelection:
698  break;
699  }
700  if (command == QItemSelectionModel::NoUpdate)
701  return false;
702 
703  if (child)
704  view->selectionModel()->select(idx, command);
705  else
706  view->selectionModel()->select(rowAt(row), command);
707  return true;
708 }
709 
711 {
712 public:
714  {
715 #ifndef QT_NO_LISTVIEW
716  list = qobject_cast<QListView*>(m_view);
717 #endif
718 #ifndef QT_NO_TREEVIEW
719  tree = qobject_cast<QTreeView*>(m_view);
720 #endif
721 #ifndef QT_NO_TABLEVIEW
722  table = qobject_cast<QTableView*>(m_view);
723 #endif
724  if (start.isValid()) {
725  m_current = start;
726  } else if (m_view && m_view->model()) {
727  m_current = view->rootIndex().isValid() ?
728  view->rootIndex().child(0,0) : view->model()->index(0, 0);
729  }
730  }
731 
732  bool next(int count = 1) {
733  for (int i = 0; i < count; ++i) {
734  do {
735  if (m_current.isValid()) {
736  const QAbstractItemModel *m = m_current.model();
737 #ifndef QT_NO_TREEVIEW
738  if (tree && m_current.model()->hasChildren(m_current) && tree->isExpanded(m_current)) {
739  m_current = m_current.child(0, 0);
740  } else
741 #endif
742  {
743  int row = m_current.row();
744  QModelIndex par = m_current.parent();
745 
746  // Go up to the parent if we reach the end of the rows
747  // If m_curent becomses invalid, stop going up.
748  while (row + 1 >= m->rowCount(par)) {
749  m_current = par;
750  if (m_current.isValid()) {
751  row = m_current.row();
752  par = m_current.parent();
753  } else {
754  row = 0;
755  par = QModelIndex();
756  break;
757  }
758  }
759 
760  if (m_current.isValid())
761  m_current = m_current.sibling(row + 1, 0);
762  }
763  }
764  } while (isHidden());
765  }
766  return m_current.isValid();
767  }
768 
769  bool isHidden() const {
770  if (false) {
771 #ifndef QT_NO_LISTVIEW
772  } else if (list) {
773  return list->isRowHidden(m_current.row());
774 #endif
775 #ifndef QT_NO_TREEVIEW
776  } else if (tree) {
777  return tree->isRowHidden(m_current.row(), m_current.parent());
778 #endif
779 #ifndef QT_NO_TABLEVIEW
780  } else if (table) {
781  return table->isRowHidden(m_current.row());
782 #endif
783  }
784  return false;
785  }
786 
788  return m_current;
789  }
790 
791 private:
794 
795 #ifndef QT_NO_TREEVIEW
797 #endif
798 #ifndef QT_NO_LISTVIEW
800 #endif
801 #ifndef QT_NO_TABLEVIEW
803 #endif
804 };
805 
807  : QAccessibleAbstractScrollArea(w->objectName() == QLatin1String("qt_scrollarea_viewport") ? w->parentWidget() : w)
808 {
809  atVP = w->objectName() == QLatin1String("qt_scrollarea_viewport");
810 
811 }
812 
813 
815 {
816  QHeaderView *header = 0;
817  if (false) {
818 #ifndef QT_NO_TABLEVIEW
819  } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
820  header = tv->horizontalHeader();
821 #endif
822 #ifndef QT_NO_TREEVIEW
823  } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(itemView())) {
824  header = tv->header();
825 #endif
826  }
827  return header;
828 }
829 
831 {
832  QHeaderView *header = 0;
833  if (false) {
834 #ifndef QT_NO_TABLEVIEW
835  } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
836  header = tv->verticalHeader();
837 #endif
838  }
839  return header;
840 }
841 
842 
844 {
845  if (atViewport()) {
846  if (false) {
847 #ifndef QT_NO_TREEVIEW
848  } else if (qobject_cast<const QTreeView*>(itemView())) {
849  return (role == TreeItem || role == Row);
850 #endif
851 #ifndef QT_NO_LISTVIEW
852  } else if (qobject_cast<const QListView*>(itemView())) {
853  return (role == ListItem);
854 #endif
855  }
856  // TableView
857  return role == Row;
858  } else {
859  if (false) {
860 #ifndef QT_NO_TREEVIEW
861  } else if (qobject_cast<const QTreeView*>(itemView())) {
862  return (role == Tree);
863 #endif
864 #ifndef QT_NO_LISTVIEW
865  } else if (qobject_cast<const QListView*>(itemView())) {
866  return (role == List);
867 #endif
868  }
869  // TableView
870  return (role == Table);
871  }
872 }
873 
875 {
877  Q_ASSERT(qobject_cast<const QAbstractItemView *>(view));
878  if (atViewport())
879  view = qobject_cast<const QAbstractItemView *>(view)->viewport();
880  return view;
881 }
882 
884 {
886 }
887 
889 {
890  if (atViewport()) {
891  if (!iface || !isValidChildRole(iface->role(0)))
892  return -1;
893 
894  int entry = -1;
895  // ### This will fail if a row is hidden.
896  const QAccessibleItemRow *ifRow = static_cast<const QAccessibleItemRow *>(iface);
897  if (ifRow->horizontalHeader())
898  return 1;
899 
900  QModelIndex idx = ifRow->row;
901  if (!idx.isValid())
902  return -1;
903 
904  entry = entryFromIndex(idx);
905  if (horizontalHeader())
906  ++entry;
907 
908  return entry;
909 
910  } else {
912  }
913 }
914 
916 {
917  if (!atViewport())
918  return QModelIndex();
920  it.next(child - 1);
921  return it.current();
922 }
923 
925 {
926  int entry = -1;
927  if (false) {
928 #ifndef QT_NO_TREEVIEW
929  } else if (QTreeView *tree = qobject_cast<QTreeView*>(itemView())) {
930  entry = tree->visualIndex(index) + 1;
931 #endif
932 #ifndef QT_NO_LISTVIEW
933  } else if (QListView *list = qobject_cast<QListView*>(itemView())) {
934  entry = list->visualIndex(index) + 1;
935 #endif
936 #ifndef QT_NO_TABLEVIEW
937  } else if (QTableView *table = qobject_cast<QTableView*>(itemView())) {
938  entry = table->visualIndex(index) + 1;
939 #endif
940  }
941  return entry;
942 }
943 
945 {
946  if (atViewport()) {
947  if (itemView()->model() == 0)
948  return 0;
950  QModelIndex idx = m->index(0,0);
951  if (!idx.isValid())
952  return 0;
954  int count = 1;
955  while (it.next()) {
956  ++count;
957  }
958  if (horizontalHeader())
959  ++count;
960 
961  return count;
962  } else {
964  }
965 }
966 
968 {
969  if (atViewport()) {
970  if (!child)
971  return QAccessibleAbstractScrollArea::text(t, child);
972 
973  QAccessibleItemRow item(itemView(), childIndex(child));
974  if (item.isValid()) {
975  return item.text(t, 1);
976  } else {
977  return QString();
978  }
979  } else {
980  return QAccessibleAbstractScrollArea::text(t, child);
981  }
982 }
983 
984 void QAccessibleItemView::setText(Text t, int child, const QString &text)
985 {
986  if (atViewport()) {
987  if (!child) {
989  return;
990  }
991 
992  QAccessibleItemRow item(itemView(), childIndex(child));
993  item.setText(t, 1, text);
994  } else {
996  }
997 }
998 
1000 {
1001  if (atViewport()) {
1002  QRect r;
1003  if (!child) {
1004  // Make sure that the rect *include* the vertical and horizontal headers, while
1005  // not including the potential vertical and horizontal scrollbars.
1006  QAbstractItemView *w = itemView();
1007 
1008  int vscrollWidth = 0;
1009  const QScrollBar *sb = w->verticalScrollBar();
1010  if (sb && sb->isVisible())
1011  vscrollWidth = sb->width();
1012 
1013  int hscrollHeight = 0;
1014  sb = w->horizontalScrollBar();
1015  if (sb && sb->isVisible())
1016  hscrollHeight = sb->height();
1017 
1018  QPoint globalPos = w->mapToGlobal(QPoint(0,0));
1019  r = w->rect().translated(globalPos);
1020  if (w->isRightToLeft()) {
1021  r.adjust(vscrollWidth, 0, 0, -hscrollHeight);
1022  } else {
1023  r.adjust(0, 0, -vscrollWidth, -hscrollHeight);
1024  }
1025  } else {
1026  QAccessibleInterface *iface = 0;
1027  if (navigate(Child, child, &iface) == 0) {
1028  r = iface->rect(0);
1029  delete iface;
1030  }
1031  }
1032  return r;
1033  } else {
1035  if (child == 1) {
1036  // include the potential vertical and horizontal headers
1037 
1038  const QHeaderView *header = verticalHeader();
1039  int headerWidth = (header && header->isVisible()) ? header->width() : 0;
1040  header = horizontalHeader();
1041  int headerHeight= (header && header->isVisible()) ? header->height() : 0;
1042  if (itemView()->isRightToLeft()) {
1043  r.adjust(0, -headerHeight, headerWidth, 0);
1044  } else {
1045  r.adjust(-headerWidth, -headerHeight, 0, 0);
1046  }
1047  }
1048  return r;
1049  }
1050 }
1051 
1052 int QAccessibleItemView::childAt(int x, int y) const
1053 {
1054  if (atViewport()) {
1055  QPoint p(x, y);
1056  for (int i = childCount(); i >= 0; --i) {
1057  if (rect(i).contains(p))
1058  return i;
1059  }
1060  return -1;
1061  } else {
1063  }
1064 }
1065 
1067 {
1068  if ((!atViewport() && child) || (atViewport() && child == 0)) {
1069  QAbstractItemView *view = itemView();
1070 #ifndef QT_NO_TABLEVIEW
1071  if (qobject_cast<QTableView *>(view))
1072  return Table;
1073 #endif
1074 #ifndef QT_NO_LISTVIEW
1075  if (qobject_cast<QListView *>(view))
1076  return List;
1077 #endif
1078  return Tree;
1079  }
1080  if (atViewport()) {
1081  if (child)
1082  return Row;
1083  }
1084 
1086 }
1087 
1089 {
1090  State st = Normal;
1091 
1092  if (itemView() == 0)
1093  return State(Unavailable);
1094 
1095  bool queryViewPort = (atViewport() && child == 0) || (!atViewport() && child == 1);
1096  if (queryViewPort) {
1098  st |= Selectable;
1099  st |= Focusable;
1100  }
1101  } else if (atViewport()) { // children of viewport
1102  if (horizontalHeader())
1103  --child;
1104  if (child) {
1105  QAccessibleItemRow item(itemView(), childIndex(child));
1106  st |= item.state(0);
1107  }
1108  } else if (!atViewport() && child != 1) {
1110  }
1111  return st;
1112 }
1113 
1115 {
1116  if (atViewport())
1118  else
1120 }
1121 
1123  QAccessibleInterface **iface) const
1124 {
1125  if (atViewport()) {
1126  if (relation == Ancestor && index == 1) {
1127  *iface = new QAccessibleItemView(itemView());
1128  return 0;
1129  } else if (relation == Child && index >= 1) {
1130  if (horizontalHeader()) {
1131  if (index == 1) {
1132  *iface = new QAccessibleItemRow(itemView(), QModelIndex(), true);
1133  return 0;
1134  }
1135  --index;
1136  }
1137 
1138  //###JAS hidden rows..
1139  QModelIndex idx = childIndex(index);
1140  if (idx.isValid()) {
1141  *iface = new QAccessibleItemRow(itemView(), idx);
1142  return 0;
1143  }
1144  } else if (relation == Sibling && index >= 1) {
1146  return parent->navigate(Child, index, iface);
1147  }
1148  *iface = 0;
1149  return -1;
1150  } else {
1151  return QAccessibleAbstractScrollArea::navigate(relation, index, iface);
1152  }
1153 }
1154 
1155 /* returns the model index for a given row and column */
1156 QModelIndex QAccessibleItemView::index(int row, int column) const
1157 {
1158  return itemView()->model()->index(row, column);
1159 }
1160 
1162 {
1163  QWidget *indexWidget = itemView()->indexWidget(index(row, column));
1164  return QAccessible::queryAccessibleInterface(indexWidget);
1165 }
1166 
1167 /* We don't have a concept of a "caption" in Qt's standard widgets */
1169 {
1170  return 0;
1171 }
1172 
1173 /* childIndex is row * columnCount + columnIndex */
1175 {
1176  return rowIndex * itemView()->model()->columnCount() + columnIndex;
1177 }
1178 
1179 /* Return the header data as column description */
1181 {
1182  return itemView()->model()->headerData(column, Qt::Horizontal).toString();
1183 }
1184 
1185 /* We don't support column spanning atm */
1186 int QAccessibleItemView::columnSpan(int /* row */, int /* column */)
1187 {
1188  return 1;
1189 }
1190 
1191 /* Return the horizontal header view */
1193 {
1194 #ifndef QT_NO_TREEVIEW
1195  if (QTreeView *tree = qobject_cast<QTreeView *>(itemView()))
1196  return QAccessible::queryAccessibleInterface(tree->header());
1197 #endif
1198 #ifndef QT_NO_TABLEVIEW
1199  if (QTableView *table = qobject_cast<QTableView *>(itemView()))
1200  return QAccessible::queryAccessibleInterface(table->horizontalHeader());
1201 #endif
1202  return 0;
1203 }
1204 
1206 {
1207  int columnCount = itemView()->model()->columnCount();
1208  if (!columnCount)
1209  return 0;
1210 
1211  return childIndex % columnCount;
1212 }
1213 
1215 {
1216  return itemView()->model()->columnCount();
1217 }
1218 
1220 {
1221  return itemView()->model()->rowCount();
1222 }
1223 
1225 {
1226  return itemView()->selectionModel()->selectedColumns().count();
1227 }
1228 
1230 {
1231  return itemView()->selectionModel()->selectedRows().count();
1232 }
1233 
1235 {
1236  return itemView()->model()->headerData(row, Qt::Vertical).toString();
1237 }
1238 
1239 /* We don't support row spanning */
1240 int QAccessibleItemView::rowSpan(int /*row*/, int /*column*/)
1241 {
1242  return 1;
1243 }
1244 
1246 {
1247 #ifndef QT_NO_TABLEVIEW
1248  if (QTableView *table = qobject_cast<QTableView *>(itemView()))
1249  return QAccessible::queryAccessibleInterface(table->verticalHeader());
1250 #endif
1251  return 0;
1252 }
1253 
1255 {
1256  int columnCount = itemView()->model()->columnCount();
1257  if (!columnCount)
1258  return 0;
1259 
1260  return int(childIndex / columnCount);
1261 }
1262 
1264 {
1265  Q_ASSERT(rows);
1266 
1267  const QModelIndexList selRows = itemView()->selectionModel()->selectedRows();
1268  int maxCount = qMin(selRows.count(), maxRows);
1269 
1270  for (int i = 0; i < maxCount; ++i)
1271  rows->append(selRows.at(i).row());
1272 
1273  return maxCount;
1274 }
1275 
1277 {
1278  Q_ASSERT(columns);
1279 
1280  const QModelIndexList selColumns = itemView()->selectionModel()->selectedColumns();
1281  int maxCount = qMin(selColumns.count(), maxColumns);
1282 
1283  for (int i = 0; i < maxCount; ++i)
1284  columns->append(selColumns.at(i).row());
1285 
1286  return maxCount;
1287 }
1288 
1289 /* Qt widgets don't have a concept of a summary */
1291 {
1292  return 0;
1293 }
1294 
1296 {
1297  return itemView()->selectionModel()->isColumnSelected(column, QModelIndex());
1298 }
1299 
1301 {
1302  return itemView()->selectionModel()->isRowSelected(row, QModelIndex());
1303 }
1304 
1305 bool QAccessibleItemView::isSelected(int row, int column)
1306 {
1307  return itemView()->selectionModel()->isSelected(index(row, column));
1308 }
1309 
1311 {
1314 }
1315 
1317 {
1320 }
1321 
1323 {
1326 }
1327 
1329 {
1332 }
1333 
1334 void QAccessibleItemView::cellAtIndex(int index, int *row, int *column, int *rSpan,
1335  int *cSpan, bool *isSelect)
1336 {
1337  *row = rowIndex(index);
1338  *column = columnIndex(index);
1339  *rSpan = rowSpan(*row, *column);
1340  *cSpan = columnSpan(*row, *column);
1341  *isSelect = isSelected(*row, *column);
1342 }
1343 
1360 {
1361  Q_ASSERT(header());
1362  addControllingSignal(QLatin1String("sectionClicked(int)"));
1363 }
1364 
1367 {
1368  return qobject_cast<QHeaderView*>(object());
1369 }
1370 
1373 {
1374  if (!child)
1375  return QAccessibleWidgetEx::rect(0);
1376 
1377  QHeaderView *h = header();
1378  QPoint zero = h->mapToGlobal(QPoint(0, 0));
1379  int sectionSize = h->sectionSize(child - 1);
1380  int sectionPos = h->sectionPosition(child - 1);
1381  return h->orientation() == Qt::Horizontal
1382  ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, h->height())
1383  : QRect(zero.x(), zero.y() + sectionPos, h->width(), sectionSize);
1384 }
1385 
1388 {
1389  return header()->count();
1390 }
1391 
1394 {
1395  QString str;
1396 
1397  if (child > 0 && child <= childCount()) {
1398  switch (t) {
1399  case Name:
1400  str = header()->model()->headerData(child - 1, header()->orientation()).toString();
1401  break;
1402  case Description: {
1404  if (QApplication::sendEvent(widget(), &event))
1405  str = event.value();
1406  break; }
1407  case Help: {
1409  if (QApplication::sendEvent(widget(), &event))
1410  str = event.value();
1411  break; }
1412  default:
1413  break;
1414  }
1415  }
1416  if (str.isEmpty())
1417  str = QAccessibleWidgetEx::text(t, child);
1418  return str;
1419 }
1420 
1423 {
1424  return (header()->orientation() == Qt::Horizontal) ? ColumnHeader : RowHeader;
1425 }
1426 
1429 {
1431 
1432  if (child) {
1433  int section = child - 1;
1434  if (header()->isSectionHidden(section))
1435  state |= Invisible;
1436  if (header()->resizeMode(section) != QHeaderView::Custom)
1437  state |= Sizeable;
1438  } else {
1439  if (header()->isMovable())
1440  state |= Movable;
1441  }
1442  if (!header()->isClickable())
1443  state |= Unavailable;
1444  return state;
1445 }
1446 #endif // QT_NO_ITEMVIEWS
1447 
1448 #ifndef QT_NO_TABBAR
1449 
1465 {
1466  Q_ASSERT(tabBar());
1467 }
1468 
1471 {
1472  return qobject_cast<QTabBar*>(object());
1473 }
1474 
1476 {
1477  if (child <= tabBar()->count())
1478  return 0;
1479  QTabBarPrivate * const tabBarPrivate = tabBar()->d_func();
1480  if (child - tabBar()->count() == 1)
1481  return tabBarPrivate->leftB;
1482  if (child - tabBar()->count() == 2)
1483  return tabBarPrivate->rightB;
1484  Q_ASSERT(false);
1485  return 0;
1486 }
1487 
1490 {
1491  if (!child || !tabBar()->isVisible())
1492  return QAccessibleWidgetEx::rect(0);
1493 
1494  QPoint tp = tabBar()->mapToGlobal(QPoint(0,0));
1495  QRect rec;
1496  if (child <= tabBar()->count()) {
1497  rec = tabBar()->tabRect(child - 1);
1498  } else {
1499  QWidget *widget = button(child);
1500  rec = widget ? widget->geometry() : QRect();
1501  }
1502  return QRect(tp.x() + rec.x(), tp.y() + rec.y(), rec.width(), rec.height());
1503 }
1504 
1507 {
1508  // tabs + scroll buttons
1509  return tabBar()->count() + 2;
1510 }
1511 
1514 {
1515  QString str;
1516 
1517  if (child > tabBar()->count()) {
1518  bool left = child - tabBar()->count() == 1;
1519  switch (t) {
1520  case Name:
1521  return left ? QTabBar::tr("Scroll Left") : QTabBar::tr("Scroll Right");
1522  default:
1523  break;
1524  }
1525  } else {
1526  switch (t) {
1527  case Name:
1528  if (child > 0)
1529  return qt_accStripAmp(tabBar()->tabText(child - 1));
1530  else if (tabBar()->currentIndex() != -1)
1531  return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex()));
1532  break;
1533  default:
1534  break;
1535  }
1536  }
1537 
1538  if (str.isEmpty())
1539  str = QAccessibleWidgetEx::text(t, child);;
1540  return str;
1541 }
1542 
1545 {
1546  if (!child)
1547  return PageTabList;
1548  if (child > tabBar()->count())
1549  return PushButton;
1550  return PageTab;
1551 }
1552 
1554 int QAccessibleTabBar::navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const
1555 {
1556  //QAccessibleWidgetEx::navigate might think that this is not a complex widget
1557  //if close buttons are enabled, so this functions handles those cases in which
1558  //the value to return is different if it's a complex widget and if it's not.
1559  if (!target)
1560  return -1;
1561 
1562  *target = 0;
1563 
1564  switch (relation) {
1565  case Child:
1566  if ((entry >= 0) && (entry <= childCount()))
1567  return entry;
1568  return -1;
1569  default:
1570  return QAccessibleWidgetEx::navigate(relation, entry, target);
1571  }
1572 }
1573 
1574 
1577 {
1579 
1580  if (!child)
1581  return st;
1582 
1583  QTabBar *tb = tabBar();
1584 
1585  if (child > tb->count()) {
1586  QWidget *bt = button(child);
1587  if (!bt)
1588  return st;
1589  if (bt->isEnabled() == false)
1590  st |= Unavailable;
1591  if (bt->isVisible() == false)
1592  st |= Invisible;
1593  if (bt->focusPolicy() != Qt::NoFocus && bt->isActiveWindow())
1594  st |= Focusable;
1595  if (bt->hasFocus())
1596  st |= Focused;
1597  return st;
1598  }
1599 
1600  if (!tb->isTabEnabled(child - 1))
1601  st |= Unavailable;
1602  else
1603  st |= Selectable;
1604 
1605  if (tb->currentIndex() == child - 1)
1606  st |= Selected;
1607 
1608  return st;
1609 }
1610 
1612 QString QAccessibleTabBar::actionText(int action, Text t, int child) const
1613 {
1614  if (!child)
1615  return QString();
1616 
1617  switch (t) {
1618  case QAccessible::Name:
1619  if ((action == 1) && (child <= tabBar()->count())) {
1620  return tabBar()->tabsClosable() ? QTabBar::tr("Close") : QString();
1621  } else if (action == 0) {
1622  if (child <= tabBar()->count())
1623  return QTabBar::tr("Activate");
1624  else //it's an scroll button
1625  return QTabBar::tr("Press");
1626  }
1627  break;
1629  if ((action == 1) && (child <= tabBar()->count())) {
1630  return tabBar()->tabsClosable() ? QTabBar::tr("Close the tab") : QString();
1631  } else if (action == 0) {
1632  if (child <= tabBar()->count())
1633  return QTabBar::tr("Activate the tab");
1634  }
1635  break;
1636  default:
1637  break;
1638  }
1639  return QString();
1640 }
1641 
1644 {
1645  if (!child || (child > tabBar()->count()))
1646  return 0;
1647  return tabBar()->tabsClosable() ? 1 : 0;
1648 }
1649 
1651 bool QAccessibleTabBar::doAction(int action, int child, const QVariantList &)
1652 {
1653  if (!child)
1654  return false;
1655 
1656  if ((action == 1) && (child <= tabBar()->count()) && tabBar()->tabsClosable()) {
1657  emit tabBar()->tabCloseRequested(child - 1);
1658  }
1659 
1660  if (action != QAccessible::DefaultAction && action != QAccessible::Press)
1661  return false;
1662 
1663  if (child > tabBar()->count()) {
1664  QAbstractButton *bt = button(child);
1665  if (!bt->isEnabled())
1666  return false;
1667  bt->animateClick();
1668  return true;
1669  }
1670  if (!tabBar()->isTabEnabled(child - 1))
1671  return false;
1672  tabBar()->setCurrentIndex(child - 1);
1673  return true;
1674 }
1675 
1686 bool QAccessibleTabBar::setSelected(int child, bool on, bool extend)
1687 {
1688  if (!child || !on || extend || child > tabBar()->count())
1689  return false;
1690 
1691  if (!tabBar()->isTabEnabled(child - 1))
1692  return false;
1693  tabBar()->setCurrentIndex(child - 1);
1694  return true;
1695 }
1696 
1704 {
1705  QVector<int> array;
1706  if (tabBar()->currentIndex() != -1)
1707  array +=tabBar()->currentIndex() + 1;
1708  return array;
1709 }
1710 
1711 #endif // QT_NO_TABBAR
1712 
1713 #ifndef QT_NO_COMBOBOX
1714 
1741 {
1742  Q_ASSERT(comboBox());
1743 }
1744 
1749 {
1750  return qobject_cast<QComboBox*>(object());
1751 }
1752 
1755 {
1756  QPoint tp;
1757  QStyle::SubControl sc;
1758  QRect r;
1759  switch (child) {
1760  case CurrentText:
1761  if (comboBox()->isEditable()) {
1762  tp = comboBox()->lineEdit()->mapToGlobal(QPoint(0,0));
1763  r = comboBox()->lineEdit()->rect();
1764  sc = QStyle::SC_None;
1765  } else {
1766  tp = comboBox()->mapToGlobal(QPoint(0,0));
1768  }
1769  break;
1770  case OpenList:
1771  tp = comboBox()->mapToGlobal(QPoint(0,0));
1773  break;
1774  default:
1775  return QAccessibleWidgetEx::rect(child);
1776  }
1777 
1778  if (sc != QStyle::SC_None) {
1779  QStyleOptionComboBox option;
1780  option.initFrom(comboBox());
1781  r = comboBox()->style()->subControlRect(QStyle::CC_ComboBox, &option, sc, comboBox());
1782  }
1783  return QRect(tp.x() + r.x(), tp.y() + r.y(), r.width(), r.height());
1784 }
1785 
1788 {
1789  *target = 0;
1790  if (entry > ComboBoxSelf) switch (rel) {
1791  case Child:
1792  if (entry == CurrentText && comboBox()->isEditable()) {
1793  *target = QAccessible::queryAccessibleInterface(comboBox()->lineEdit());
1794  return *target ? 0 : -1;
1795  } else if (entry < PopupList) {
1796  return entry;
1797  } else if (entry == PopupList) {
1798  QAbstractItemView *view = comboBox()->view();
1799  QWidget *parent = view ? view->parentWidget() : 0;
1800  *target = QAccessible::queryAccessibleInterface(parent);
1801  return *target ? 0 : -1;
1802  }
1803  case QAccessible::Left:
1804  return entry == OpenList ? CurrentText : -1;
1805  case QAccessible::Right:
1806  return entry == CurrentText ? OpenList : -1;
1807  case QAccessible::Up:
1808  return -1;
1809  case QAccessible::Down:
1810  return -1;
1811  default:
1812  break;
1813  }
1814  return QAccessibleWidgetEx::navigate(rel, entry, target);
1815 }
1816 
1819 {
1820  return comboBox()->view() ? PopupList : OpenList;
1821 }
1822 
1824 int QAccessibleComboBox::childAt(int x, int y) const
1825 {
1826  if (!comboBox()->isVisible())
1827  return -1;
1828  QPoint gp = widget()->mapToGlobal(QPoint(0, 0));
1829  if (!QRect(gp.x(), gp.y(), widget()->width(), widget()->height()).contains(x, y))
1830  return -1;
1831 
1832  // a complex control
1833  for (int i = 1; i < PopupList; ++i) {
1834  if (rect(i).contains(x, y))
1835  return i;
1836  }
1837  return 0;
1838 }
1839 
1842 {
1843  QObject *viewParent = comboBox()->view() ? comboBox()->view()->parentWidget() : 0;
1844  if (child->object() == viewParent)
1845  return PopupList;
1846  return -1;
1847 }
1848 
1851 {
1852  QString str;
1853 
1854  switch (t) {
1855  case Name:
1856 #ifndef Q_WS_X11 // on Linux we use relations for this, name is text (fall through to Value)
1857  if (child == OpenList)
1858  str = QComboBox::tr("Open");
1859  else
1860  str = QAccessibleWidgetEx::text(t, 0);
1861  break;
1862 #endif
1863  case Value:
1864  if (comboBox()->isEditable())
1865  str = comboBox()->lineEdit()->text();
1866  else
1867  str = comboBox()->currentText();
1868  break;
1869 #ifndef QT_NO_SHORTCUT
1870  case Accelerator:
1871  if (child == OpenList)
1873  break;
1874 #endif
1875  default:
1876  break;
1877  }
1878  if (str.isEmpty())
1879  str = QAccessibleWidgetEx::text(t, 0);
1880  return str;
1881 }
1882 
1885 {
1886  switch (child) {
1887  case CurrentText:
1888  if (comboBox()->isEditable())
1889  return EditableText;
1890  return StaticText;
1891  case OpenList:
1892  return PushButton;
1893  case PopupList:
1894  return List;
1895  default:
1896  return ComboBox;
1897  }
1898 }
1899 
1902 {
1903  return QAccessibleWidgetEx::state(0);
1904 }
1905 
1907 bool QAccessibleComboBox::doAction(int action, int child, const QVariantList &)
1908 {
1909  if (child == 2 && (action == DefaultAction || action == Press)) {
1910  if (comboBox()->view()->isVisible()) {
1911  comboBox()->hidePopup();
1912  } else {
1913  comboBox()->showPopup();
1914  }
1915  return true;
1916  }
1917  return false;
1918 }
1919 
1920 QString QAccessibleComboBox::actionText(int action, Text t, int child) const
1921 {
1922  QString text;
1923  if (child == 2 && t == Name && (action == DefaultAction || action == Press))
1924  text = comboBox()->view()->isVisible() ? QComboBox::tr("Close") : QComboBox::tr("Open");
1925  return text;
1926 }
1927 #endif // QT_NO_COMBOBOX
1928 
1930 {
1931  if (!list || list->isEmpty())
1932  return;
1933 
1934  for (int i = 0; i < list->count(); ++i) {
1935  QWidget *widget = list->at(i);
1936  if (!widget->isVisible())
1937  list->removeAt(i);
1938  }
1939 }
1940 
1941 #ifndef QT_NO_SCROLLAREA
1942 // ======================= QAccessibleAbstractScrollArea =======================
1944  : QAccessibleWidgetEx(widget, Client)
1945 {
1946  Q_ASSERT(qobject_cast<QAbstractScrollArea *>(widget));
1947 }
1948 
1950 {
1951  if (child == Self)
1952  return QAccessibleWidgetEx::text(textType, 0);
1953  QWidgetList children = accessibleChildren();
1954  if (child < 1 || child > children.count())
1955  return QString();
1956  QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
1957  if (!childInterface)
1958  return QString();
1959  QString string = childInterface->text(textType, 0);
1960  delete childInterface;
1961  return string;
1962 }
1963 
1964 void QAccessibleAbstractScrollArea::setText(Text textType, int child, const QString &text)
1965 {
1966  if (text.isEmpty())
1967  return;
1968  if (child == 0) {
1969  QAccessibleWidgetEx::setText(textType, 0, text);
1970  return;
1971  }
1972  QWidgetList children = accessibleChildren();
1973  if (child < 1 || child > children.count())
1974  return;
1975  QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
1976  if (!childInterface)
1977  return;
1978  childInterface->setText(textType, 0, text);
1979  delete childInterface;
1980 }
1981 
1983 {
1984  if (child == Self)
1985  return QAccessibleWidgetEx::state(child);
1986  QWidgetList children = accessibleChildren();
1987  if (child < 1 || child > children.count())
1989  QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
1990  if (!childInterface)
1992  QAccessible::State returnState = childInterface->state(0);
1993  delete childInterface;
1994  return returnState;
1995 }
1996 
1998 {
1999  return QVariant();
2000 }
2001 
2003 {
2004  return accessibleChildren().count();
2005 }
2006 
2008 {
2009  if (!child || !child->object())
2010  return -1;
2011  int index = accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object()));
2012  if (index >= 0)
2013  return ++index;
2014  return -1;
2015 }
2016 
2018 {
2019  return (QAccessibleWidgetEx::isValid() && abstractScrollArea() && abstractScrollArea()->viewport());
2020 }
2021 
2023 {
2024  if (!target)
2025  return -1;
2026 
2027  *target = 0;
2028 
2029  QWidget *targetWidget = 0;
2030  QWidget *entryWidget = 0;
2031 
2032  if (relation == Child ||
2033  relation == Left || relation == Up || relation == Right || relation == Down) {
2034  QWidgetList children = accessibleChildren();
2035  if (entry < 0 || entry > children.count())
2036  return -1;
2037 
2038  if (entry == Self)
2039  entryWidget = abstractScrollArea();
2040  else
2041  entryWidget = children.at(entry - 1);
2042  AbstractScrollAreaElement entryElement = elementType(entryWidget);
2043 
2044  // Not one of the most beautiful switches I've ever seen, but I believe it has
2045  // to be like this since each case need special handling.
2046  // It might be possible to make it more general, but I'll leave that as an exercise
2047  // to the reader. :-)
2048  switch (relation) {
2049  case Child:
2050  if (entry > 0)
2051  targetWidget = children.at(entry - 1);
2052  break;
2053  case Left:
2054  if (entry < 1)
2055  break;
2056  switch (entryElement) {
2057  case Viewport:
2058  if (!isLeftToRight())
2059  targetWidget = abstractScrollArea()->verticalScrollBar();
2060  break;
2061  case HorizontalContainer:
2062  if (!isLeftToRight())
2063  targetWidget = abstractScrollArea()->cornerWidget();
2064  break;
2065  case VerticalContainer:
2066  if (isLeftToRight())
2067  targetWidget = abstractScrollArea()->viewport();
2068  break;
2069  case CornerWidget:
2070  if (isLeftToRight())
2071  targetWidget = abstractScrollArea()->horizontalScrollBar();
2072  break;
2073  default:
2074  break;
2075  }
2076  break;
2077  case Right:
2078  if (entry < 1)
2079  break;
2080  switch (entryElement) {
2081  case Viewport:
2082  if (isLeftToRight())
2083  targetWidget = abstractScrollArea()->verticalScrollBar();
2084  break;
2085  case HorizontalContainer:
2086  targetWidget = abstractScrollArea()->cornerWidget();
2087  break;
2088  case VerticalContainer:
2089  if (!isLeftToRight())
2090  targetWidget = abstractScrollArea()->viewport();
2091  break;
2092  case CornerWidget:
2093  if (!isLeftToRight())
2094  targetWidget = abstractScrollArea()->horizontalScrollBar();
2095  break;
2096  default:
2097  break;
2098  }
2099  break;
2100  case Up:
2101  if (entry < 1)
2102  break;
2103  switch (entryElement) {
2104  case HorizontalContainer:
2105  targetWidget = abstractScrollArea()->viewport();
2106  break;
2107  case CornerWidget:
2108  targetWidget = abstractScrollArea()->verticalScrollBar();
2109  break;
2110  default:
2111  break;
2112  }
2113  break;
2114  case Down:
2115  if (entry < 1)
2116  break;
2117  switch (entryElement) {
2118  case Viewport:
2119  targetWidget = abstractScrollArea()->horizontalScrollBar();
2120  break;
2121  case VerticalContainer:
2122  targetWidget = abstractScrollArea()->cornerWidget();
2123  break;
2124  default:
2125  break;
2126  }
2127  break;
2128  default:
2129  break;
2130  }
2131  } else {
2132  return QAccessibleWidgetEx::navigate(relation, entry, target);
2133  }
2134 
2135  if (qobject_cast<const QScrollBar *>(targetWidget))
2136  targetWidget = targetWidget->parentWidget();
2137  *target = QAccessible::queryAccessibleInterface(targetWidget);
2138  return *target ? 0: -1;
2139 }
2140 
2142 {
2143  if (!abstractScrollArea()->isVisible())
2144  return QRect();
2145  if (child == Self)
2146  return QAccessibleWidgetEx::rect(child);
2147  QWidgetList children = accessibleChildren();
2148  if (child < 1 || child > children.count())
2149  return QRect();
2150  const QWidget *childWidget = children.at(child - 1);
2151  if (!childWidget->isVisible())
2152  return QRect();
2153  return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size());
2154 }
2155 
2157 {
2158  if (!abstractScrollArea()->isVisible())
2159  return -1;
2160 #if 0
2161  const QRect globalSelfGeometry = rect(Self);
2162  if (!globalSelfGeometry.isValid() || !globalSelfGeometry.contains(QPoint(x, y)))
2163  return -1;
2164  const QWidgetList children = accessibleChildren();
2165  for (int i = 0; i < children.count(); ++i) {
2166  const QWidget *child = children.at(i);
2167  const QRect globalChildGeometry = QRect(child->mapToGlobal(QPoint(0, 0)), child->size());
2168  if (globalChildGeometry.contains(QPoint(x, y))) {
2169  return ++i;
2170  }
2171  }
2172  return 0;
2173 #else
2174  for (int i = childCount(); i >= 0; --i) {
2175  if (rect(i).contains(x, y))
2176  return i;
2177  }
2178  return -1;
2179 #endif
2180 }
2181 
2183 {
2184  return static_cast<QAbstractScrollArea *>(object());
2185 }
2186 
2188 {
2189  QWidgetList children;
2190 
2191  // Viewport.
2192  QWidget * viewport = abstractScrollArea()->viewport();
2193  if (viewport)
2194  children.append(viewport);
2195 
2196  // Horizontal scrollBar container.
2197  QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar();
2198  if (horizontalScrollBar && horizontalScrollBar->isVisible()) {
2199  children.append(horizontalScrollBar->parentWidget());
2200  }
2201 
2202  // Vertical scrollBar container.
2203  QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar();
2204  if (verticalScrollBar && verticalScrollBar->isVisible()) {
2205  children.append(verticalScrollBar->parentWidget());
2206  }
2207 
2208  // CornerWidget.
2209  QWidget *cornerWidget = abstractScrollArea()->cornerWidget();
2210  if (cornerWidget && cornerWidget->isVisible())
2211  children.append(cornerWidget);
2212 
2213  return children;
2214 }
2215 
2218 {
2219  if (!widget)
2220  return Undefined;
2221 
2222  if (widget == abstractScrollArea())
2223  return Self;
2224  if (widget == abstractScrollArea()->viewport())
2225  return Viewport;
2226  if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer"))
2227  return HorizontalContainer;
2228  if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer"))
2229  return VerticalContainer;
2230  if (widget == abstractScrollArea()->cornerWidget())
2231  return CornerWidget;
2232 
2233  return Undefined;
2234 }
2235 
2237 {
2238  return abstractScrollArea()->isLeftToRight();
2239 }
2240 
2241 // ======================= QAccessibleScrollArea ===========================
2244 {
2245  Q_ASSERT(qobject_cast<QScrollArea *>(widget));
2246 }
2247 #endif // QT_NO_SCROLLAREA
2248 
2250 
2251 #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
static QItemSelection rowAt(const QModelIndex &idx)
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
QModelIndexList selectedRows(int column=0) const
Returns the indexes in the given column for the rows where all columns are selected.
T qobject_cast(QObject *object)
Definition: qobject.h:375
int columnIndex(int childIndex)
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
int rowSpan(int row, int column)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int row() const
Returns the row this persistent model index refers to.
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...
The QItemSelectionModel class keeps track of a view&#39;s selected items.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
SubControl
This enum describes the available sub controls.
Definition: qstyle.h:402
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
QString text_helper(int child) const
QRect rect(int child) const
Reimplemented Function
AbstractScrollAreaElement elementType(QWidget *widget) const
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int childCount() const
Reimplemented Function
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int childCount() const
Returns the number of children that belong to this object.
QAccessibleAbstractScrollArea(QWidget *widget)
EventRef event
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
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...
int indexOfChild(const QAccessibleInterface *child) const
Reimplemented Function
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isActiveWindow
whether this widget&#39;s window is the active window
Definition: qwidget.h:186
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
Reimplemented Function
State state(int child) const
Reimplemented Function
#define it(className, varName)
virtual bool isIndexHidden(const QModelIndex &index) const =0
Returns true if the item referred to by the given index is hidden in the view, otherwise returns fals...
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
QToolButton * rightB
Definition: qtabbar_p.h:170
bool isColumnSelected(int column, const QModelIndex &parent) const
Returns true if all items are selected in the column with the given parent.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=0) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
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...
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QAccessibleTabBar(QWidget *w)
Constructs a QAccessibleTabBar object for w.
bool isTabEnabled(int index) const
Returns true if the tab at position index is enabled; otherwise returns false.
Definition: qtabbar.cpp:977
Role
This enum defines the role of an accessible object.
Definition: qaccessible.h:188
QWidgetList accessibleChildren() const
int childAt(int x, int y) const
Reimplemented Function
QAccessibleInterface * rowHeader()
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
bool doAction(int action, int child, const QVariantList &params)
Reimplemented Function
int columnSpan(int row, int column)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
const QItemSelection selection() const
Returns the selection ranges stored in the selection model.
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
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QVector< int > selection() const
Returns a (possibly empty) list of indexes of the items selected in the list box. ...
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...
void setCurrentIndex(int index)
Definition: qtabbar.cpp:1238
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void selectColumn(int column)
Role role(int child) const
Reimplemented Function
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QAbstractScrollArea widget provides a scrolling area with on-demand scroll bars.
The QTabBar class provides a tab bar, e.g.
Definition: qtabbar.h:59
QWidget * cornerWidget() const
Returns the widget in the corner between the two scroll bars.
QAccessibleComboBox(QWidget *w)
Constructs a QAccessibleComboBox object for w.
QAbstractButton * button(int child) const
QTabBar * tabBar() const
Returns the QTabBar.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this positi...
Role role(int child) const
Reimplemented Function
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...
QModelIndex childIndex(int child) const
int rowIndex(int childIndex)
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool doAction(int action, int child, const QVariantList &params)
Reimplemented Function
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void setUpdatesEnabled(bool enable)
Definition: qwidget.cpp:7670
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.
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction...
int height() const
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
bool isSectionHidden(int logicalIndex) const
Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise r...
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
QToolButton * leftB
Definition: qtabbar_p.h:171
QWidget * indexWidget(const QModelIndex &index) const
Returns the widget for the item at the given index.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns the data for the given role and section in the header with the specified orientation.
QAccessibleInterface * columnHeader()
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.
SelectionMode selectionMode
which selection mode the view operates in
bool tabsClosable
Whether or not a tab bar should place close buttons on each tab.
Definition: qtabbar.h:71
QList< QModelIndex > children() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QStyle * style() const
Definition: qwidget.cpp:2742
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 logicalFromChild(QHeaderView *header, int child) const
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...
QAccessibleScrollArea(QWidget *widget)
QString text(Text t, int child) const
Reimplemented Function
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
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...
QWidget * viewport() const
Returns the viewport widget.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
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.
static QString toString(Register *reg, int type, bool *ok=0)
The QScrollBar widget provides a vertical or horizontal scroll bar.
Definition: qscrollbar.h:59
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QString text(Text t, int child) const
Reimplemented Function
bool sectionsHidden() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QAbstractItemView::CursorAction toCursorAction(Relation rel)
bool setSelected(int child, bool on, bool extend)
Selects the item with index child if on is true; otherwise unselects it.
int childCount() const
Reimplemented Function
friend class QAccessibleItemView
QHeaderView * header() const
Returns the QHeaderView.
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
int indexOfChild(const QAccessibleInterface *) 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(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
int childCount() const
Reimplemented Function
The QAccessibleEvent class is used to query addition accessibility information about complex widgets...
Definition: qaccessible.h:449
bool isValidChildRole(QAccessible::Role role) const
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
QAccessibleInterface * caption()
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 isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QItemSelectionModel * selectionModel() const
Returns the current selection model.
Qt::Orientation orientation() const
Returns the orientation of the header.
bool isSelected(const QModelIndex &index) const
Returns true if the given model item index is selected.
int width() const
RelationFlag
This enum type defines bit flags that can be combined to indicate the relationship between two access...
Definition: qaccessible.h:268
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
QString text
the line edit&#39;s text
Definition: qlineedit.h:72
void initFrom(const QWidget *w)
Definition: qstyleoption.h:99
const QAbstractItemModel * model() const
Returns the model that the index belongs to.
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Definition: qmime_win.cpp:141
int row() const
Returns the row this model index refers to.
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
Method
This enum describes the possible types of methods that can be invoked on an accessible object...
Definition: qaccessible.h:311
QModelIndex current() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int userActionCount(int child) const
Reimplemented Function
#define emit
Definition: qobjectdefs.h:76
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
int navigate(RelationFlag relation, int index, 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 QComboBox widget is a combined button and popup list.
Definition: qcombobox.h:62
QModelIndex parent() const
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no pare...
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
QPointer< QAbstractItemView > view
QRect rect(int child) const
Reimplemented Function
static void removeInvisibleWidgetsFromList(QWidgetList *list)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QAccessibleItemView(QWidget *w)
int navigate(RelationFlag relation, int index, 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 entryFromIndex(const QModelIndex &index) const
QModelIndex currentIndex() const
Returns the model index of the current item.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
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...
QAccessibleHeader(QWidget *w)
Constructs a QAccessibleHeader object for w.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
QModelIndex currentIndex() const
Returns the model item index for the current item, or an invalid index if there is no current item...
The State element defines configurations of objects and properties.
QHeaderView * verticalHeader() const
QAbstractItemView * itemView() const
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
bool isColumnSelected(int column)
QAbstractScrollArea * abstractScrollArea() const
The QTableView class provides a default model/view implementation of a table view.
Definition: qtableview.h:58
QString text(Text t, int child) const
Reimplemented Function
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
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
QString actionText(int action, Text t, int child) const
Reimplemented Function
bool isEnabled() const
Definition: qwidget.h:948
static QWidget * parentWidget(const QWidget *w)
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...
The QAbstractItemModel class provides the abstract interface for item model classes.
virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
Sets the data for the given role and section in the header with the specified orientation to the valu...
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
The Row item arranges its children horizontally.
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 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...
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.
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
bool next(int count=1)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QHeaderView * verticalHeader() const
bool isSelected(int row, int column)
The QItemSelection class manages information about selected items in a model.
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
Reimplemented Function
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
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
int count
the number of tabs in the tab bar
Definition: qtabbar.h:66
QRect rect(int child) const
Reimplemented Function
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...
QModelIndexList selectedColumns(int row=0) const
Returns the indexes in the given row for columns where all rows are selected.
State
Definition: qaudio.h:59
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
void addControllingSignal(const QString &signal)
State state(int child) const
Reimplemented Function
QWidget * widget() const
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
virtual void showPopup()
Displays the list of items in the combobox.
Definition: qcombobox.cpp:2447
QString rowDescription(int row)
int childCount() const
Returns the number of children that belong to this object.
QAbstractItemView * view() const
Returns the list view used for the combobox popup.
Definition: qcombobox.cpp:2385
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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 setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
#define st(var, type, card)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
QModelIndex index(int row, int column) const
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
ModelIndexIterator(QAbstractItemView *view, const QModelIndex &start=QModelIndex())
virtual QString text(Text t, int child) const =0
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
int count() const
Returns the number of sections in the header.
The QStyleOptionComboBox class is used to describe the parameter for drawing a combobox.
Definition: qstyleoption.h:796
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
QString objectName() const
int sectionSize(int logicalIndex) const
Returns the width (or height for vertical headers) of the given logicalIndex.
QAbstractItemView * m_view
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...
static const int zero
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QRect tabRect(int index) const
Returns the visual rectangle of the tab at position index, or a null rectangle if index is out of ran...
Definition: qtabbar.cpp:1179
quint16 index
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.
bool isLeftToRight() const
Definition: qwidget.h:429
void tabCloseRequested(int index)
This signal is emitted when the close button on a tab is clicked.
void unselectRow(int row)
Role role(int child) const
Reimplemented Function
QHeaderView * horizontalHeader() const
QString currentText
the current text
Definition: qcombobox.h:70
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text)
bool isRightToLeft() const
Definition: qwidget.h:428
QAccessibleItemRow(QAbstractItemView *view, const QModelIndex &index=QModelIndex(), bool isHeader=false)
QComboBox * comboBox() const
Returns the combobox.
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
State state(int child) const
Reimplemented Function
QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params)
CursorAction
This enum describes the different ways to navigate between items,.
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
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 x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
void unselectColumn(int column)
int sectionPosition(int logicalIndex) const
Returns the section position of the given logicalIndex, or -1 if the section is hidden.
void cellAtIndex(int index, int *row, int *column, int *rowSpan, int *columnSpan, bool *isSelected)
QLineEdit * lineEdit() const
Returns the line edit used to edit items in the combobox, or 0 if there is no line edit...
Definition: qcombobox.cpp:1858
virtual void hidePopup()
Hides the list of items in the combobox if it is currently visible and resets the internal state...
Definition: qcombobox.cpp:2685
int selectedColumns(int maxColumns, QList< int > *columns)
int childCount() const
Returns the number of children that belong to this object.
QHeaderView * horizontalHeader() const
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
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.
QAccessibleInterface * accessibleAt(int row, int column)
QModelIndex rootIndex() const
Returns the model index of the model&#39;s root item.
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
QAbstractItemModel * model() const
Returns the model that this view is presenting.
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
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
bool atViewport() const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QAccessibleInterface * summary()
QPersistentModelIndex row
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
QString columnDescription(int column)
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
int selectedRows(int maxRows, QList< int > *rows)
int currentIndex
the index of the tab bar&#39;s visible tab
Definition: qtabbar.h:65
QModelIndex childIndex(int child) const
virtual void setText(Text t, int child, const QString &text)=0
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
#define text
Definition: qobjectdefs.h:80
bool isRowSelected(int row, const QModelIndex &parent) const
Returns true if all items are selected in the row with the given parent.
bool isRowSelected(int row)
The QHeaderView class provides a header row or header column for item views.
Definition: qheaderview.h:58
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.
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480