blob: 4c44b18adccc60dbb595a59fb73d1868b907ab3e (
plain)
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
|
/*
* SPDX-FileCopyrightText: 2012 Amandeep Singh <[email protected]>
* SPDX-FileCopyrightText: 2024 Felix Ernst <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KITEMLISTVIEWACCESSIBLE_H
#define KITEMLISTVIEWACCESSIBLE_H
#include "dolphin_export.h"
#include <QAccessible>
#include <QAccessibleObject>
#include <QAccessibleWidget>
#include <QPointer>
class KItemListView;
class KItemListContainer;
class KItemListContainerAccessible;
class KItemListSelectionManager;
/**
* The main class for making the main view accessible.
*
* Such a class is necessary because the KItemListView is a mostly custom entity. This class provides a lot of the functionality to make it possible to
* interact with the view using accessibility tools. It implements various interfaces mostly to generally allow working with the view as a whole. However,
* actually interacting with singular items within the view is implemented in KItemListDelegateAccessible.
*
* @note For documentation of most of the methods within this class, check out the documentation of the methods which are being overriden here.
*/
class DOLPHIN_EXPORT KItemListViewAccessible : public QAccessibleObject,
public QAccessibleSelectionInterface,
public QAccessibleTableInterface,
public QAccessibleActionInterface
{
public:
explicit KItemListViewAccessible(KItemListView *view, KItemListContainerAccessible *parent);
~KItemListViewAccessible() override;
// QAccessibleObject
void *interface_cast(QAccessible::InterfaceType type) override;
QAccessible::Role role() const override;
QAccessible::State state() const override;
QString text(QAccessible::Text t) const override;
QRect rect() const override;
QAccessibleInterface *child(int index) const override;
int childCount() const override;
int indexOfChild(const QAccessibleInterface *) const override;
QAccessibleInterface *childAt(int x, int y) const override;
QAccessibleInterface *parent() const 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;
void modelChange(QAccessibleTableModelChangeEvent *) override;
// Selection interface
/** Clear selection */
bool clear() override;
bool isSelected(QAccessibleInterface *childItem) const override;
bool select(QAccessibleInterface *childItem) override;
bool selectAll() override;
QAccessibleInterface *selectedItem(int selectionIndex) const override;
int selectedItemCount() const override;
QList<QAccessibleInterface *> selectedItems() const override;
bool unselect(QAccessibleInterface *childItem) override;
// Action interface
QStringList actionNames() const override;
void doAction(const QString &actionName) override;
QStringList keyBindingsForAction(const QString &actionName) const override;
// Custom non-interface methods
KItemListView *view() const;
/**
* Moves the focus to the list view itself so an overview over the state can be given.
* @param placeholderMessage the message that should be announced when no items are visible (yet). This message is mostly identical to
* DolphinView::m_placeholderLabel in both content and purpose. @see DolphinView::updatePlaceHolderLabel().
*/
void announceOverallViewState(const QString &placeholderMessage);
/**
* Announces that the description of the view has changed. The changed description will only be announced if the view has focus (from an accessibility
* point of view). This method ensures that multiple calls to this method within a small time frame will only lead to a singular announcement instead of
* multiple or already outdated ones, so calling this method instead of manually sending accessibility events for this view is preferred.
*/
void announceDescriptionChange();
protected:
virtual void modelReset();
/**
* @returns a KItemListDelegateAccessible representing the file or folder at the @index. Returns nullptr for invalid indices.
* If a KItemListDelegateAccessible for an index does not yet exist, it will be created.
* Index is 0-based.
*/
inline QAccessibleInterface *accessibleDelegate(int index) const;
KItemListSelectionManager *selectionManager() const;
private:
/** @see setPlaceholderMessage(). */
QString m_placeholderMessage;
QTimer *m_announceDescriptionChangeTimer;
class AccessibleIdWrapper
{
public:
AccessibleIdWrapper();
bool isValid;
QAccessible::Id id;
};
/**
* A list that maps the indices of the children of this KItemListViewAccessible to the accessible ids of the matching KItemListDelegateAccessible objects.
* For example: m_accessibleDelegates.at(2) would be the AccessibleIdWrapper with an id which can be used to retrieve the QAccessibleObject that represents
* the third file in this view.
*/
mutable QVector<AccessibleIdWrapper> m_accessibleDelegates;
KItemListContainerAccessible *m_parent;
};
#endif
|