]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/kitemlistviewaccessible.h
Merge remote-tracking branch 'origin/KDE/4.9'
[dolphin.git] / src / kitemviews / kitemlistviewaccessible.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Amandeep Singh <aman.dedman@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KITEMLISTVIEWACCESSIBLE_H
21 #define KITEMLISTVIEWACCESSIBLE_H
22
23 #ifndef QT_NO_ACCESSIBILITY
24
25 #include <QtCore/qpointer.h>
26 #include <QtGui/qaccessible.h>
27 #include <QtGui/qaccessible2.h>
28 #include <QtGui/qaccessiblewidget.h>
29 #include <QtGui/qaccessibleobject.h>
30
31 class KItemListView;
32 class KItemListContainer;
33
34 class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
35 {
36 Q_ACCESSIBLE_OBJECT
37
38 public:
39 explicit KItemListViewAccessible(KItemListView* view);
40
41 Role role(int child) const;
42 State state(int child) const;
43 QString text(Text t, int child) const;
44 QRect rect(int child) const;
45
46 int childAt(int x, int y) const;
47 int childCount() const;
48 int indexOfChild(const QAccessibleInterface*) const;
49
50 int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
51 Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
52
53 #ifndef QT_NO_ACTION
54 int userActionCount(int child) const;
55 QString actionText(int action, Text t, int child) const;
56 bool doAction(int action, int child, const QVariantList& params);
57 #endif
58 QVariant invokeMethodEx(Method, int, const QVariantList&);
59
60 // Table2 interface
61 virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const;
62 virtual QAccessibleInterface* caption() const;
63 virtual QAccessibleInterface* summary() const;
64 virtual QString columnDescription(int column) const;
65 virtual QString rowDescription(int row) const;
66 virtual int columnCount() const;
67 virtual int rowCount() const;
68 virtual QAccessible2::TableModelChange modelChange() const;
69 virtual void rowsInserted(const QModelIndex&, int, int) {}
70 virtual void rowsRemoved(const QModelIndex&, int, int) {}
71 virtual void columnsInserted(const QModelIndex&, int, int) {}
72 virtual void columnsRemoved(const QModelIndex&, int, int) {}
73 virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
74 virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
75
76 // Selection
77 virtual int selectedCellCount() const;
78 virtual int selectedColumnCount() const;
79 virtual int selectedRowCount() const;
80 virtual QList<QAccessibleTable2CellInterface*> selectedCells() const;
81 virtual QList<int> selectedColumns() const;
82 virtual QList<int> selectedRows() const;
83 virtual bool isColumnSelected(int column) const;
84 virtual bool isRowSelected(int row) const;
85 virtual bool selectRow(int row);
86 virtual bool selectColumn(int column);
87 virtual bool unselectRow(int row);
88 virtual bool unselectColumn(int column);
89
90 KItemListView* view() const;
91
92 protected:
93 virtual void modelReset();
94 /**
95 * Create an QAccessibleTable2CellInterface representing the table
96 * cell at the @index. Index is 0-based.
97 */
98 inline QAccessibleTable2CellInterface* cell(int index) const;
99 inline QAccessible::Role cellRole() const;
100 };
101
102 class KItemListAccessibleCell: public QAccessibleTable2CellInterface
103 {
104 public:
105 KItemListAccessibleCell(KItemListView* view, int m_index);
106
107 QObject* object() const;
108 Role role(int) const;
109 State state(int) const;
110 QRect rect(int) const;
111 bool isValid() const;
112 int childAt(int, int) const;
113 int childCount() const;
114 int indexOfChild(const QAccessibleInterface*) const;
115 QString text(Text t, int child) const;
116 void setText(Text t, int child, const QString& text);
117 int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
118 Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
119 bool isExpandable() const;
120
121 #ifndef QT_NO_ACTION
122 int userActionCount(int child) const;
123 QString actionText(int action, Text t, int child) const;
124 bool doAction(int action, int child, const QVariantList& params);
125 #endif
126
127 // Cell Interface
128 virtual int columnExtent() const;
129 virtual QList<QAccessibleInterface*> columnHeaderCells() const;
130 virtual int columnIndex() const;
131 virtual int rowExtent() const;
132 virtual QList<QAccessibleInterface*> rowHeaderCells() const;
133 virtual int rowIndex() const;
134 virtual bool isSelected() const;
135 virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
136 virtual QAccessibleTable2Interface* table() const;
137
138 inline int index() const;
139
140 private:
141 QPointer<KItemListView> m_view;
142 int m_index;
143 };
144
145 class KItemListContainerAccessible : public QAccessibleWidgetEx
146 {
147 Q_ACCESSIBLE_OBJECT
148
149 public:
150 explicit KItemListContainerAccessible(KItemListContainer* container);
151 virtual ~KItemListContainerAccessible();
152
153 int childCount() const;
154 int indexOfChild(const QAccessibleInterface* child) const;
155 int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
156
157 private:
158 const KItemListContainer* container() const;
159 };
160
161 #endif // QT_NO_ACCESSIBILITY
162
163 #endif