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
37{
38public:
39 explicit QAccessibleTable(QWidget *w);
40 bool isValid() const override;
41
44 QRect rect() const override;
45
46 QAccessibleInterface *childAt(int x, int y) const override;
48 int childCount() const override;
50
53
55
56 // table interface
57 virtual QAccessibleInterface *cellAt(int row, int column) const override;
58 virtual QAccessibleInterface *caption() const override;
59 virtual QAccessibleInterface *summary() const override;
60 virtual QString columnDescription(int column) const override;
61 virtual QString rowDescription(int row) const override;
62 virtual int columnCount() const override;
63 virtual int rowCount() const override;
64
65 // selection
66 virtual int selectedCellCount() const override;
67 virtual int selectedColumnCount() const override;
68 virtual int selectedRowCount() const override;
70 virtual QList<int> selectedColumns() const override;
71 virtual QList<int> selectedRows() const override;
72 virtual bool isColumnSelected(int column) const override;
73 virtual bool isRowSelected(int row) const override;
74 virtual bool selectRow(int row) override;
75 virtual bool selectColumn(int column) override;
76 virtual bool unselectRow(int row) override;
77 virtual bool unselectColumn(int column) override;
78
79 // QAccessibleSelectionInterface
80 virtual int selectedItemCount() const override;
85 virtual bool selectAll() override;
86 virtual bool clear() override;
87
88 QAbstractItemView *view() const;
89
91
92protected:
93 inline QAccessible::Role cellRole() const {
94 switch (m_role) {
95 case QAccessible::List:
96 return QAccessible::ListItem;
97 case QAccessible::Table:
98 return QAccessible::Cell;
99 case QAccessible::Tree:
100 return QAccessible::TreeItem;
101 default:
102 Q_ASSERT(0);
103 }
104 return QAccessible::NoRole;
105 }
106
109
110 // maybe vector
111 typedef QHash<int, QAccessible::Id> ChildCache;
112 mutable ChildCache childToId;
113
114 virtual ~QAccessibleTable();
115
116private:
117 // the child index for a model index
118 inline int logicalIndex(const QModelIndex &index) const;
120};
121
122#if QT_CONFIG(treeview)
124{
125public:
126 explicit QAccessibleTree(QWidget *w)
128 {}
129
130
131 QAccessibleInterface *childAt(int x, int y) const override;
133 int childCount() const override;
135
136 int indexOfChild(const QAccessibleInterface *) const override;
137
138 int rowCount() const override;
139
140 // table interface
143 bool isRowSelected(int row) const override;
144 bool selectRow(int row) override;
145
146private:
147 QModelIndex indexFromLogical(int row, int column = 0) const;
148};
149#endif
150
151#if QT_CONFIG(listview)
153{
154public:
155 explicit QAccessibleList(QWidget *w)
157 {}
158
160
161 // table interface
163
164 // selection
165 int selectedCellCount() const override;
167};
168#endif
169
171{
172public:
174
176 QObject *object() const override { return nullptr; }
177 QAccessible::Role role() const override;
179 QRect rect() const override;
180 bool isValid() const override;
181
182 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
183 int childCount() const override { return 0; }
184 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
185
188
191
192 // cell interface
193 virtual int columnExtent() const override;
195 virtual int columnIndex() const override;
196 virtual int rowExtent() const override;
198 virtual int rowIndex() const override;
199 virtual bool isSelected() const override;
200 virtual QAccessibleInterface* table() const override;
201
202 //action interface
203 virtual QStringList actionNames() const override;
204 virtual void doAction(const QString &actionName) override;
206
207private:
213
214 void selectCell();
215 void unselectCell();
216
217friend class QAccessibleTable;
218#if QT_CONFIG(treeview)
219friend class QAccessibleTree;
220#endif
221#if QT_CONFIG(listview)
222friend class QAccessibleList;
223#endif
224};
225
226
228{
229public:
230 // For header cells, pass the header view in addition
232
233 QObject *object() const override { return nullptr; }
234 QAccessible::Role role() const override;
236 QRect rect() const override;
237 bool isValid() const override;
238
239 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
240 int childCount() const override { return 0; }
241 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
242
245
248
249private:
250 QHeaderView *headerView() const;
251
253 int index;
255
256friend class QAccessibleTable;
257#if QT_CONFIG(treeview)
258friend class QAccessibleTree;
259#endif
260#if QT_CONFIG(listview)
261friend class QAccessibleList;
262#endif
263};
264
265// This is the corner button on the top left of a table.
266// It can be used to select all cells or it is not active at all.
267// For now it is ignored.
269{
270public:
272 :view(view_)
273 {}
274
275 QObject *object() const override { return nullptr; }
276 QAccessible::Role role() const override { return QAccessible::Pane; }
277 QAccessible::State state() const override { return QAccessible::State(); }
278 QRect rect() const override { return QRect(); }
279 bool isValid() const override { return true; }
280
281 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
282 int childCount() const override { return 0; }
283 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
284
285 QString text(QAccessible::Text) const override { return QString(); }
286 void setText(QAccessible::Text, const QString &) override {}
287
290 }
292 return nullptr;
293 }
294
295private:
297};
298
299
300#endif // QT_CONFIG(accessibility)
301
303
304#endif // ACCESSIBLE_ITEMVIEWS_H
\inmodule QtSql
QT_REQUIRE_CONFIG(itemviews)