1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/* SPDX-FileCopyrightText: 2026 Project Tick
* SPDX-FileContributor: Project Tick
* SPDX-License-Identifier: GPL-3.0-or-later
*
* MeshMC - A Custom Launcher for Minecraft
* Copyright (C) 2026 Project Tick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "QtCore/qpointer.h"
#include <QtGui/qaccessible.h>
#include <QAccessibleWidget>
#include <QAbstractItemView>
#ifndef QT_NO_ACCESSIBILITY
#include "InstanceView.h"
// #include <QHeaderView>
class QAccessibleTableCell;
class QAccessibleTableHeaderCell;
class AccessibleInstanceView : public QAccessibleTableInterface,
public QAccessibleObject
{
public:
explicit AccessibleInstanceView(QWidget* w);
bool isValid() const override;
QAccessible::Role role() const override;
QAccessible::State state() const override;
QString text(QAccessible::Text t) const override;
QRect rect() const override;
QAccessibleInterface* childAt(int x, int y) const override;
int childCount() const override;
int indexOfChild(const QAccessibleInterface*) const override;
QAccessibleInterface* parent() const override;
QAccessibleInterface* child(int index) const override;
void* interface_cast(QAccessible::InterfaceType t) override;
// table interface
QAccessibleInterface* cellAt(int row, int column) const override;
QAccessibleInterface* caption() const override;
QAccessibleInterface* summary() const override;
QString columnDescription(int column) const override;
QString rowDescription(int row) const override;
int columnCount() const override;
int rowCount() const override;
// selection
int selectedCellCount() const override;
int selectedColumnCount() const override;
int selectedRowCount() const override;
QList<QAccessibleInterface*> selectedCells() const override;
QList<int> selectedColumns() const override;
QList<int> selectedRows() const override;
bool isColumnSelected(int column) const override;
bool isRowSelected(int row) const override;
bool selectRow(int row) override;
bool selectColumn(int column) override;
bool unselectRow(int row) override;
bool unselectColumn(int column) override;
QAbstractItemView* view() const;
void modelChange(QAccessibleTableModelChangeEvent* event) override;
protected:
// maybe vector
typedef QHash<int, QAccessible::Id> ChildCache;
mutable ChildCache childToId;
virtual ~AccessibleInstanceView();
private:
inline int logicalIndex(const QModelIndex& index) const;
};
class AccessibleInstanceViewItem : public QAccessibleInterface,
public QAccessibleTableCellInterface,
public QAccessibleActionInterface
{
public:
AccessibleInstanceViewItem(QAbstractItemView* view,
const QModelIndex& m_index);
void* interface_cast(QAccessible::InterfaceType t) override;
QObject* object() const override
{
return nullptr;
}
QAccessible::Role role() const override;
QAccessible::State state() const override;
QRect rect() const override;
bool isValid() const override;
QAccessibleInterface* childAt(int, int) const override
{
return nullptr;
}
int childCount() const override
{
return 0;
}
int indexOfChild(const QAccessibleInterface*) const override
{
return -1;
}
QString text(QAccessible::Text t) const override;
void setText(QAccessible::Text t, const QString& text) override;
QAccessibleInterface* parent() const override;
QAccessibleInterface* child(int) const override;
// cell interface
int columnExtent() const override;
QList<QAccessibleInterface*> columnHeaderCells() const override;
int columnIndex() const override;
int rowExtent() const override;
QList<QAccessibleInterface*> rowHeaderCells() const override;
int rowIndex() const override;
bool isSelected() const override;
QAccessibleInterface* table() const override;
// action interface
QStringList actionNames() const override;
void doAction(const QString& actionName) override;
QStringList keyBindingsForAction(const QString& actionName) const override;
private:
QPointer<QAbstractItemView> view;
QPersistentModelIndex m_index;
void selectCell();
void unselectCell();
friend class AccessibleInstanceView;
};
#endif /* !QT_NO_ACCESSIBILITY */
|