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// Qt-Security score:significant reason:default
4
5#ifndef ACCESSIBLE_ITEMVIEWS_H
6#define ACCESSIBLE_ITEMVIEWS_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "QtCore/qpointer.h"
21#include <QtGui/qaccessible.h>
22#include <QtWidgets/qaccessiblewidget.h>
23#include <QtWidgets/qabstractitemview.h>
24#include <QtWidgets/qheaderview.h>
25
27
29
30#if QT_CONFIG(accessibility)
31
34
38{
39public:
41
42 QAccessibleInterface *childAt(int x, int y) const override;
44 int childCount() const override;
46
49
51
52 // table interface
53 virtual QAccessibleInterface *cellAt(int row, int column) const override;
54 virtual QAccessibleInterface *caption() const override;
55 virtual QAccessibleInterface *summary() const override;
56 virtual QString columnDescription(int column) const override;
57 virtual QString rowDescription(int row) const override;
58 virtual int columnCount() const override;
59 virtual int rowCount() const override;
60
61 // selection
62 virtual int selectedCellCount() const override;
63 virtual int selectedColumnCount() const override;
64 virtual int selectedRowCount() const override;
66 virtual QList<int> selectedColumns() const override;
67 virtual QList<int> selectedRows() const override;
68 virtual bool isColumnSelected(int column) const override;
69 virtual bool isRowSelected(int row) const override;
70 virtual bool selectRow(int row) override;
71 virtual bool selectColumn(int column) override;
72 virtual bool unselectRow(int row) override;
73 virtual bool unselectColumn(int column) override;
74
75 // QAccessibleSelectionInterface
76 virtual int selectedItemCount() const override;
81 virtual bool selectAll() override;
82 virtual bool clear() override;
83
84 QAbstractItemView *view() const;
85
87
88protected:
89 inline QAccessible::Role cellRole() const {
90 switch (role()) {
91 case QAccessible::List:
92 return QAccessible::ListItem;
93 case QAccessible::Table:
94 return QAccessible::Cell;
95 case QAccessible::Tree:
96 return QAccessible::TreeItem;
97 default:
98 Q_ASSERT(0);
99 }
100 return QAccessible::NoRole;
101 }
102
105
106 // maybe vector
107 typedef QHash<int, QAccessible::Id> ChildCache;
108 mutable ChildCache childToId;
109
110 virtual ~QAccessibleTable();
111
112private:
113 // the child index for a model index
114 inline int logicalIndex(const QModelIndex &index) const;
115};
116
117#if QT_CONFIG(treeview)
119{
120public:
121 explicit QAccessibleTree(QWidget *w)
123 {}
124
125
126 QAccessibleInterface *childAt(int x, int y) const override;
128 int childCount() const override;
130
131 int indexOfChild(const QAccessibleInterface *) const override;
132
133 int rowCount() const override;
134
135 // table interface
138 bool isRowSelected(int row) const override;
139 bool selectRow(int row) override;
140
141private:
142 QModelIndex indexFromLogical(int row, int column = 0) const;
143};
144#endif
145
146#if QT_CONFIG(listview)
148{
149public:
150 explicit QAccessibleList(QWidget *w)
152 {}
153
155
156 // table interface
158
159 // selection
160 int selectedCellCount() const override;
162};
163#endif
164
166{
167public:
169
171 QObject *object() const override { return nullptr; }
172 QAccessible::Role role() const override;
174 QRect rect() const override;
175 bool isValid() const override;
176
177 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
178 int childCount() const override { return 0; }
179 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
180
183
186
187 // cell interface
188 virtual int columnExtent() const override;
190 virtual int columnIndex() const override;
191 virtual int rowExtent() const override;
193 virtual int rowIndex() const override;
194 virtual bool isSelected() const override;
195 virtual QAccessibleInterface* table() const override;
196
197 //action interface
198 virtual QStringList actionNames() const override;
199 virtual void doAction(const QString &actionName) override;
201
202private:
208
209 void selectCell();
210 void unselectCell();
211
212friend class QAccessibleTable;
213#if QT_CONFIG(treeview)
214friend class QAccessibleTree;
215#endif
216#if QT_CONFIG(listview)
217friend class QAccessibleList;
218#endif
219};
220
221
223{
224public:
225 // For header cells, pass the header view in addition
227
228 QObject *object() const override { return nullptr; }
229 QAccessible::Role role() const override;
231 QRect rect() const override;
232 bool isValid() const override;
233
234 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
235 int childCount() const override { return 0; }
236 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
237
240
243
244private:
245 QHeaderView *headerView() const;
246
248 int index;
250
251friend class QAccessibleTable;
252#if QT_CONFIG(treeview)
253friend class QAccessibleTree;
254#endif
255#if QT_CONFIG(listview)
256friend class QAccessibleList;
257#endif
258};
259
260// This is the corner button on the top left of a table.
261// It can be used to select all cells or it is not active at all.
262// For now it is ignored.
264{
265public:
267 :view(view_)
268 {}
269
270 QObject *object() const override { return nullptr; }
271 QAccessible::Role role() const override { return QAccessible::Pane; }
272 QAccessible::State state() const override { return QAccessible::State(); }
273 QRect rect() const override { return QRect(); }
274 bool isValid() const override { return true; }
275
276 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
277 int childCount() const override { return 0; }
278 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
279
280 QString text(QAccessible::Text) const override { return QString(); }
281 void setText(QAccessible::Text, const QString &) override {}
282
285 }
287 return nullptr;
288 }
289
290private:
292};
293
294
295#endif // QT_CONFIG(accessibility)
296
298
299#endif // ACCESSIBLE_ITEMVIEWS_H
\inmodule QtSql
QT_REQUIRE_CONFIG(itemviews)