Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
itemviews.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "itemviews_p.h"
5
6#include <qheaderview.h>
7#if QT_CONFIG(tableview)
8#include <qtableview.h>
9#endif
10#if QT_CONFIG(listview)
11#include <qlistview.h>
12#endif
13#if QT_CONFIG(treeview)
14#include <qtreeview.h>
15#include <private/qtreeview_p.h>
16#endif
17#include <private/qwidget_p.h>
18
19#if QT_CONFIG(accessibility)
20
22
23/*
24Implementation of the IAccessible2 table2 interface. Much simpler than
25the other table interfaces since there is only the main table and cells:
26
27TABLE/LIST/TREE
28 |- HEADER CELL
29 |- CELL
30 |- CELL
31 ...
32*/
33
34
35QAbstractItemView *QAccessibleTable::view() const
36{
37 return qobject_cast<QAbstractItemView*>(object());
38}
39
40int QAccessibleTable::logicalIndex(const QModelIndex &index) const
41{
42 const QAbstractItemView *theView = view();
43 const QAbstractItemModel *theModel = index.model();
44 if (!theModel || !index.isValid())
45 return -1;
46
47 const QModelIndex rootIndex = theView->rootIndex();
48 const int vHeader = verticalHeader() ? 1 : 0;
49 const int hHeader = horizontalHeader() ? 1 : 0;
50 return (index.row() + hHeader) * (theModel->columnCount(rootIndex) + vHeader)
51 + (index.column() + vHeader);
52}
53
54QAccessibleTable::QAccessibleTable(QWidget *w)
55 : QAccessibleObject(w)
56{
57 Q_ASSERT(view());
58
59#if QT_CONFIG(tableview)
60 if (qobject_cast<const QTableView*>(view())) {
61 m_role = QAccessible::Table;
62 } else
63#endif
64#if QT_CONFIG(treeview)
65 if (qobject_cast<const QTreeView*>(view())) {
66 m_role = QAccessible::Tree;
67 } else
68#endif
69#if QT_CONFIG(listview)
70 if (qobject_cast<const QListView*>(view())) {
71 m_role = QAccessible::List;
72 } else
73#endif
74 {
75 // is this our best guess?
76 m_role = QAccessible::Table;
77 }
78}
79
80bool QAccessibleTable::isValid() const
81{
82 return view() && !qt_widget_private(view())->data.in_destructor;
83}
84
85QAccessibleTable::~QAccessibleTable()
86{
87 for (QAccessible::Id id : std::as_const(childToId))
88 QAccessible::deleteAccessibleInterface(id);
89}
90
91QHeaderView *QAccessibleTable::horizontalHeader() const
92{
93 QHeaderView *header = nullptr;
94 if (false) {
95#if QT_CONFIG(tableview)
96 } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
97 header = tv->horizontalHeader();
98#endif
99#if QT_CONFIG(treeview)
100 } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view())) {
101 header = tv->header();
102#endif
103 }
104 return header;
105}
106
107QHeaderView *QAccessibleTable::verticalHeader() const
108{
109 QHeaderView *header = nullptr;
110 if (false) {
111#if QT_CONFIG(tableview)
112 } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
113 header = tv->verticalHeader();
114#endif
115 }
116 return header;
117}
118
119QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const
120{
121 const QAbstractItemView *theView = view();
122 const QAbstractItemModel *theModel = theView->model();
123 if (!theModel)
124 return nullptr;
125 Q_ASSERT(role() != QAccessible::Tree);
126 QModelIndex index = theModel->index(row, column, theView->rootIndex());
127 if (Q_UNLIKELY(!index.isValid())) {
128 qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << theView;
129 return nullptr;
130 }
131 return child(logicalIndex(index));
132}
133
134QAccessibleInterface *QAccessibleTable::caption() const
135{
136 return nullptr;
137}
138
139QString QAccessibleTable::columnDescription(int column) const
140{
141 const QAbstractItemView *theView = view();
142 const QAbstractItemModel *theModel = theView->model();
143 if (!theModel)
144 return QString();
145 return theModel->headerData(column, Qt::Horizontal).toString();
146}
147
148int QAccessibleTable::columnCount() const
149{
150 const QAbstractItemView *theView = view();
151 const QAbstractItemModel *theModel = theView->model();
152 if (!theModel)
153 return 0;
154 return theModel->columnCount(theView->rootIndex());
155}
156
157int QAccessibleTable::rowCount() const
158{
159 const QAbstractItemView *theView = view();
160 const QAbstractItemModel *theModel = theView->model();
161 if (!theModel)
162 return 0;
163 return theModel->rowCount(theView->rootIndex());
164}
165
166int QAccessibleTable::selectedCellCount() const
167{
168 if (!view()->selectionModel())
169 return 0;
170 return view()->selectionModel()->selectedIndexes().size();
171}
172
173int QAccessibleTable::selectedColumnCount() const
174{
175 if (!view()->selectionModel())
176 return 0;
177 return view()->selectionModel()->selectedColumns().size();
178}
179
180int QAccessibleTable::selectedRowCount() const
181{
182 if (!view()->selectionModel())
183 return 0;
184 return view()->selectionModel()->selectedRows().size();
185}
186
187QString QAccessibleTable::rowDescription(int row) const
188{
189 const QAbstractItemView *theView = view();
190 const QAbstractItemModel *theModel = theView->model();
191 if (!theModel)
192 return QString();
193 return theModel->headerData(row, Qt::Vertical).toString();
194}
195
196QList<QAccessibleInterface *> QAccessibleTable::selectedCells() const
197{
198 QList<QAccessibleInterface*> cells;
199 if (!view()->selectionModel())
200 return cells;
201 const QModelIndexList selectedIndexes = view()->selectionModel()->selectedIndexes();
202 cells.reserve(selectedIndexes.size());
203 for (const QModelIndex &index : selectedIndexes)
204 cells.append(child(logicalIndex(index)));
205 return cells;
206}
207
208QList<int> QAccessibleTable::selectedColumns() const
209{
210 if (!view()->selectionModel())
211 return QList<int>();
212 QList<int> columns;
213 const QModelIndexList selectedColumns = view()->selectionModel()->selectedColumns();
214 columns.reserve(selectedColumns.size());
215 for (const QModelIndex &index : selectedColumns)
216 columns.append(index.column());
217
218 return columns;
219}
220
221QList<int> QAccessibleTable::selectedRows() const
222{
223 if (!view()->selectionModel())
224 return QList<int>();
225 QList<int> rows;
226 const QModelIndexList selectedRows = view()->selectionModel()->selectedRows();
227 rows.reserve(selectedRows.size());
228 for (const QModelIndex &index : selectedRows)
229 rows.append(index.row());
230
231 return rows;
232}
233
234QAccessibleInterface *QAccessibleTable::summary() const
235{
236 return nullptr;
237}
238
239bool QAccessibleTable::isColumnSelected(int column) const
240{
241 if (!view()->selectionModel())
242 return false;
243 return view()->selectionModel()->isColumnSelected(column, QModelIndex());
244}
245
246bool QAccessibleTable::isRowSelected(int row) const
247{
248 if (!view()->selectionModel())
249 return false;
250 return view()->selectionModel()->isRowSelected(row, QModelIndex());
251}
252
253bool QAccessibleTable::selectRow(int row)
254{
255 QAbstractItemView *theView = view();
256 const QAbstractItemModel *theModel = theView->model();
257 if (!theModel || !view()->selectionModel())
258 return false;
259
260 const QModelIndex rootIndex = theView->rootIndex();
261 const QModelIndex index = theModel->index(row, 0, rootIndex);
262
263 if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns)
264 return false;
265
266 switch (view()->selectionMode()) {
268 return false;
270 if (view()->selectionBehavior() != QAbstractItemView::SelectRows && columnCount() > 1 )
271 return false;
272 view()->clearSelection();
273 break;
275 if ((!row || !theView->selectionModel()->isRowSelected(row - 1, rootIndex))
276 && !theView->selectionModel()->isRowSelected(row + 1, rootIndex)) {
277 theView->clearSelection();
278 }
279 break;
280 default:
281 break;
282 }
283
284 view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
285 return true;
286}
287
288bool QAccessibleTable::selectColumn(int column)
289{
290 QAbstractItemView *theView = view();
291 const QAbstractItemModel *theModel = theView->model();
292 auto *selectionModel = theView->selectionModel();
293 if (!theModel || !selectionModel)
294 return false;
295
296 const QModelIndex rootIndex = theView->rootIndex();
297 const QModelIndex index = theModel->index(0, column, rootIndex);
298
299 if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectRows)
300 return false;
301
302 switch (theView->selectionMode()) {
304 return false;
306 if (theView->selectionBehavior() != QAbstractItemView::SelectColumns && rowCount() > 1)
307 return false;
310 if ((!column || !selectionModel->isColumnSelected(column - 1, rootIndex))
311 && !selectionModel->isColumnSelected(column + 1, rootIndex)) {
312 theView->clearSelection();
313 }
314 break;
315 default:
316 break;
317 }
318
320 return true;
321}
322
323bool QAccessibleTable::unselectRow(int row)
324{
325 const QAbstractItemView *theView = view();
326 const QAbstractItemModel *theModel = theView->model();
327 auto *selectionModel = theView->selectionModel();
328 if (!theModel || !selectionModel)
329 return false;
330
331 const QModelIndex rootIndex = theView->rootIndex();
332 const QModelIndex index = view()->model()->index(row, 0, rootIndex);
333 if (!index.isValid())
334 return false;
335
337
338 switch (theView->selectionMode()) {
340 //In SingleSelection and ContiguousSelection once an item
341 //is selected, there's no way for the user to unselect all items
342 if (selectedRowCount() == 1)
343 return false;
344 break;
346 if (selectedRowCount() == 1)
347 return false;
348
349 if ((!row || selectionModel->isRowSelected(row - 1, rootIndex))
350 && selectionModel->isRowSelected(row + 1, rootIndex)) {
351 //If there are rows selected both up the current row and down the current rown,
352 //the ones which are down the current row will be deselected
353 selection = QItemSelection(index, theModel->index(rowCount() - 1, 0, rootIndex));
354 }
355 break;
356 default:
357 break;
358 }
359
361 return true;
362}
363
364bool QAccessibleTable::unselectColumn(int column)
365{
366 const QAbstractItemView *theView = view();
367 const QAbstractItemModel *theModel = theView->model();
368 auto *selectionModel = theView->selectionModel();
369 if (!theModel || !selectionModel)
370 return false;
371
372 const QModelIndex rootIndex = theView->rootIndex();
373 const QModelIndex index = view()->model()->index(0, column, rootIndex);
374 if (!index.isValid())
375 return false;
376
378
379 switch (view()->selectionMode()) {
381 //In SingleSelection and ContiguousSelection once an item
382 //is selected, there's no way for the user to unselect all items
383 if (selectedColumnCount() == 1)
384 return false;
385 break;
387 if (selectedColumnCount() == 1)
388 return false;
389
390 if ((!column || selectionModel->isColumnSelected(column - 1, rootIndex))
391 && selectionModel->isColumnSelected(column + 1, rootIndex)) {
392 //If there are columns selected both at the left of the current row and at the right
393 //of the current rown, the ones which are at the right will be deselected
394 selection = QItemSelection(index, theModel->index(0, columnCount() - 1, rootIndex));
395 }
396 break;
397 default:
398 break;
399 }
400
402 return true;
403}
404
405int QAccessibleTable::selectedItemCount() const
406{
407 return selectedCellCount();
408}
409
410QList<QAccessibleInterface*> QAccessibleTable::selectedItems() const
411{
412 return selectedCells();
413}
414
415bool QAccessibleTable::isSelected(QAccessibleInterface *childCell) const
416{
417 if (!childCell || childCell->parent() != this) {
418 qWarning() << "QAccessibleTable::isSelected: Accessible interface must be a direct child of the table interface.";
419 return false;
420 }
421
422 const QAccessibleTableCellInterface *cell = childCell->tableCellInterface();
423 if (cell)
424 return cell->isSelected();
425
426 return false;
427}
428
429bool QAccessibleTable::select(QAccessibleInterface *childCell)
430{
431 if (!childCell || childCell->parent() != this) {
432 qWarning() << "QAccessibleTable::select: Accessible interface must be a direct child of the table interface.";
433 return false;
434 }
435
436 if (!childCell->tableCellInterface()) {
437 qWarning() << "QAccessibleTable::select: Accessible interface doesn't implement table cell interface.";
438 return false;
439 }
440
441 if (childCell->role() == QAccessible::Cell || childCell->role() == QAccessible::ListItem || childCell->role() == QAccessible::TreeItem) {
442 QAccessibleTableCell* cell = static_cast<QAccessibleTableCell*>(childCell);
443 cell->selectCell();
444 return true;
445 }
446
447 return false;
448}
449
450bool QAccessibleTable::unselect(QAccessibleInterface *childCell)
451{
452 if (!childCell || childCell->parent() != this) {
453 qWarning() << "QAccessibleTable::select: Accessible interface must be a direct child of the table interface.";
454 return false;
455 }
456
457 if (!childCell->tableCellInterface()) {
458 qWarning() << "QAccessibleTable::unselect: Accessible interface doesn't implement table cell interface.";
459 return false;
460 }
461
462 if (childCell->role() == QAccessible::Cell || childCell->role() == QAccessible::ListItem || childCell->role() == QAccessible::TreeItem) {
463 QAccessibleTableCell* cell = static_cast<QAccessibleTableCell*>(childCell);
464 cell->unselectCell();
465 return true;
466 }
467
468 return false;
469}
470
471bool QAccessibleTable::selectAll()
472{
473 view()->selectAll();
474 return true;
475}
476
477bool QAccessibleTable::clear()
478{
479 view()->selectionModel()->clearSelection();
480 return true;
481}
482
483
484QAccessible::Role QAccessibleTable::role() const
485{
486 return m_role;
487}
488
489QAccessible::State QAccessibleTable::state() const
490{
492 const auto *w = view();
493
494 if (w->testAttribute(Qt::WA_WState_Visible) == false)
495 state.invisible = true;
496 if (w->focusPolicy() != Qt::NoFocus)
497 state.focusable = true;
498 if (w->hasFocus())
499 state.focused = true;
500 if (!w->isEnabled())
501 state.disabled = true;
502 if (w->isWindow()) {
503 if (w->windowFlags() & Qt::WindowSystemMenuHint)
504 state.movable = true;
505 if (w->minimumSize() != w->maximumSize())
506 state.sizeable = true;
507 if (w->isActiveWindow())
508 state.active = true;
509 }
510
511 return state;
512}
513
514QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const
515{
516 QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0));
517 QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset);
518 // FIXME: if indexPosition < 0 in one coordinate, return header
519
520 const QModelIndex index = view()->indexAt(indexPosition);
521 if (index.isValid())
522 return child(logicalIndex(index));
523 return nullptr;
524}
525
526QAccessibleInterface *QAccessibleTable::focusChild() const
527{
528 QModelIndex index = view()->currentIndex();
529 if (!index.isValid())
530 return nullptr;
531
532 return child(logicalIndex(index));
533}
534
535int QAccessibleTable::childCount() const
536{
537 const QAbstractItemView *theView = view();
538 const QAbstractItemModel *theModel = theView->model();
539 if (!theModel)
540 return 0;
541 const QModelIndex rootIndex = theView->rootIndex();
542 int vHeader = verticalHeader() ? 1 : 0;
543 int hHeader = horizontalHeader() ? 1 : 0;
544 return (theModel->rowCount(rootIndex) + hHeader) * (theModel->columnCount(rootIndex) + vHeader);
545}
546
547int QAccessibleTable::indexOfChild(const QAccessibleInterface *iface) const
548{
549 const QAbstractItemView *theView = view();
550 const QAbstractItemModel *theModel = theView->model();
551 if (!theModel)
552 return -1;
553 QAccessibleInterface *parent = iface->parent();
554 if (parent->object() != theView)
555 return -1;
556
557 const QModelIndex rootIndex = theView->rootIndex();
558 Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class
559 if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
560 const QAccessibleTableCell* cell = static_cast<const QAccessibleTableCell*>(iface);
561 return logicalIndex(cell->m_index);
562 } else if (iface->role() == QAccessible::ColumnHeader){
563 const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
564 return cell->index + (verticalHeader() ? 1 : 0);
565 } else if (iface->role() == QAccessible::RowHeader){
566 const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
567 return (cell->index + 1) * (theModel->columnCount(rootIndex) + 1);
568 } else if (iface->role() == QAccessible::Pane) {
569 return 0; // corner button
570 } else {
571 qWarning() << "WARNING QAccessibleTable::indexOfChild Fix my children..."
572 << iface->role() << iface->text(QAccessible::Name);
573 }
574 // FIXME: we are in denial of our children. this should stop.
575 return -1;
576}
577
578QString QAccessibleTable::text(QAccessible::Text t) const
579{
580 if (t == QAccessible::Description)
581 return view()->accessibleDescription();
582 return view()->accessibleName();
583}
584
585QRect QAccessibleTable::rect() const
586{
587 if (!view()->isVisible())
588 return QRect();
589 QPoint pos = view()->mapToGlobal(QPoint(0, 0));
590 return QRect(pos.x(), pos.y(), view()->width(), view()->height());
591}
592
593QAccessibleInterface *QAccessibleTable::parent() const
594{
595 if (view() && view()->parent()) {
596 if (qstrcmp("QComboBoxPrivateContainer", view()->parent()->metaObject()->className()) == 0) {
597 return QAccessible::queryAccessibleInterface(view()->parent()->parent());
598 }
599 return QAccessible::queryAccessibleInterface(view()->parent());
600 }
601 return QAccessible::queryAccessibleInterface(qApp);
602}
603
604QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
605{
606 QAbstractItemView *theView = view();
607 const QAbstractItemModel *theModel = theView->model();
608 if (!theModel)
609 return nullptr;
610
611 const QModelIndex rootIndex = theView->rootIndex();
612 auto id = childToId.constFind(logicalIndex);
613 if (id != childToId.constEnd())
614 return QAccessible::accessibleInterface(id.value());
615
616 int vHeader = verticalHeader() ? 1 : 0;
617 int hHeader = horizontalHeader() ? 1 : 0;
618
619 int columns = theModel->columnCount(rootIndex) + vHeader;
620
621 int row = logicalIndex / columns;
622 int column = logicalIndex % columns;
623
624 QAccessibleInterface *iface = nullptr;
625
626 if (vHeader) {
627 if (column == 0) {
628 if (hHeader && row == 0) {
629 iface = new QAccessibleTableCornerButton(theView);
630 } else {
631 iface = new QAccessibleTableHeaderCell(theView, row - hHeader, Qt::Vertical);
632 }
633 }
634 --column;
635 }
636 if (!iface && hHeader) {
637 if (row == 0) {
638 iface = new QAccessibleTableHeaderCell(theView, column, Qt::Horizontal);
639 }
640 --row;
641 }
642
643 if (!iface) {
644 QModelIndex index = theModel->index(row, column, rootIndex);
645 if (Q_UNLIKELY(!index.isValid())) {
646 qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column);
647 return nullptr;
648 }
649 iface = new QAccessibleTableCell(theView, index, cellRole());
650 }
651
652 QAccessible::registerAccessibleInterface(iface);
653 childToId.insert(logicalIndex, QAccessible::uniqueId(iface));
654 return iface;
655}
656
657void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t)
658{
659 if (t == QAccessible::SelectionInterface)
660 return static_cast<QAccessibleSelectionInterface*>(this);
661 if (t == QAccessible::TableInterface)
662 return static_cast<QAccessibleTableInterface*>(this);
663 return nullptr;
664}
665
666void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event)
667{
668 // if there is no cache yet, we don't update anything
669 if (childToId.isEmpty())
670 return;
671
672 switch (event->modelChangeType()) {
673 case QAccessibleTableModelChangeEvent::ModelReset:
674 for (QAccessible::Id id : std::as_const(childToId))
675 QAccessible::deleteAccessibleInterface(id);
676 childToId.clear();
677 break;
678
679 // rows are inserted: move every row after that
680 case QAccessibleTableModelChangeEvent::RowsInserted:
681 case QAccessibleTableModelChangeEvent::ColumnsInserted: {
682 int newRows = event->lastRow() - event->firstRow() + 1;
683 int newColumns = event->lastColumn() - event->firstColumn() + 1;
684
685 ChildCache newCache;
686 ChildCache::ConstIterator iter = childToId.constBegin();
687
688 while (iter != childToId.constEnd()) {
689 QAccessible::Id id = iter.value();
690 QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
691 Q_ASSERT(iface);
692 if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted
693 && iface->role() == QAccessible::RowHeader) {
694 QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
695 if (cell->index >= event->firstRow()) {
696 cell->index += newRows;
697 }
698 } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted
699 && iface->role() == QAccessible::ColumnHeader) {
700 QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
701 if (cell->index >= event->firstColumn()) {
702 cell->index += newColumns;
703 }
704 }
705 if (indexOfChild(iface) >= 0) {
706 newCache.insert(indexOfChild(iface), id);
707 } else {
708 // ### This should really not happen,
709 // but it might if the view has a root index set.
710 // This needs to be fixed.
711 QAccessible::deleteAccessibleInterface(id);
712 }
713 ++iter;
714 }
715 childToId = newCache;
716 break;
717 }
718
719 case QAccessibleTableModelChangeEvent::ColumnsRemoved:
720 case QAccessibleTableModelChangeEvent::RowsRemoved: {
721 int deletedColumns = event->lastColumn() - event->firstColumn() + 1;
722 int deletedRows = event->lastRow() - event->firstRow() + 1;
723 ChildCache newCache;
724 ChildCache::ConstIterator iter = childToId.constBegin();
725 while (iter != childToId.constEnd()) {
726 QAccessible::Id id = iter.value();
727 QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
728 Q_ASSERT(iface);
729 if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
730 Q_ASSERT(iface->tableCellInterface());
731 QAccessibleTableCell *cell = static_cast<QAccessibleTableCell*>(iface->tableCellInterface());
732 // Since it is a QPersistentModelIndex, we only need to check if it is valid
733 if (cell->m_index.isValid())
734 newCache.insert(indexOfChild(cell), id);
735 else
736 QAccessible::deleteAccessibleInterface(id);
737 } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved
738 && iface->role() == QAccessible::RowHeader) {
739 QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
740 if (cell->index < event->firstRow()) {
741 newCache.insert(indexOfChild(cell), id);
742 } else if (cell->index > event->lastRow()) {
743 cell->index -= deletedRows;
744 newCache.insert(indexOfChild(cell), id);
745 } else {
746 QAccessible::deleteAccessibleInterface(id);
747 }
748 } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsRemoved
749 && iface->role() == QAccessible::ColumnHeader) {
750 QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
751 if (cell->index < event->firstColumn()) {
752 newCache.insert(indexOfChild(cell), id);
753 } else if (cell->index > event->lastColumn()) {
754 cell->index -= deletedColumns;
755 newCache.insert(indexOfChild(cell), id);
756 } else {
757 QAccessible::deleteAccessibleInterface(id);
758 }
759 }
760 ++iter;
761 }
762 childToId = newCache;
763 break;
764 }
765
766 case QAccessibleTableModelChangeEvent::DataChanged:
767 // nothing to do in this case
768 break;
769 }
770}
771
772#if QT_CONFIG(treeview)
773
774// TREE VIEW
775
776QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const
777{
778 if (!isValid() || !view()->model())
779 return QModelIndex();
780
781 const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
782 if (Q_UNLIKELY(row < 0 || column < 0 || treeView->d_func()->viewItems.size() <= row)) {
783 qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView;
784 return QModelIndex();
785 }
786 QModelIndex modelIndex = treeView->d_func()->viewItems.at(row).index;
787
788 if (modelIndex.isValid() && column > 0) {
789 modelIndex = view()->model()->index(modelIndex.row(), column, modelIndex.parent());
790 }
791 return modelIndex;
792}
793
794QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const
795{
796 const QAbstractItemView *theView = view();
797 const QAbstractItemModel *theModel = theView->model();
798 if (!theModel)
799 return nullptr;
800
801 const QPoint viewportOffset = theView->viewport()->mapTo(view(), QPoint(0, 0));
802 const QPoint indexPosition = theView->mapFromGlobal(QPoint(x, y) - viewportOffset);
803
804 const QModelIndex index = theView->indexAt(indexPosition);
805 if (!index.isValid())
806 return nullptr;
807
808 const QTreeView *treeView = qobject_cast<const QTreeView *>(theView);
809 int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
810 int column = index.column();
811
812 int i = row * theModel->columnCount(theView->rootIndex()) + column;
813 return child(i);
814}
815
816QAccessibleInterface *QAccessibleTree::focusChild() const
817{
818 const QAbstractItemView *theView = view();
819 const QAbstractItemModel *theModel = theView->model();
820 const QModelIndex index = theView->currentIndex();
821 if (!index.isValid())
822 return nullptr;
823
824 const QTreeView *treeView = qobject_cast<const QTreeView *>(theView);
825 const int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
826 const int column = index.column();
827
828 int i = row * theModel->columnCount(theView->rootIndex()) + column;
829 return child(i);
830}
831
832int QAccessibleTree::childCount() const
833{
834 const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
835 Q_ASSERT(treeView);
836 const QAbstractItemModel *theModel = treeView->model();
837 if (!theModel)
838 return 0;
839
840 int hHeader = horizontalHeader() ? 1 : 0;
841 return (treeView->d_func()->viewItems.size() + hHeader)
842 * theModel->columnCount(treeView->rootIndex());
843}
844
845QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
846{
847 const QAbstractItemView *theView = view();
848 const QAbstractItemModel *theModel = theView->model();
849 const QModelIndex rootIndex = theView->rootIndex();
850 if (logicalIndex < 0 || !theModel || !theModel->columnCount(rootIndex))
851 return nullptr;
852
853 QAccessibleInterface *iface = nullptr;
854 int index = logicalIndex;
855
856 if (horizontalHeader()) {
857 if (index < theModel->columnCount(rootIndex))
858 iface = new QAccessibleTableHeaderCell(view(), index, Qt::Horizontal);
859 else
860 index -= theModel->columnCount(rootIndex);
861 }
862
863 if (!iface) {
864 const int row = index / theModel->columnCount(rootIndex);
865 const int column = index % theModel->columnCount(rootIndex);
866 const QModelIndex modelIndex = indexFromLogical(row, column);
867 if (!modelIndex.isValid())
868 return nullptr;
869 iface = new QAccessibleTableCell(view(), modelIndex, cellRole());
870 }
871 QAccessible::registerAccessibleInterface(iface);
872 // ### FIXME: get interfaces from the cache instead of re-creating them
873 return iface;
874}
875
876int QAccessibleTree::rowCount() const
877{
878 const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
879 Q_ASSERT(treeView);
880 return treeView->d_func()->viewItems.size();
881}
882
883int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const
884{
885 const QAbstractItemView *theView = view();
886 const QAbstractItemModel *theModel = theView->model();
887 if (!theModel)
888 return -1;
889 QAccessibleInterface *parent = iface->parent();
890 if (parent->object() != view())
891 return -1;
892
893 if (iface->role() == QAccessible::TreeItem) {
894 const QAccessibleTableCell* cell = static_cast<const QAccessibleTableCell*>(iface);
895 const QTreeView *treeView = qobject_cast<const QTreeView *>(theView);
896 Q_ASSERT(treeView);
897 int row = treeView->d_func()->viewIndex(cell->m_index) + (horizontalHeader() ? 1 : 0);
898 int column = cell->m_index.column();
899
900 int index = row * theModel->columnCount(theView->rootIndex()) + column;
901 return index;
902 } else if (iface->role() == QAccessible::ColumnHeader){
903 const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface);
904 return cell->index;
905 } else {
906 qWarning() << "WARNING QAccessibleTable::indexOfChild invalid child"
907 << iface->role() << iface->text(QAccessible::Name);
908 }
909 // FIXME: add scrollbars and don't just ignore them
910 return -1;
911}
912
913QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
914{
915 QModelIndex index = indexFromLogical(row, column);
916 if (Q_UNLIKELY(!index.isValid())) {
917 qWarning("Requested invalid tree cell: %d %d", row, column);
918 return nullptr;
919 }
920 const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
921 Q_ASSERT(treeView);
922 int logicalIndex = treeView->d_func()->accessibleTable2Index(index);
923
924 return child(logicalIndex); // FIXME ### new QAccessibleTableCell(view(), index, cellRole());
925}
926
927QString QAccessibleTree::rowDescription(int) const
928{
929 return QString(); // no headers for rows in trees
930}
931
932bool QAccessibleTree::isRowSelected(int row) const
933{
934 if (!view()->selectionModel())
935 return false;
936 QModelIndex index = indexFromLogical(row);
937 return view()->selectionModel()->isRowSelected(index.row(), index.parent());
938}
939
940bool QAccessibleTree::selectRow(int row)
941{
942 if (!view()->selectionModel())
943 return false;
944 QModelIndex index = indexFromLogical(row);
945
946 if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns)
947 return false;
948
949 switch (view()->selectionMode()) {
951 return false;
953 if ((view()->selectionBehavior() != QAbstractItemView::SelectRows) && (columnCount() > 1))
954 return false;
955 view()->clearSelection();
956 break;
958 if ((!row || !view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex()))
959 && !view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex()))
960 view()->clearSelection();
961 break;
962 default:
963 break;
964 }
965
966 view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
967 return true;
968}
969
970#endif // QT_CONFIG(treeview)
971
972// TABLE CELL
973
974QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_)
975 : /* QAccessibleSimpleEditableTextInterface(this), */ view(view_), m_index(index_), m_role(role_)
976{
977 if (Q_UNLIKELY(!index_.isValid()))
978 qWarning() << "QAccessibleTableCell::QAccessibleTableCell with invalid index: " << index_;
979}
980
981void *QAccessibleTableCell::interface_cast(QAccessible::InterfaceType t)
982{
983 if (t == QAccessible::TableCellInterface)
984 return static_cast<QAccessibleTableCellInterface*>(this);
985 if (t == QAccessible::ActionInterface)
986 return static_cast<QAccessibleActionInterface*>(this);
987 return nullptr;
988}
989
990int QAccessibleTableCell::columnExtent() const { return 1; }
991int QAccessibleTableCell::rowExtent() const { return 1; }
992
993QList<QAccessibleInterface*> QAccessibleTableCell::rowHeaderCells() const
994{
995 QList<QAccessibleInterface*> headerCell;
996 if (verticalHeader()) {
997 // FIXME
998 headerCell.append(new QAccessibleTableHeaderCell(view, m_index.row(), Qt::Vertical));
999 }
1000 return headerCell;
1001}
1002
1003QList<QAccessibleInterface*> QAccessibleTableCell::columnHeaderCells() const
1004{
1005 QList<QAccessibleInterface*> headerCell;
1006 if (horizontalHeader()) {
1007 // FIXME
1008 headerCell.append(new QAccessibleTableHeaderCell(view, m_index.column(), Qt::Horizontal));
1009 }
1010 return headerCell;
1011}
1012
1013QHeaderView *QAccessibleTableCell::horizontalHeader() const
1014{
1015 QHeaderView *header = nullptr;
1016
1017 if (false) {
1018#if QT_CONFIG(tableview)
1019 } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
1020 header = tv->horizontalHeader();
1021#endif
1022#if QT_CONFIG(treeview)
1023 } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
1024 header = tv->header();
1025#endif
1026 }
1027
1028 return header;
1029}
1030
1031QHeaderView *QAccessibleTableCell::verticalHeader() const
1032{
1033 QHeaderView *header = nullptr;
1034#if QT_CONFIG(tableview)
1035 if (const QTableView *tv = qobject_cast<const QTableView*>(view))
1036 header = tv->verticalHeader();
1037#endif
1038 return header;
1039}
1040
1041int QAccessibleTableCell::columnIndex() const
1042{
1043 if (!isValid())
1044 return -1;
1045 return m_index.column();
1046}
1047
1048int QAccessibleTableCell::rowIndex() const
1049{
1050 if (!isValid())
1051 return -1;
1052#if QT_CONFIG(treeview)
1053 if (role() == QAccessible::TreeItem) {
1054 const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
1055 Q_ASSERT(treeView);
1056 int row = treeView->d_func()->viewIndex(m_index);
1057 return row;
1058 }
1059#endif
1060 return m_index.row();
1061}
1062
1063bool QAccessibleTableCell::isSelected() const
1064{
1065 if (!isValid())
1066 return false;
1067 return view->selectionModel()->isSelected(m_index);
1068}
1069
1070QStringList QAccessibleTableCell::actionNames() const
1071{
1073 names << toggleAction();
1074 return names;
1075}
1076
1077void QAccessibleTableCell::doAction(const QString& actionName)
1078{
1079 if (actionName == toggleAction()) {
1080#if defined(Q_OS_ANDROID)
1081 QAccessibleInterface *parentInterface = parent();
1082 while (parentInterface){
1083 if (parentInterface->role() == QAccessible::ComboBox) {
1084 selectCell();
1085 parentInterface->actionInterface()->doAction(pressAction());
1086 return;
1087 } else {
1088 parentInterface = parentInterface->parent();
1089 }
1090 }
1091#endif
1092 if (isSelected()) {
1093 unselectCell();
1094 } else {
1095 selectCell();
1096 }
1097 }
1098}
1099
1100QStringList QAccessibleTableCell::keyBindingsForAction(const QString &) const
1101{
1102 return QStringList();
1103}
1104
1105
1106void QAccessibleTableCell::selectCell()
1107{
1108 if (!isValid())
1109 return;
1110 QAbstractItemView::SelectionMode selectionMode = view->selectionMode();
1111 if (selectionMode == QAbstractItemView::NoSelection)
1112 return;
1113 Q_ASSERT(table());
1114 QAccessibleTableInterface *cellTable = table()->tableInterface();
1115
1116 switch (view->selectionBehavior()) {
1118 break;
1120 if (cellTable)
1121 cellTable->selectColumn(m_index.column());
1122 return;
1124 if (cellTable)
1125 cellTable->selectRow(m_index.row());
1126 return;
1127 }
1128
1129 if (selectionMode == QAbstractItemView::SingleSelection) {
1130 view->clearSelection();
1131 }
1132
1133 view->selectionModel()->select(m_index, QItemSelectionModel::Select);
1134}
1135
1136void QAccessibleTableCell::unselectCell()
1137{
1138 if (!isValid())
1139 return;
1140 QAbstractItemView::SelectionMode selectionMode = view->selectionMode();
1141 if (selectionMode == QAbstractItemView::NoSelection)
1142 return;
1143
1144 QAccessibleTableInterface *cellTable = table()->tableInterface();
1145
1146 switch (view->selectionBehavior()) {
1148 break;
1150 if (cellTable)
1151 cellTable->unselectColumn(m_index.column());
1152 return;
1154 if (cellTable)
1155 cellTable->unselectRow(m_index.row());
1156 return;
1157 }
1158
1159 //If the mode is not MultiSelection or ExtendedSelection and only
1160 //one cell is selected it cannot be unselected by the user
1161 if ((selectionMode != QAbstractItemView::MultiSelection)
1162 && (selectionMode != QAbstractItemView::ExtendedSelection)
1163 && (view->selectionModel()->selectedIndexes().size() <= 1))
1164 return;
1165
1166 view->selectionModel()->select(m_index, QItemSelectionModel::Deselect);
1167}
1168
1169QAccessibleInterface *QAccessibleTableCell::table() const
1170{
1171 return QAccessible::queryAccessibleInterface(view);
1172}
1173
1174QAccessible::Role QAccessibleTableCell::role() const
1175{
1176 return m_role;
1177}
1178
1179QAccessible::State QAccessibleTableCell::state() const
1180{
1182 if (!isValid())
1183 return st;
1184
1185 QRect globalRect = view->rect();
1186 globalRect.translate(view->mapToGlobal(QPoint(0,0)));
1187 if (!globalRect.intersects(rect()))
1188 st.invisible = true;
1189
1190 if (view->selectionModel()->isSelected(m_index))
1191 st.selected = true;
1192 if (view->selectionModel()->currentIndex() == m_index)
1193 st.focused = true;
1194
1195 QVariant checkState = m_index.model()->data(m_index, Qt::CheckStateRole);
1196 if (checkState.toInt() == Qt::Checked)
1197 st.checked = true;
1198
1199 Qt::ItemFlags flags = m_index.flags();
1201 st.checkable = true;
1203 st.selectable = true;
1204 st.focusable = true;
1205 if (view->selectionMode() == QAbstractItemView::MultiSelection)
1206 st.multiSelectable = true;
1207 if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
1208 st.extSelectable = true;
1209 }
1210#if QT_CONFIG(treeview)
1211 if (m_role == QAccessible::TreeItem) {
1212 const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
1213 if (treeView->model()->hasChildren(m_index))
1214 st.expandable = true;
1215 if (treeView->isExpanded(m_index))
1216 st.expanded = true;
1217 }
1218#endif
1219 return st;
1220}
1221
1222
1223QRect QAccessibleTableCell::rect() const
1224{
1225 QRect r;
1226 if (!isValid())
1227 return r;
1228 r = view->visualRect(m_index);
1229
1230 if (!r.isNull()) {
1231 r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
1232 r.translate(view->mapToGlobal(QPoint(0, 0)));
1233 }
1234 return r;
1235}
1236
1237QString QAccessibleTableCell::text(QAccessible::Text t) const
1238{
1239 QString value;
1240 if (!isValid())
1241 return value;
1242 QAbstractItemModel *model = view->model();
1243 switch (t) {
1244 case QAccessible::Name:
1246 if (value.isEmpty())
1247 value = model->data(m_index, Qt::DisplayRole).toString();
1248 break;
1249 case QAccessible::Description:
1251 break;
1252 default:
1253 break;
1254 }
1255 return value;
1256}
1257
1258void QAccessibleTableCell::setText(QAccessible::Text /*t*/, const QString &text)
1259{
1260 if (!isValid() || !(m_index.flags() & Qt::ItemIsEditable))
1261 return;
1262 view->model()->setData(m_index, text);
1263}
1264
1265bool QAccessibleTableCell::isValid() const
1266{
1267 return view && !qt_widget_private(view)->data.in_destructor
1268 && view->model() && m_index.isValid();
1269}
1270
1271QAccessibleInterface *QAccessibleTableCell::parent() const
1272{
1273 return QAccessible::queryAccessibleInterface(view);
1274}
1275
1276QAccessibleInterface *QAccessibleTableCell::child(int) const
1277{
1278 return nullptr;
1279}
1280
1281QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_)
1282 : view(view_), index(index_), orientation(orientation_)
1283{
1284 Q_ASSERT(index_ >= 0);
1285}
1286
1287QAccessible::Role QAccessibleTableHeaderCell::role() const
1288{
1289 if (orientation == Qt::Horizontal)
1290 return QAccessible::ColumnHeader;
1291 return QAccessible::RowHeader;
1292}
1293
1294QAccessible::State QAccessibleTableHeaderCell::state() const
1295{
1297 if (QHeaderView *h = headerView()) {
1298 s.invisible = !h->testAttribute(Qt::WA_WState_Visible);
1299 s.disabled = !h->isEnabled();
1300 }
1301 return s;
1302}
1303
1304QRect QAccessibleTableHeaderCell::rect() const
1305{
1306 QHeaderView *header = nullptr;
1307 if (false) {
1308#if QT_CONFIG(tableview)
1309 } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
1310 if (orientation == Qt::Horizontal) {
1311 header = tv->horizontalHeader();
1312 } else {
1313 header = tv->verticalHeader();
1314 }
1315#endif
1316#if QT_CONFIG(treeview)
1317 } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
1318 header = tv->header();
1319#endif
1320 }
1321 if (!header)
1322 return QRect();
1323 QPoint zero = header->mapToGlobal(QPoint(0, 0));
1324 int sectionSize = header->sectionSize(index);
1325 int sectionPos = header->sectionPosition(index);
1326 return orientation == Qt::Horizontal
1327 ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height())
1328 : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize);
1329}
1330
1331QString QAccessibleTableHeaderCell::text(QAccessible::Text t) const
1332{
1333 QAbstractItemModel *model = view->model();
1334 QString value;
1335 switch (t) {
1336 case QAccessible::Name:
1338 if (value.isEmpty())
1339 value = model->headerData(index, orientation, Qt::DisplayRole).toString();
1340 break;
1341 case QAccessible::Description:
1343 break;
1344 default:
1345 break;
1346 }
1347 return value;
1348}
1349
1350void QAccessibleTableHeaderCell::setText(QAccessible::Text, const QString &)
1351{
1352 return;
1353}
1354
1355bool QAccessibleTableHeaderCell::isValid() const
1356{
1357 const QAbstractItemModel *theModel = view && !qt_widget_private(view)->data.in_destructor
1358 ? view->model() : nullptr;
1359 if (!theModel)
1360 return false;
1361 const QModelIndex rootIndex = view->rootIndex();
1362 return (index >= 0) && ((orientation == Qt::Horizontal)
1363 ? (index < theModel->columnCount(rootIndex))
1364 : (index < theModel->rowCount(rootIndex)));
1365}
1366
1367QAccessibleInterface *QAccessibleTableHeaderCell::parent() const
1368{
1369 return QAccessible::queryAccessibleInterface(view);
1370}
1371
1372QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const
1373{
1374 return nullptr;
1375}
1376
1377QHeaderView *QAccessibleTableHeaderCell::headerView() const
1378{
1379 QHeaderView *header = nullptr;
1380 if (false) {
1381#if QT_CONFIG(tableview)
1382 } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
1383 if (orientation == Qt::Horizontal) {
1384 header = tv->horizontalHeader();
1385 } else {
1386 header = tv->verticalHeader();
1387 }
1388#endif
1389#if QT_CONFIG(treeview)
1390 } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
1391 header = tv->header();
1392#endif
1393 }
1394 return header;
1395}
1396
1398
1399#endif // QT_CONFIG(accessibility)
virtual Q_INVOKABLE bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns {true} if parent has any children; otherwise returns {false}.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
virtual Q_INVOKABLE int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
The QAbstractItemView class provides the basic functionality for item view classes.
SelectionMode
This enum indicates how the view responds to user selections:
QAbstractItemModel * model() const
Returns the model that this view is presenting.
QModelIndex rootIndex() const
Returns the model index of the model's root item.
\inmodule QtGui
The QAccessible class provides enums and static functions related to accessibility.
The QHeaderView class provides a header row or header column for item views.
Definition qheaderview.h:18
\inmodule QtCore
qsizetype size() const noexcept
Definition qlist.h:397
\inmodule QtCore
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the header data for the given role in the section of the header with the specified orientatio...
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTableView class provides a default model/view implementation of a table view.
Definition qtableview.h:18
The QTreeView class provides a default model/view implementation of a tree view.
Definition qtreeview.h:20
bool isExpanded(const QModelIndex &index) const
Returns true if the model item index is expanded; otherwise returns false.
\inmodule QtCore
Definition qvariant.h:65
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QString text
list append(new Employee("Blackpool", "Stephen"))
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
constexpr QBindableInterface iface
Definition qproperty.h:666
@ Checked
@ WA_WState_Visible
Definition qnamespace.h:296
@ NoFocus
Definition qnamespace.h:107
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ AccessibleDescriptionRole
@ AccessibleTextRole
@ CheckStateRole
@ DisplayRole
@ WindowSystemMenuHint
Definition qnamespace.h:227
@ ItemIsEditable
@ ItemIsUserCheckable
@ ItemIsSelectable
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define Q_FALLTHROUGH()
#define Q_UNLIKELY(x)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
#define qApp
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLuint index
[2]
GLboolean r
[2]
GLenum GLuint id
[7]
GLint GLsizei width
GLbitfield flags
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLsizei void GLsizei void * column
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLuint * names
GLdouble GLdouble t
Definition qopenglext.h:243
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void * table
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define zero
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
const char className[16]
[1]
Definition qwizard.cpp:100
QSqlQueryModel * model
[16]
obj metaObject() -> className()
edit isVisible()
QItemSelection * selection
[0]
QLayoutItem * child
[0]
QQuickView * view
[0]