Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
itemviews_p.h
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#ifndef ACCESSIBLE_ITEMVIEWS_H
5#define ACCESSIBLE_ITEMVIEWS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "QtCore/qpointer.h"
20#include <QtGui/qaccessible.h>
21#include <QtWidgets/qaccessiblewidget.h>
22#include <QtWidgets/qabstractitemview.h>
23#include <QtWidgets/qheaderview.h>
24
26
28
29#if QT_CONFIG(accessibility)
30
33
35{
36public:
37 explicit QAccessibleTable(QWidget *w);
38 bool isValid() const override;
39
43 QRect rect() const override;
44
45 QAccessibleInterface *childAt(int x, int y) const override;
47 int childCount() const override;
49
52
54
55 // table interface
56 virtual QAccessibleInterface *cellAt(int row, int column) const override;
57 virtual QAccessibleInterface *caption() const override;
58 virtual QAccessibleInterface *summary() const override;
59 virtual QString columnDescription(int column) const override;
60 virtual QString rowDescription(int row) const override;
61 virtual int columnCount() const override;
62 virtual int rowCount() const override;
63
64 // selection
65 virtual int selectedCellCount() const override;
66 virtual int selectedColumnCount() const override;
67 virtual int selectedRowCount() const override;
69 virtual QList<int> selectedColumns() const override;
70 virtual QList<int> selectedRows() const override;
71 virtual bool isColumnSelected(int column) const override;
72 virtual bool isRowSelected(int row) const override;
73 virtual bool selectRow(int row) override;
74 virtual bool selectColumn(int column) override;
75 virtual bool unselectRow(int row) override;
76 virtual bool unselectColumn(int column) override;
77
78 // QAccessibleSelectionInterface
79 virtual int selectedItemCount() const override;
84 virtual bool selectAll() override;
85 virtual bool clear() override;
86
87 QAbstractItemView *view() const;
88
90
91protected:
92 inline QAccessible::Role cellRole() const {
93 switch (m_role) {
94 case QAccessible::List:
95 return QAccessible::ListItem;
96 case QAccessible::Table:
97 return QAccessible::Cell;
98 case QAccessible::Tree:
99 return QAccessible::TreeItem;
100 default:
101 Q_ASSERT(0);
102 }
103 return QAccessible::NoRole;
104 }
105
108
109 // maybe vector
110 typedef QHash<int, QAccessible::Id> ChildCache;
111 mutable ChildCache childToId;
112
113 virtual ~QAccessibleTable();
114
115private:
116 // the child index for a model index
117 inline int logicalIndex(const QModelIndex &index) const;
119};
120
121#if QT_CONFIG(treeview)
123{
124public:
125 explicit QAccessibleTree(QWidget *w)
127 {}
128
129
130 QAccessibleInterface *childAt(int x, int y) const override;
132 int childCount() const override;
134
135 int indexOfChild(const QAccessibleInterface *) const override;
136
137 int rowCount() const override;
138
139 // table interface
142 bool isRowSelected(int row) const override;
143 bool selectRow(int row) override;
144
145private:
146 QModelIndex indexFromLogical(int row, int column = 0) const;
147};
148#endif
149
150#if QT_CONFIG(listview)
152{
153public:
154 explicit QAccessibleList(QWidget *w)
156 {}
157
159
160 // table interface
162
163 // selection
164 int selectedCellCount() const override;
166};
167#endif
168
170{
171public:
173
175 QObject *object() const override { return nullptr; }
176 QAccessible::Role role() const override;
178 QRect rect() const override;
179 bool isValid() const override;
180
181 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
182 int childCount() const override { return 0; }
183 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
184
187
190
191 // cell interface
192 virtual int columnExtent() const override;
194 virtual int columnIndex() const override;
195 virtual int rowExtent() const override;
197 virtual int rowIndex() const override;
198 virtual bool isSelected() const override;
199 virtual QAccessibleInterface* table() const override;
200
201 //action interface
202 virtual QStringList actionNames() const override;
203 virtual void doAction(const QString &actionName) override;
205
206private:
212
213 void selectCell();
214 void unselectCell();
215
216friend class QAccessibleTable;
217#if QT_CONFIG(treeview)
218friend class QAccessibleTree;
219#endif
220#if QT_CONFIG(listview)
221friend class QAccessibleList;
222#endif
223};
224
225
227{
228public:
229 // For header cells, pass the header view in addition
231
232 QObject *object() const override { return nullptr; }
233 QAccessible::Role role() const override;
235 QRect rect() const override;
236 bool isValid() const override;
237
238 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
239 int childCount() const override { return 0; }
240 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
241
244
247
248private:
249 QHeaderView *headerView() const;
250
252 int index;
254
255friend class QAccessibleTable;
256#if QT_CONFIG(treeview)
257friend class QAccessibleTree;
258#endif
259#if QT_CONFIG(listview)
260friend class QAccessibleList;
261#endif
262};
263
264// This is the corner button on the top left of a table.
265// It can be used to select all cells or it is not active at all.
266// For now it is ignored.
268{
269public:
271 :view(view_)
272 {}
273
274 QObject *object() const override { return nullptr; }
275 QAccessible::Role role() const override { return QAccessible::Pane; }
276 QAccessible::State state() const override { return QAccessible::State(); }
277 QRect rect() const override { return QRect(); }
278 bool isValid() const override { return true; }
279
280 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
281 int childCount() const override { return 0; }
282 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
283
284 QString text(QAccessible::Text) const override { return QString(); }
285 void setText(QAccessible::Text, const QString &) override {}
286
289 }
291 return nullptr;
292 }
293
294private:
296};
297
298
299#endif // QT_CONFIG(accessibility)
300
302
303#endif // ACCESSIBLE_ITEMVIEWS_H
\inmodule QtSql
QT_REQUIRE_CONFIG(itemviews)