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
169{
170public:
172
174 QObject *object() const override { return nullptr; }
175 QAccessible::Role role() const override;
177 QRect rect() const override;
178 bool isValid() const override;
179
180 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
181 int childCount() const override { return 0; }
182 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
183
186
189
190 // cell interface
191 virtual int columnExtent() const override;
193 virtual int columnIndex() const override;
194 virtual int rowExtent() const override;
196 virtual int rowIndex() const override;
197 virtual bool isSelected() const override;
198 virtual QAccessibleInterface* table() const override;
199
200 //action interface
201 virtual QStringList actionNames() const override;
202 virtual void doAction(const QString &actionName) override;
204
205 // attributes interface
208
209private:
215
216 void selectCell();
217 void unselectCell();
218
219friend class QAccessibleTable;
220#if QT_CONFIG(treeview)
221friend class QAccessibleTree;
222#endif
223#if QT_CONFIG(listview)
224friend class QAccessibleList;
225#endif
226};
227
228
230{
231public:
232 // For header cells, pass the header view in addition
234
235 QObject *object() const override { return nullptr; }
236 QAccessible::Role role() const override;
238 QRect rect() const override;
239 bool isValid() const override;
240
241 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
242 int childCount() const override { return 0; }
243 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
244
247
250
251private:
252 QHeaderView *headerView() const;
253
255 int index;
257
258friend class QAccessibleTable;
259#if QT_CONFIG(treeview)
260friend class QAccessibleTree;
261#endif
262#if QT_CONFIG(listview)
263friend class QAccessibleList;
264#endif
265};
266
267// This is the corner button on the top left of a table.
268// It can be used to select all cells or it is not active at all.
269// For now it is ignored.
271{
272public:
274 :view(view_)
275 {}
276
277 QObject *object() const override { return nullptr; }
278 QAccessible::Role role() const override { return QAccessible::Pane; }
279 QAccessible::State state() const override { return QAccessible::State(); }
280 QRect rect() const override { return QRect(); }
281 bool isValid() const override { return true; }
282
283 QAccessibleInterface *childAt(int, int) const override { return nullptr; }
284 int childCount() const override { return 0; }
285 int indexOfChild(const QAccessibleInterface *) const override { return -1; }
286
287 QString text(QAccessible::Text) const override { return QString(); }
288 void setText(QAccessible::Text, const QString &) override {}
289
292 }
294 return nullptr;
295 }
296
297private:
299};
300
301
302#endif // QT_CONFIG(accessibility)
303
305
306#endif // ACCESSIBLE_ITEMVIEWS_H
\inmodule QtSql
QT_REQUIRE_CONFIG(itemviews)