Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/accessible/itemviews.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||
25 | ** | - | ||||||||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||
29 | ** | - | ||||||||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
31 | ** | - | ||||||||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | #include "itemviews_p.h" | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | #include <qheaderview.h> | - | ||||||||||||||||||
37 | #include <qtableview.h> | - | ||||||||||||||||||
38 | #include <qlistview.h> | - | ||||||||||||||||||
39 | #include <qtreeview.h> | - | ||||||||||||||||||
40 | #include <private/qtreewidget_p.h> | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||
47 | /* | - | ||||||||||||||||||
48 | Implementation of the IAccessible2 table2 interface. Much simpler than | - | ||||||||||||||||||
49 | the other table interfaces since there is only the main table and cells: | - | ||||||||||||||||||
50 | - | |||||||||||||||||||
51 | TABLE/LIST/TREE | - | ||||||||||||||||||
52 | |- HEADER CELL | - | ||||||||||||||||||
53 | |- CELL | - | ||||||||||||||||||
54 | |- CELL | - | ||||||||||||||||||
55 | ... | - | ||||||||||||||||||
56 | */ | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | - | |||||||||||||||||||
59 | QAbstractItemView *QAccessibleTable::view() const | - | ||||||||||||||||||
60 | { | - | ||||||||||||||||||
61 | return qobject_cast<QAbstractItemView*>(object()); never executed: return qobject_cast<QAbstractItemView*>(object()); | 0 | ||||||||||||||||||
62 | } | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | int QAccessibleTable::logicalIndex(const QModelIndex &index) const | - | ||||||||||||||||||
65 | { | - | ||||||||||||||||||
66 | if (!view()->model() || !index.isValid())
| 0 | ||||||||||||||||||
67 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
68 | int vHeader = verticalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
69 | int hHeader = horizontalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
70 | return (index.row() + hHeader)*(index.model()->columnCount() + vHeader) + (index.column() + vHeader); never executed: return (index.row() + hHeader)*(index.model()->columnCount() + vHeader) + (index.column() + vHeader); | 0 | ||||||||||||||||||
71 | } | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | QAccessibleTable::QAccessibleTable(QWidget *w) | - | ||||||||||||||||||
74 | : QAccessibleObject(w) | - | ||||||||||||||||||
75 | { | - | ||||||||||||||||||
76 | Q_ASSERT(view()); | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | if (qobject_cast<const QTableView*>(view())) {
| 0 | ||||||||||||||||||
79 | m_role = QAccessible::Table; | - | ||||||||||||||||||
80 | } else if (qobject_cast<const QTreeView*>(view())) { never executed: end of block
| 0 | ||||||||||||||||||
81 | m_role = QAccessible::Tree; | - | ||||||||||||||||||
82 | } else if (qobject_cast<const QListView*>(view())) { never executed: end of block
| 0 | ||||||||||||||||||
83 | m_role = QAccessible::List; | - | ||||||||||||||||||
84 | } else { never executed: end of block | 0 | ||||||||||||||||||
85 | // is this our best guess? | - | ||||||||||||||||||
86 | m_role = QAccessible::Table; | - | ||||||||||||||||||
87 | } never executed: end of block | 0 | ||||||||||||||||||
88 | } | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | bool QAccessibleTable::isValid() const | - | ||||||||||||||||||
91 | { | - | ||||||||||||||||||
92 | return (view() && !qobject_cast<QWidget*>(view())->d_func()->data.in_destructor); never executed: return (view() && !qobject_cast<QWidget*>(view())->d_func()->data.in_destructor);
| 0 | ||||||||||||||||||
93 | } | - | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | QAccessibleTable::~QAccessibleTable() | - | ||||||||||||||||||
96 | { | - | ||||||||||||||||||
97 | Q_FOREACH (QAccessible::Id id, childToId) | - | ||||||||||||||||||
98 | QAccessible::deleteAccessibleInterface(id); never executed: QAccessible::deleteAccessibleInterface(id); | 0 | ||||||||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||||||||
100 | - | |||||||||||||||||||
101 | QHeaderView *QAccessibleTable::horizontalHeader() const | - | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | QHeaderView *header = 0; | - | ||||||||||||||||||
104 | if (false) { dead code: { } | - | ||||||||||||||||||
105 | #ifndef QT_NO_TABLEVIEW dead code: { } | - | ||||||||||||||||||
106 | } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
dead code: { } | - | ||||||||||||||||||
107 | header = tv->horizontalHeader(); | - | ||||||||||||||||||
108 | #endif | - | ||||||||||||||||||
109 | #ifndef QT_NO_TREEVIEW | - | ||||||||||||||||||
110 | } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view())) { never executed: end of block
| 0 | ||||||||||||||||||
111 | header = tv->header(); | - | ||||||||||||||||||
112 | #endif | - | ||||||||||||||||||
113 | } never executed: end of block | 0 | ||||||||||||||||||
114 | return header; never executed: return header; | 0 | ||||||||||||||||||
115 | } | - | ||||||||||||||||||
116 | - | |||||||||||||||||||
117 | QHeaderView *QAccessibleTable::verticalHeader() const | - | ||||||||||||||||||
118 | { | - | ||||||||||||||||||
119 | QHeaderView *header = 0; | - | ||||||||||||||||||
120 | if (false) { dead code: { } | - | ||||||||||||||||||
121 | #ifndef QT_NO_TABLEVIEW dead code: { } | - | ||||||||||||||||||
122 | } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
dead code: { } | - | ||||||||||||||||||
123 | header = tv->verticalHeader(); | - | ||||||||||||||||||
124 | #endif | - | ||||||||||||||||||
125 | } never executed: end of block | 0 | ||||||||||||||||||
126 | return header; never executed: return header; | 0 | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const | - | ||||||||||||||||||
130 | { | - | ||||||||||||||||||
131 | if (!view()->model())
| 0 | ||||||||||||||||||
132 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
133 | Q_ASSERT(role() != QAccessible::Tree); | - | ||||||||||||||||||
134 | QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); | - | ||||||||||||||||||
135 | if (!index.isValid()) {
| 0 | ||||||||||||||||||
136 | qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view(); | - | ||||||||||||||||||
137 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
138 | } | - | ||||||||||||||||||
139 | return child(logicalIndex(index)); never executed: return child(logicalIndex(index)); | 0 | ||||||||||||||||||
140 | } | - | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | QAccessibleInterface *QAccessibleTable::caption() const | - | ||||||||||||||||||
143 | { | - | ||||||||||||||||||
144 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
145 | } | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | QString QAccessibleTable::columnDescription(int column) const | - | ||||||||||||||||||
148 | { | - | ||||||||||||||||||
149 | if (!view()->model())
| 0 | ||||||||||||||||||
150 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
151 | return view()->model()->headerData(column, Qt::Horizontal).toString(); never executed: return view()->model()->headerData(column, Qt::Horizontal).toString(); | 0 | ||||||||||||||||||
152 | } | - | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | int QAccessibleTable::columnCount() const | - | ||||||||||||||||||
155 | { | - | ||||||||||||||||||
156 | if (!view()->model())
| 0 | ||||||||||||||||||
157 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
158 | return view()->model()->columnCount(); never executed: return view()->model()->columnCount(); | 0 | ||||||||||||||||||
159 | } | - | ||||||||||||||||||
160 | - | |||||||||||||||||||
161 | int QAccessibleTable::rowCount() const | - | ||||||||||||||||||
162 | { | - | ||||||||||||||||||
163 | if (!view()->model())
| 0 | ||||||||||||||||||
164 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
165 | return view()->model()->rowCount(); never executed: return view()->model()->rowCount(); | 0 | ||||||||||||||||||
166 | } | - | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | int QAccessibleTable::selectedCellCount() const | - | ||||||||||||||||||
169 | { | - | ||||||||||||||||||
170 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
171 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
172 | return view()->selectionModel()->selectedIndexes().count(); never executed: return view()->selectionModel()->selectedIndexes().count(); | 0 | ||||||||||||||||||
173 | } | - | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | int QAccessibleTable::selectedColumnCount() const | - | ||||||||||||||||||
176 | { | - | ||||||||||||||||||
177 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
178 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
179 | return view()->selectionModel()->selectedColumns().count(); never executed: return view()->selectionModel()->selectedColumns().count(); | 0 | ||||||||||||||||||
180 | } | - | ||||||||||||||||||
181 | - | |||||||||||||||||||
182 | int QAccessibleTable::selectedRowCount() const | - | ||||||||||||||||||
183 | { | - | ||||||||||||||||||
184 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
185 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
186 | return view()->selectionModel()->selectedRows().count(); never executed: return view()->selectionModel()->selectedRows().count(); | 0 | ||||||||||||||||||
187 | } | - | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | QString QAccessibleTable::rowDescription(int row) const | - | ||||||||||||||||||
190 | { | - | ||||||||||||||||||
191 | if (!view()->model())
| 0 | ||||||||||||||||||
192 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||
193 | return view()->model()->headerData(row, Qt::Vertical).toString(); never executed: return view()->model()->headerData(row, Qt::Vertical).toString(); | 0 | ||||||||||||||||||
194 | } | - | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | QList<QAccessibleInterface *> QAccessibleTable::selectedCells() const | - | ||||||||||||||||||
197 | { | - | ||||||||||||||||||
198 | QList<QAccessibleInterface*> cells; | - | ||||||||||||||||||
199 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
200 | return cells; never executed: return cells; | 0 | ||||||||||||||||||
201 | const QModelIndexList selectedIndexes = view()->selectionModel()->selectedIndexes(); | - | ||||||||||||||||||
202 | cells.reserve(selectedIndexes.size()); | - | ||||||||||||||||||
203 | Q_FOREACH (const QModelIndex &index, selectedIndexes) | - | ||||||||||||||||||
204 | cells.append(child(logicalIndex(index))); never executed: cells.append(child(logicalIndex(index))); | 0 | ||||||||||||||||||
205 | return cells; never executed: return cells; | 0 | ||||||||||||||||||
206 | } | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | QList<int> QAccessibleTable::selectedColumns() const | - | ||||||||||||||||||
209 | { | - | ||||||||||||||||||
210 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
211 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||
212 | QList<int> columns; | - | ||||||||||||||||||
213 | const QModelIndexList selectedColumns = view()->selectionModel()->selectedColumns(); | - | ||||||||||||||||||
214 | columns.reserve(selectedColumns.size()); | - | ||||||||||||||||||
215 | Q_FOREACH (const QModelIndex &index, selectedColumns) | - | ||||||||||||||||||
216 | columns.append(index.column()); never executed: columns.append(index.column()); | 0 | ||||||||||||||||||
217 | - | |||||||||||||||||||
218 | return columns; never executed: return columns; | 0 | ||||||||||||||||||
219 | } | - | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | QList<int> QAccessibleTable::selectedRows() const | - | ||||||||||||||||||
222 | { | - | ||||||||||||||||||
223 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
224 | return QList<int>(); never executed: return QList<int>(); | 0 | ||||||||||||||||||
225 | QList<int> rows; | - | ||||||||||||||||||
226 | const QModelIndexList selectedRows = view()->selectionModel()->selectedRows(); | - | ||||||||||||||||||
227 | rows.reserve(selectedRows.size()); | - | ||||||||||||||||||
228 | Q_FOREACH (const QModelIndex &index, selectedRows) | - | ||||||||||||||||||
229 | rows.append(index.row()); never executed: rows.append(index.row()); | 0 | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | return rows; never executed: return rows; | 0 | ||||||||||||||||||
232 | } | - | ||||||||||||||||||
233 | - | |||||||||||||||||||
234 | QAccessibleInterface *QAccessibleTable::summary() const | - | ||||||||||||||||||
235 | { | - | ||||||||||||||||||
236 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
237 | } | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | bool QAccessibleTable::isColumnSelected(int column) const | - | ||||||||||||||||||
240 | { | - | ||||||||||||||||||
241 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
242 | return false; never executed: return false; | 0 | ||||||||||||||||||
243 | return view()->selectionModel()->isColumnSelected(column, QModelIndex()); never executed: return view()->selectionModel()->isColumnSelected(column, QModelIndex()); | 0 | ||||||||||||||||||
244 | } | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | bool QAccessibleTable::isRowSelected(int row) const | - | ||||||||||||||||||
247 | { | - | ||||||||||||||||||
248 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
249 | return false; never executed: return false; | 0 | ||||||||||||||||||
250 | return view()->selectionModel()->isRowSelected(row, QModelIndex()); never executed: return view()->selectionModel()->isRowSelected(row, QModelIndex()); | 0 | ||||||||||||||||||
251 | } | - | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | bool QAccessibleTable::selectRow(int row) | - | ||||||||||||||||||
254 | { | - | ||||||||||||||||||
255 | if (!view()->model() || !view()->selectionModel())
| 0 | ||||||||||||||||||
256 | return false; never executed: return false; | 0 | ||||||||||||||||||
257 | QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns)
| 0 | ||||||||||||||||||
260 | return false; never executed: return false; | 0 | ||||||||||||||||||
261 | - | |||||||||||||||||||
262 | switch (view()->selectionMode()) { | - | ||||||||||||||||||
263 | case QAbstractItemView::NoSelection: never executed: case QAbstractItemView::NoSelection: | 0 | ||||||||||||||||||
264 | return false; never executed: return false; | 0 | ||||||||||||||||||
265 | case QAbstractItemView::SingleSelection: never executed: case QAbstractItemView::SingleSelection: | 0 | ||||||||||||||||||
266 | if (view()->selectionBehavior() != QAbstractItemView::SelectRows && columnCount() > 1 )
| 0 | ||||||||||||||||||
267 | return false; never executed: return false; | 0 | ||||||||||||||||||
268 | view()->clearSelection(); | - | ||||||||||||||||||
269 | break; never executed: break; | 0 | ||||||||||||||||||
270 | case QAbstractItemView::ContiguousSelection: never executed: case QAbstractItemView::ContiguousSelection: | 0 | ||||||||||||||||||
271 | if ((!row || !view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
272 | && !view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
273 | view()->clearSelection(); never executed: view()->clearSelection(); | 0 | ||||||||||||||||||
274 | break; never executed: break; | 0 | ||||||||||||||||||
275 | default: never executed: default: | 0 | ||||||||||||||||||
276 | break; never executed: break; | 0 | ||||||||||||||||||
277 | } | - | ||||||||||||||||||
278 | - | |||||||||||||||||||
279 | view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); | - | ||||||||||||||||||
280 | return true; never executed: return true; | 0 | ||||||||||||||||||
281 | } | - | ||||||||||||||||||
282 | - | |||||||||||||||||||
283 | bool QAccessibleTable::selectColumn(int column) | - | ||||||||||||||||||
284 | { | - | ||||||||||||||||||
285 | if (!view()->model() || !view()->selectionModel())
| 0 | ||||||||||||||||||
286 | return false; never executed: return false; | 0 | ||||||||||||||||||
287 | QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); | - | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectRows)
| 0 | ||||||||||||||||||
290 | return false; never executed: return false; | 0 | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | switch (view()->selectionMode()) { | - | ||||||||||||||||||
293 | case QAbstractItemView::NoSelection: never executed: case QAbstractItemView::NoSelection: | 0 | ||||||||||||||||||
294 | return false; never executed: return false; | 0 | ||||||||||||||||||
295 | case QAbstractItemView::SingleSelection: never executed: case QAbstractItemView::SingleSelection: | 0 | ||||||||||||||||||
296 | if (view()->selectionBehavior() != QAbstractItemView::SelectColumns && rowCount() > 1)
| 0 | ||||||||||||||||||
297 | return false; never executed: return false; | 0 | ||||||||||||||||||
298 | case QAbstractItemView::ContiguousSelection: code before this statement never executed: case QAbstractItemView::ContiguousSelection: never executed: case QAbstractItemView::ContiguousSelection: | 0 | ||||||||||||||||||
299 | if ((!column || !view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
300 | && !view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
301 | view()->clearSelection(); never executed: view()->clearSelection(); | 0 | ||||||||||||||||||
302 | break; never executed: break; | 0 | ||||||||||||||||||
303 | default: never executed: default: | 0 | ||||||||||||||||||
304 | break; never executed: break; | 0 | ||||||||||||||||||
305 | } | - | ||||||||||||||||||
306 | - | |||||||||||||||||||
307 | view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Columns); | - | ||||||||||||||||||
308 | return true; never executed: return true; | 0 | ||||||||||||||||||
309 | } | - | ||||||||||||||||||
310 | - | |||||||||||||||||||
311 | bool QAccessibleTable::unselectRow(int row) | - | ||||||||||||||||||
312 | { | - | ||||||||||||||||||
313 | if (!view()->model() || !view()->selectionModel())
| 0 | ||||||||||||||||||
314 | return false; never executed: return false; | 0 | ||||||||||||||||||
315 | - | |||||||||||||||||||
316 | QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); | - | ||||||||||||||||||
317 | if (!index.isValid())
| 0 | ||||||||||||||||||
318 | return false; never executed: return false; | 0 | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | QItemSelection selection(index, index); | - | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | switch (view()->selectionMode()) { | - | ||||||||||||||||||
323 | case QAbstractItemView::SingleSelection: never executed: case QAbstractItemView::SingleSelection: | 0 | ||||||||||||||||||
324 | //In SingleSelection and ContiguousSelection once an item | - | ||||||||||||||||||
325 | //is selected, there's no way for the user to unselect all items | - | ||||||||||||||||||
326 | if (selectedRowCount() == 1)
| 0 | ||||||||||||||||||
327 | return false; never executed: return false; | 0 | ||||||||||||||||||
328 | break; never executed: break; | 0 | ||||||||||||||||||
329 | case QAbstractItemView::ContiguousSelection: never executed: case QAbstractItemView::ContiguousSelection: | 0 | ||||||||||||||||||
330 | if (selectedRowCount() == 1)
| 0 | ||||||||||||||||||
331 | return false; never executed: return false; | 0 | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | if ((!row || view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
334 | && view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex())) {
| 0 | ||||||||||||||||||
335 | //If there are rows selected both up the current row and down the current rown, | - | ||||||||||||||||||
336 | //the ones which are down the current row will be deselected | - | ||||||||||||||||||
337 | selection = QItemSelection(index, view()->model()->index(rowCount() - 1, 0, view()->rootIndex())); | - | ||||||||||||||||||
338 | } never executed: end of block | 0 | ||||||||||||||||||
339 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||
340 | break; never executed: break; | 0 | ||||||||||||||||||
341 | } | - | ||||||||||||||||||
342 | - | |||||||||||||||||||
343 | view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); | - | ||||||||||||||||||
344 | return true; never executed: return true; | 0 | ||||||||||||||||||
345 | } | - | ||||||||||||||||||
346 | - | |||||||||||||||||||
347 | bool QAccessibleTable::unselectColumn(int column) | - | ||||||||||||||||||
348 | { | - | ||||||||||||||||||
349 | if (!view()->model() || !view()->selectionModel())
| 0 | ||||||||||||||||||
350 | return false; never executed: return false; | 0 | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | QModelIndex index = view()->model()->index(0, column, view()->rootIndex()); | - | ||||||||||||||||||
353 | if (!index.isValid())
| 0 | ||||||||||||||||||
354 | return false; never executed: return false; | 0 | ||||||||||||||||||
355 | - | |||||||||||||||||||
356 | QItemSelection selection(index, index); | - | ||||||||||||||||||
357 | - | |||||||||||||||||||
358 | switch (view()->selectionMode()) { | - | ||||||||||||||||||
359 | case QAbstractItemView::SingleSelection: never executed: case QAbstractItemView::SingleSelection: | 0 | ||||||||||||||||||
360 | //In SingleSelection and ContiguousSelection once an item | - | ||||||||||||||||||
361 | //is selected, there's no way for the user to unselect all items | - | ||||||||||||||||||
362 | if (selectedColumnCount() == 1)
| 0 | ||||||||||||||||||
363 | return false; never executed: return false; | 0 | ||||||||||||||||||
364 | break; never executed: break; | 0 | ||||||||||||||||||
365 | case QAbstractItemView::ContiguousSelection: never executed: case QAbstractItemView::ContiguousSelection: | 0 | ||||||||||||||||||
366 | if (selectedColumnCount() == 1)
| 0 | ||||||||||||||||||
367 | return false; never executed: return false; | 0 | ||||||||||||||||||
368 | - | |||||||||||||||||||
369 | if ((!column || view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
370 | && view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) {
| 0 | ||||||||||||||||||
371 | //If there are columns selected both at the left of the current row and at the right | - | ||||||||||||||||||
372 | //of the current rown, the ones which are at the right will be deselected | - | ||||||||||||||||||
373 | selection = QItemSelection(index, view()->model()->index(0, columnCount() - 1, view()->rootIndex())); | - | ||||||||||||||||||
374 | } never executed: end of block | 0 | ||||||||||||||||||
375 | default: code before this statement never executed: default: never executed: default: | 0 | ||||||||||||||||||
376 | break; never executed: break; | 0 | ||||||||||||||||||
377 | } | - | ||||||||||||||||||
378 | - | |||||||||||||||||||
379 | view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Columns); | - | ||||||||||||||||||
380 | return true; never executed: return true; | 0 | ||||||||||||||||||
381 | } | - | ||||||||||||||||||
382 | - | |||||||||||||||||||
383 | QAccessible::Role QAccessibleTable::role() const | - | ||||||||||||||||||
384 | { | - | ||||||||||||||||||
385 | return m_role; never executed: return m_role; | 0 | ||||||||||||||||||
386 | } | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | QAccessible::State QAccessibleTable::state() const | - | ||||||||||||||||||
389 | { | - | ||||||||||||||||||
390 | return QAccessible::State(); never executed: return QAccessible::State(); | 0 | ||||||||||||||||||
391 | } | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const | - | ||||||||||||||||||
394 | { | - | ||||||||||||||||||
395 | QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); | - | ||||||||||||||||||
396 | QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); | - | ||||||||||||||||||
397 | // FIXME: if indexPosition < 0 in one coordinate, return header | - | ||||||||||||||||||
398 | - | |||||||||||||||||||
399 | QModelIndex index = view()->indexAt(indexPosition); | - | ||||||||||||||||||
400 | if (index.isValid()) {
| 0 | ||||||||||||||||||
401 | return child(logicalIndex(index)); never executed: return child(logicalIndex(index)); | 0 | ||||||||||||||||||
402 | } | - | ||||||||||||||||||
403 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
404 | } | - | ||||||||||||||||||
405 | - | |||||||||||||||||||
406 | int QAccessibleTable::childCount() const | - | ||||||||||||||||||
407 | { | - | ||||||||||||||||||
408 | if (!view()->model())
| 0 | ||||||||||||||||||
409 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
410 | int vHeader = verticalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
411 | int hHeader = horizontalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
412 | return (view()->model()->rowCount()+hHeader) * (view()->model()->columnCount()+vHeader); never executed: return (view()->model()->rowCount()+hHeader) * (view()->model()->columnCount()+vHeader); | 0 | ||||||||||||||||||
413 | } | - | ||||||||||||||||||
414 | - | |||||||||||||||||||
415 | int QAccessibleTable::indexOfChild(const QAccessibleInterface *iface) const | - | ||||||||||||||||||
416 | { | - | ||||||||||||||||||
417 | if (!view()->model())
| 0 | ||||||||||||||||||
418 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
419 | QAccessibleInterface *parent = iface->parent(); | - | ||||||||||||||||||
420 | if (parent->object() != view())
| 0 | ||||||||||||||||||
421 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
422 | - | |||||||||||||||||||
423 | Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class | - | ||||||||||||||||||
424 | if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
| 0 | ||||||||||||||||||
425 | const QAccessibleTableCell* cell = static_cast<const QAccessibleTableCell*>(iface); | - | ||||||||||||||||||
426 | return logicalIndex(cell->m_index); never executed: return logicalIndex(cell->m_index); | 0 | ||||||||||||||||||
427 | } else if (iface->role() == QAccessible::ColumnHeader){
| 0 | ||||||||||||||||||
428 | const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
429 | return cell->index + (verticalHeader() ? 1 : 0); never executed: return cell->index + (verticalHeader() ? 1 : 0);
| 0 | ||||||||||||||||||
430 | } else if (iface->role() == QAccessible::RowHeader){
| 0 | ||||||||||||||||||
431 | const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
432 | return (cell->index + 1) * (view()->model()->columnCount() + 1); never executed: return (cell->index + 1) * (view()->model()->columnCount() + 1); | 0 | ||||||||||||||||||
433 | } else if (iface->role() == QAccessible::Pane) {
| 0 | ||||||||||||||||||
434 | return 0; // corner button never executed: return 0; | 0 | ||||||||||||||||||
435 | } else { | - | ||||||||||||||||||
436 | qWarning() << "WARNING QAccessibleTable::indexOfChild Fix my children..." | - | ||||||||||||||||||
437 | << iface->role() << iface->text(QAccessible::Name); | - | ||||||||||||||||||
438 | } never executed: end of block | 0 | ||||||||||||||||||
439 | // FIXME: we are in denial of our children. this should stop. | - | ||||||||||||||||||
440 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
441 | } | - | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | QString QAccessibleTable::text(QAccessible::Text t) const | - | ||||||||||||||||||
444 | { | - | ||||||||||||||||||
445 | if (t == QAccessible::Description)
| 0 | ||||||||||||||||||
446 | return view()->accessibleDescription(); never executed: return view()->accessibleDescription(); | 0 | ||||||||||||||||||
447 | return view()->accessibleName(); never executed: return view()->accessibleName(); | 0 | ||||||||||||||||||
448 | } | - | ||||||||||||||||||
449 | - | |||||||||||||||||||
450 | QRect QAccessibleTable::rect() const | - | ||||||||||||||||||
451 | { | - | ||||||||||||||||||
452 | if (!view()->isVisible())
| 0 | ||||||||||||||||||
453 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
454 | QPoint pos = view()->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
455 | return QRect(pos.x(), pos.y(), view()->width(), view()->height()); never executed: return QRect(pos.x(), pos.y(), view()->width(), view()->height()); | 0 | ||||||||||||||||||
456 | } | - | ||||||||||||||||||
457 | - | |||||||||||||||||||
458 | QAccessibleInterface *QAccessibleTable::parent() const | - | ||||||||||||||||||
459 | { | - | ||||||||||||||||||
460 | if (view() && view()->parent()) {
| 0 | ||||||||||||||||||
461 | if (qstrcmp("QComboBoxPrivateContainer", view()->parent()->metaObject()->className()) == 0) {
| 0 | ||||||||||||||||||
462 | return QAccessible::queryAccessibleInterface(view()->parent()->parent()); never executed: return QAccessible::queryAccessibleInterface(view()->parent()->parent()); | 0 | ||||||||||||||||||
463 | } | - | ||||||||||||||||||
464 | return QAccessible::queryAccessibleInterface(view()->parent()); never executed: return QAccessible::queryAccessibleInterface(view()->parent()); | 0 | ||||||||||||||||||
465 | } | - | ||||||||||||||||||
466 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
467 | } | - | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const | - | ||||||||||||||||||
470 | { | - | ||||||||||||||||||
471 | if (!view()->model())
| 0 | ||||||||||||||||||
472 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | if (childToId.contains(logicalIndex)) {
| 0 | ||||||||||||||||||
475 | QAccessible::Id id = childToId.value(logicalIndex); | - | ||||||||||||||||||
476 | return QAccessible::accessibleInterface(id); never executed: return QAccessible::accessibleInterface(id); | 0 | ||||||||||||||||||
477 | } | - | ||||||||||||||||||
478 | - | |||||||||||||||||||
479 | int vHeader = verticalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
480 | int hHeader = horizontalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
481 | - | |||||||||||||||||||
482 | int columns = view()->model()->columnCount() + vHeader; | - | ||||||||||||||||||
483 | - | |||||||||||||||||||
484 | int row = logicalIndex / columns; | - | ||||||||||||||||||
485 | int column = logicalIndex % columns; | - | ||||||||||||||||||
486 | - | |||||||||||||||||||
487 | QAccessibleInterface *iface = 0; | - | ||||||||||||||||||
488 | - | |||||||||||||||||||
489 | if (vHeader) {
| 0 | ||||||||||||||||||
490 | if (column == 0) {
| 0 | ||||||||||||||||||
491 | if (hHeader && row == 0) {
| 0 | ||||||||||||||||||
492 | iface = new QAccessibleTableCornerButton(view()); | - | ||||||||||||||||||
493 | } else { never executed: end of block | 0 | ||||||||||||||||||
494 | iface = new QAccessibleTableHeaderCell(view(), row - hHeader, Qt::Vertical); | - | ||||||||||||||||||
495 | } never executed: end of block | 0 | ||||||||||||||||||
496 | } | - | ||||||||||||||||||
497 | --column; | - | ||||||||||||||||||
498 | } never executed: end of block | 0 | ||||||||||||||||||
499 | if (!iface && hHeader) {
| 0 | ||||||||||||||||||
500 | if (row == 0) {
| 0 | ||||||||||||||||||
501 | iface = new QAccessibleTableHeaderCell(view(), column, Qt::Horizontal); | - | ||||||||||||||||||
502 | } never executed: end of block | 0 | ||||||||||||||||||
503 | --row; | - | ||||||||||||||||||
504 | } never executed: end of block | 0 | ||||||||||||||||||
505 | - | |||||||||||||||||||
506 | if (!iface) {
| 0 | ||||||||||||||||||
507 | QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); | - | ||||||||||||||||||
508 | if (!index.isValid()) {
| 0 | ||||||||||||||||||
509 | qWarning() << "QAccessibleTable::child: Invalid index at: " << row << column; | - | ||||||||||||||||||
510 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
511 | } | - | ||||||||||||||||||
512 | iface = new QAccessibleTableCell(view(), index, cellRole()); | - | ||||||||||||||||||
513 | } never executed: end of block | 0 | ||||||||||||||||||
514 | - | |||||||||||||||||||
515 | QAccessible::registerAccessibleInterface(iface); | - | ||||||||||||||||||
516 | childToId.insert(logicalIndex, QAccessible::uniqueId(iface)); | - | ||||||||||||||||||
517 | return iface; never executed: return iface; | 0 | ||||||||||||||||||
518 | } | - | ||||||||||||||||||
519 | - | |||||||||||||||||||
520 | void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
521 | { | - | ||||||||||||||||||
522 | if (t == QAccessible::TableInterface)
| 0 | ||||||||||||||||||
523 | return static_cast<QAccessibleTableInterface*>(this); never executed: return static_cast<QAccessibleTableInterface*>(this); | 0 | ||||||||||||||||||
524 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
525 | } | - | ||||||||||||||||||
526 | - | |||||||||||||||||||
527 | void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) | - | ||||||||||||||||||
528 | { | - | ||||||||||||||||||
529 | // if there is no cache yet, we don't update anything | - | ||||||||||||||||||
530 | if (childToId.isEmpty())
| 0 | ||||||||||||||||||
531 | return; never executed: return; | 0 | ||||||||||||||||||
532 | - | |||||||||||||||||||
533 | switch (event->modelChangeType()) { | - | ||||||||||||||||||
534 | case QAccessibleTableModelChangeEvent::ModelReset: never executed: case QAccessibleTableModelChangeEvent::ModelReset: | 0 | ||||||||||||||||||
535 | Q_FOREACH (QAccessible::Id id, childToId) | - | ||||||||||||||||||
536 | QAccessible::deleteAccessibleInterface(id); never executed: QAccessible::deleteAccessibleInterface(id); | 0 | ||||||||||||||||||
537 | childToId.clear(); | - | ||||||||||||||||||
538 | break; never executed: break; | 0 | ||||||||||||||||||
539 | - | |||||||||||||||||||
540 | // rows are inserted: move every row after that | - | ||||||||||||||||||
541 | case QAccessibleTableModelChangeEvent::RowsInserted: never executed: case QAccessibleTableModelChangeEvent::RowsInserted: | 0 | ||||||||||||||||||
542 | case QAccessibleTableModelChangeEvent::ColumnsInserted: { never executed: case QAccessibleTableModelChangeEvent::ColumnsInserted: | 0 | ||||||||||||||||||
543 | int newRows = event->lastRow() - event->firstRow() + 1; | - | ||||||||||||||||||
544 | int newColumns = event->lastColumn() - event->firstColumn() + 1; | - | ||||||||||||||||||
545 | - | |||||||||||||||||||
546 | ChildCache newCache; | - | ||||||||||||||||||
547 | ChildCache::ConstIterator iter = childToId.constBegin(); | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | while (iter != childToId.constEnd()) {
| 0 | ||||||||||||||||||
550 | QAccessible::Id id = iter.value(); | - | ||||||||||||||||||
551 | QAccessibleInterface *iface = QAccessible::accessibleInterface(id); | - | ||||||||||||||||||
552 | Q_ASSERT(iface); | - | ||||||||||||||||||
553 | if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted
| 0 | ||||||||||||||||||
554 | && iface->role() == QAccessible::RowHeader) {
| 0 | ||||||||||||||||||
555 | QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
556 | if (cell->index >= event->firstRow()) {
| 0 | ||||||||||||||||||
557 | cell->index += newRows; | - | ||||||||||||||||||
558 | } never executed: end of block | 0 | ||||||||||||||||||
559 | } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted never executed: end of block
| 0 | ||||||||||||||||||
560 | && iface->role() == QAccessible::ColumnHeader) {
| 0 | ||||||||||||||||||
561 | QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
562 | if (cell->index >= event->firstColumn()) {
| 0 | ||||||||||||||||||
563 | cell->index += newColumns; | - | ||||||||||||||||||
564 | } never executed: end of block | 0 | ||||||||||||||||||
565 | } never executed: end of block | 0 | ||||||||||||||||||
566 | if (indexOfChild(iface) >= 0) {
| 0 | ||||||||||||||||||
567 | newCache.insert(indexOfChild(iface), id); | - | ||||||||||||||||||
568 | } else { never executed: end of block | 0 | ||||||||||||||||||
569 | // ### This should really not happen, | - | ||||||||||||||||||
570 | // but it might if the view has a root index set. | - | ||||||||||||||||||
571 | // This needs to be fixed. | - | ||||||||||||||||||
572 | QAccessible::deleteAccessibleInterface(id); | - | ||||||||||||||||||
573 | } never executed: end of block | 0 | ||||||||||||||||||
574 | ++iter; | - | ||||||||||||||||||
575 | } never executed: end of block | 0 | ||||||||||||||||||
576 | childToId = newCache; | - | ||||||||||||||||||
577 | break; never executed: break; | 0 | ||||||||||||||||||
578 | } | - | ||||||||||||||||||
579 | - | |||||||||||||||||||
580 | case QAccessibleTableModelChangeEvent::ColumnsRemoved: never executed: case QAccessibleTableModelChangeEvent::ColumnsRemoved: | 0 | ||||||||||||||||||
581 | case QAccessibleTableModelChangeEvent::RowsRemoved: { never executed: case QAccessibleTableModelChangeEvent::RowsRemoved: | 0 | ||||||||||||||||||
582 | int deletedColumns = event->lastColumn() - event->firstColumn() + 1; | - | ||||||||||||||||||
583 | int deletedRows = event->lastRow() - event->firstRow() + 1; | - | ||||||||||||||||||
584 | ChildCache newCache; | - | ||||||||||||||||||
585 | ChildCache::ConstIterator iter = childToId.constBegin(); | - | ||||||||||||||||||
586 | while (iter != childToId.constEnd()) {
| 0 | ||||||||||||||||||
587 | QAccessible::Id id = iter.value(); | - | ||||||||||||||||||
588 | QAccessibleInterface *iface = QAccessible::accessibleInterface(id); | - | ||||||||||||||||||
589 | Q_ASSERT(iface); | - | ||||||||||||||||||
590 | if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
| 0 | ||||||||||||||||||
591 | Q_ASSERT(iface->tableCellInterface()); | - | ||||||||||||||||||
592 | QAccessibleTableCell *cell = static_cast<QAccessibleTableCell*>(iface->tableCellInterface()); | - | ||||||||||||||||||
593 | // Since it is a QPersistentModelIndex, we only need to check if it is valid | - | ||||||||||||||||||
594 | if (cell->m_index.isValid())
| 0 | ||||||||||||||||||
595 | newCache.insert(indexOfChild(cell), id); never executed: newCache.insert(indexOfChild(cell), id); | 0 | ||||||||||||||||||
596 | else | - | ||||||||||||||||||
597 | QAccessible::deleteAccessibleInterface(id); never executed: QAccessible::deleteAccessibleInterface(id); | 0 | ||||||||||||||||||
598 | } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved
| 0 | ||||||||||||||||||
599 | && iface->role() == QAccessible::RowHeader) {
| 0 | ||||||||||||||||||
600 | QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
601 | if (cell->index < event->firstRow()) {
| 0 | ||||||||||||||||||
602 | newCache.insert(indexOfChild(cell), id); | - | ||||||||||||||||||
603 | } else if (cell->index > event->lastRow()) { never executed: end of block
| 0 | ||||||||||||||||||
604 | cell->index -= deletedRows; | - | ||||||||||||||||||
605 | newCache.insert(indexOfChild(cell), id); | - | ||||||||||||||||||
606 | } else { never executed: end of block | 0 | ||||||||||||||||||
607 | QAccessible::deleteAccessibleInterface(id); | - | ||||||||||||||||||
608 | } never executed: end of block | 0 | ||||||||||||||||||
609 | } else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsRemoved
| 0 | ||||||||||||||||||
610 | && iface->role() == QAccessible::ColumnHeader) {
| 0 | ||||||||||||||||||
611 | QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
612 | if (cell->index < event->firstColumn()) {
| 0 | ||||||||||||||||||
613 | newCache.insert(indexOfChild(cell), id); | - | ||||||||||||||||||
614 | } else if (cell->index > event->lastColumn()) { never executed: end of block
| 0 | ||||||||||||||||||
615 | cell->index -= deletedColumns; | - | ||||||||||||||||||
616 | newCache.insert(indexOfChild(cell), id); | - | ||||||||||||||||||
617 | } else { never executed: end of block | 0 | ||||||||||||||||||
618 | QAccessible::deleteAccessibleInterface(id); | - | ||||||||||||||||||
619 | } never executed: end of block | 0 | ||||||||||||||||||
620 | } | - | ||||||||||||||||||
621 | ++iter; | - | ||||||||||||||||||
622 | } never executed: end of block | 0 | ||||||||||||||||||
623 | childToId = newCache; | - | ||||||||||||||||||
624 | break; never executed: break; | 0 | ||||||||||||||||||
625 | } | - | ||||||||||||||||||
626 | - | |||||||||||||||||||
627 | case QAccessibleTableModelChangeEvent::DataChanged: never executed: case QAccessibleTableModelChangeEvent::DataChanged: | 0 | ||||||||||||||||||
628 | // nothing to do in this case | - | ||||||||||||||||||
629 | break; never executed: break; | 0 | ||||||||||||||||||
630 | } | - | ||||||||||||||||||
631 | } never executed: end of block | 0 | ||||||||||||||||||
632 | - | |||||||||||||||||||
633 | // TREE VIEW | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const | - | ||||||||||||||||||
636 | { | - | ||||||||||||||||||
637 | if (!isValid() || !view()->model())
| 0 | ||||||||||||||||||
638 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||
639 | - | |||||||||||||||||||
640 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
641 | if ((row < 0) || (column < 0) || (treeView->d_func()->viewItems.count() <= row)) {
| 0 | ||||||||||||||||||
642 | qWarning() << "QAccessibleTree::indexFromLogical: invalid index: " << row << column << " for " << treeView; | - | ||||||||||||||||||
643 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||||||||
644 | } | - | ||||||||||||||||||
645 | QModelIndex modelIndex = treeView->d_func()->viewItems.at(row).index; | - | ||||||||||||||||||
646 | - | |||||||||||||||||||
647 | if (modelIndex.isValid() && column > 0) {
| 0 | ||||||||||||||||||
648 | modelIndex = view()->model()->index(modelIndex.row(), column, modelIndex.parent()); | - | ||||||||||||||||||
649 | } never executed: end of block | 0 | ||||||||||||||||||
650 | return modelIndex; never executed: return modelIndex; | 0 | ||||||||||||||||||
651 | } | - | ||||||||||||||||||
652 | - | |||||||||||||||||||
653 | QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const | - | ||||||||||||||||||
654 | { | - | ||||||||||||||||||
655 | if (!view()->model())
| 0 | ||||||||||||||||||
656 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
657 | QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); | - | ||||||||||||||||||
658 | QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); | - | ||||||||||||||||||
659 | - | |||||||||||||||||||
660 | QModelIndex index = view()->indexAt(indexPosition); | - | ||||||||||||||||||
661 | if (!index.isValid())
| 0 | ||||||||||||||||||
662 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
665 | int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
| 0 | ||||||||||||||||||
666 | int column = index.column(); | - | ||||||||||||||||||
667 | - | |||||||||||||||||||
668 | int i = row * view()->model()->columnCount() + column; | - | ||||||||||||||||||
669 | return child(i); never executed: return child(i); | 0 | ||||||||||||||||||
670 | } | - | ||||||||||||||||||
671 | - | |||||||||||||||||||
672 | int QAccessibleTree::childCount() const | - | ||||||||||||||||||
673 | { | - | ||||||||||||||||||
674 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
675 | Q_ASSERT(treeView); | - | ||||||||||||||||||
676 | if (!view()->model())
| 0 | ||||||||||||||||||
677 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
678 | - | |||||||||||||||||||
679 | int hHeader = horizontalHeader() ? 1 : 0;
| 0 | ||||||||||||||||||
680 | return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); never executed: return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount(); | 0 | ||||||||||||||||||
681 | } | - | ||||||||||||||||||
682 | - | |||||||||||||||||||
683 | - | |||||||||||||||||||
684 | QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const | - | ||||||||||||||||||
685 | { | - | ||||||||||||||||||
686 | if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount())
| 0 | ||||||||||||||||||
687 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
688 | - | |||||||||||||||||||
689 | QAccessibleInterface *iface = 0; | - | ||||||||||||||||||
690 | int index = logicalIndex; | - | ||||||||||||||||||
691 | - | |||||||||||||||||||
692 | if (horizontalHeader()) {
| 0 | ||||||||||||||||||
693 | if (index < view()->model()->columnCount()) {
| 0 | ||||||||||||||||||
694 | iface = new QAccessibleTableHeaderCell(view(), index, Qt::Horizontal); | - | ||||||||||||||||||
695 | } else { never executed: end of block | 0 | ||||||||||||||||||
696 | index -= view()->model()->columnCount(); | - | ||||||||||||||||||
697 | } never executed: end of block | 0 | ||||||||||||||||||
698 | } | - | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | if (!iface) {
| 0 | ||||||||||||||||||
701 | int row = index / view()->model()->columnCount(); | - | ||||||||||||||||||
702 | int column = index % view()->model()->columnCount(); | - | ||||||||||||||||||
703 | QModelIndex modelIndex = indexFromLogical(row, column); | - | ||||||||||||||||||
704 | if (!modelIndex.isValid())
| 0 | ||||||||||||||||||
705 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
706 | iface = new QAccessibleTableCell(view(), modelIndex, cellRole()); | - | ||||||||||||||||||
707 | } never executed: end of block | 0 | ||||||||||||||||||
708 | QAccessible::registerAccessibleInterface(iface); | - | ||||||||||||||||||
709 | // ### FIXME: get interfaces from the cache instead of re-creating them | - | ||||||||||||||||||
710 | return iface; never executed: return iface; | 0 | ||||||||||||||||||
711 | } | - | ||||||||||||||||||
712 | - | |||||||||||||||||||
713 | int QAccessibleTree::rowCount() const | - | ||||||||||||||||||
714 | { | - | ||||||||||||||||||
715 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
716 | Q_ASSERT(treeView); | - | ||||||||||||||||||
717 | return treeView->d_func()->viewItems.count(); never executed: return treeView->d_func()->viewItems.count(); | 0 | ||||||||||||||||||
718 | } | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | int QAccessibleTree::indexOfChild(const QAccessibleInterface *iface) const | - | ||||||||||||||||||
721 | { | - | ||||||||||||||||||
722 | if (!view()->model())
| 0 | ||||||||||||||||||
723 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
724 | QAccessibleInterface *parent = iface->parent(); | - | ||||||||||||||||||
725 | if (parent->object() != view())
| 0 | ||||||||||||||||||
726 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
727 | - | |||||||||||||||||||
728 | if (iface->role() == QAccessible::TreeItem) {
| 0 | ||||||||||||||||||
729 | const QAccessibleTableCell* cell = static_cast<const QAccessibleTableCell*>(iface); | - | ||||||||||||||||||
730 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
731 | Q_ASSERT(treeView); | - | ||||||||||||||||||
732 | int row = treeView->d_func()->viewIndex(cell->m_index) + (horizontalHeader() ? 1 : 0);
| 0 | ||||||||||||||||||
733 | int column = cell->m_index.column(); | - | ||||||||||||||||||
734 | - | |||||||||||||||||||
735 | int index = row * view()->model()->columnCount() + column; | - | ||||||||||||||||||
736 | return index; never executed: return index; | 0 | ||||||||||||||||||
737 | } else if (iface->role() == QAccessible::ColumnHeader){
| 0 | ||||||||||||||||||
738 | const QAccessibleTableHeaderCell* cell = static_cast<const QAccessibleTableHeaderCell*>(iface); | - | ||||||||||||||||||
739 | return cell->index; never executed: return cell->index; | 0 | ||||||||||||||||||
740 | } else { | - | ||||||||||||||||||
741 | qWarning() << "WARNING QAccessibleTable::indexOfChild invalid child" | - | ||||||||||||||||||
742 | << iface->role() << iface->text(QAccessible::Name); | - | ||||||||||||||||||
743 | } never executed: end of block | 0 | ||||||||||||||||||
744 | // FIXME: add scrollbars and don't just ignore them | - | ||||||||||||||||||
745 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
746 | } | - | ||||||||||||||||||
747 | - | |||||||||||||||||||
748 | QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const | - | ||||||||||||||||||
749 | { | - | ||||||||||||||||||
750 | QModelIndex index = indexFromLogical(row, column); | - | ||||||||||||||||||
751 | if (!index.isValid()) {
| 0 | ||||||||||||||||||
752 | qWarning() << "Requested invalid tree cell: " << row << column; | - | ||||||||||||||||||
753 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
754 | } | - | ||||||||||||||||||
755 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); | - | ||||||||||||||||||
756 | Q_ASSERT(treeView); | - | ||||||||||||||||||
757 | int logicalIndex = treeView->d_func()->accessibleTable2Index(index); | - | ||||||||||||||||||
758 | - | |||||||||||||||||||
759 | return child(logicalIndex); // FIXME ### new QAccessibleTableCell(view(), index, cellRole()); never executed: return child(logicalIndex); | 0 | ||||||||||||||||||
760 | } | - | ||||||||||||||||||
761 | - | |||||||||||||||||||
762 | QString QAccessibleTree::rowDescription(int) const | - | ||||||||||||||||||
763 | { | - | ||||||||||||||||||
764 | return QString(); // no headers for rows in trees never executed: return QString(); | 0 | ||||||||||||||||||
765 | } | - | ||||||||||||||||||
766 | - | |||||||||||||||||||
767 | bool QAccessibleTree::isRowSelected(int row) const | - | ||||||||||||||||||
768 | { | - | ||||||||||||||||||
769 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
770 | return false; never executed: return false; | 0 | ||||||||||||||||||
771 | QModelIndex index = indexFromLogical(row); | - | ||||||||||||||||||
772 | return view()->selectionModel()->isRowSelected(index.row(), index.parent()); never executed: return view()->selectionModel()->isRowSelected(index.row(), index.parent()); | 0 | ||||||||||||||||||
773 | } | - | ||||||||||||||||||
774 | - | |||||||||||||||||||
775 | bool QAccessibleTree::selectRow(int row) | - | ||||||||||||||||||
776 | { | - | ||||||||||||||||||
777 | if (!view()->selectionModel())
| 0 | ||||||||||||||||||
778 | return false; never executed: return false; | 0 | ||||||||||||||||||
779 | QModelIndex index = indexFromLogical(row); | - | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns)
| 0 | ||||||||||||||||||
782 | return false; never executed: return false; | 0 | ||||||||||||||||||
783 | - | |||||||||||||||||||
784 | switch (view()->selectionMode()) { | - | ||||||||||||||||||
785 | case QAbstractItemView::NoSelection: never executed: case QAbstractItemView::NoSelection: | 0 | ||||||||||||||||||
786 | return false; never executed: return false; | 0 | ||||||||||||||||||
787 | case QAbstractItemView::SingleSelection: never executed: case QAbstractItemView::SingleSelection: | 0 | ||||||||||||||||||
788 | if ((view()->selectionBehavior() != QAbstractItemView::SelectRows) && (columnCount() > 1))
| 0 | ||||||||||||||||||
789 | return false; never executed: return false; | 0 | ||||||||||||||||||
790 | view()->clearSelection(); | - | ||||||||||||||||||
791 | break; never executed: break; | 0 | ||||||||||||||||||
792 | case QAbstractItemView::ContiguousSelection: never executed: case QAbstractItemView::ContiguousSelection: | 0 | ||||||||||||||||||
793 | if ((!row || !view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
794 | && !view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex()))
| 0 | ||||||||||||||||||
795 | view()->clearSelection(); never executed: view()->clearSelection(); | 0 | ||||||||||||||||||
796 | break; never executed: break; | 0 | ||||||||||||||||||
797 | default: never executed: default: | 0 | ||||||||||||||||||
798 | break; never executed: break; | 0 | ||||||||||||||||||
799 | } | - | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); | - | ||||||||||||||||||
802 | return true; never executed: return true; | 0 | ||||||||||||||||||
803 | } | - | ||||||||||||||||||
804 | - | |||||||||||||||||||
805 | // TABLE CELL | - | ||||||||||||||||||
806 | - | |||||||||||||||||||
807 | QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_) | - | ||||||||||||||||||
808 | : /* QAccessibleSimpleEditableTextInterface(this), */ view(view_), m_index(index_), m_role(role_) | - | ||||||||||||||||||
809 | { | - | ||||||||||||||||||
810 | if (!index_.isValid())
| 0 | ||||||||||||||||||
811 | qWarning() << "QAccessibleTableCell::QAccessibleTableCell with invalid index: " << index_; never executed: QMessageLogger(__FILE__, 811, __PRETTY_FUNCTION__).warning() << "QAccessibleTableCell::QAccessibleTableCell with invalid index: " << index_; | 0 | ||||||||||||||||||
812 | } never executed: end of block | 0 | ||||||||||||||||||
813 | - | |||||||||||||||||||
814 | void *QAccessibleTableCell::interface_cast(QAccessible::InterfaceType t) | - | ||||||||||||||||||
815 | { | - | ||||||||||||||||||
816 | if (t == QAccessible::TableCellInterface)
| 0 | ||||||||||||||||||
817 | return static_cast<QAccessibleTableCellInterface*>(this); never executed: return static_cast<QAccessibleTableCellInterface*>(this); | 0 | ||||||||||||||||||
818 | if (t == QAccessible::ActionInterface)
| 0 | ||||||||||||||||||
819 | return static_cast<QAccessibleActionInterface*>(this); never executed: return static_cast<QAccessibleActionInterface*>(this); | 0 | ||||||||||||||||||
820 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
821 | } | - | ||||||||||||||||||
822 | - | |||||||||||||||||||
823 | int QAccessibleTableCell::columnExtent() const { return 1; } never executed: return 1; | 0 | ||||||||||||||||||
824 | int QAccessibleTableCell::rowExtent() const { return 1; } never executed: return 1; | 0 | ||||||||||||||||||
825 | - | |||||||||||||||||||
826 | QList<QAccessibleInterface*> QAccessibleTableCell::rowHeaderCells() const | - | ||||||||||||||||||
827 | { | - | ||||||||||||||||||
828 | QList<QAccessibleInterface*> headerCell; | - | ||||||||||||||||||
829 | if (verticalHeader()) {
| 0 | ||||||||||||||||||
830 | // FIXME | - | ||||||||||||||||||
831 | headerCell.append(new QAccessibleTableHeaderCell(view, m_index.row(), Qt::Vertical)); | - | ||||||||||||||||||
832 | } never executed: end of block | 0 | ||||||||||||||||||
833 | return headerCell; never executed: return headerCell; | 0 | ||||||||||||||||||
834 | } | - | ||||||||||||||||||
835 | - | |||||||||||||||||||
836 | QList<QAccessibleInterface*> QAccessibleTableCell::columnHeaderCells() const | - | ||||||||||||||||||
837 | { | - | ||||||||||||||||||
838 | QList<QAccessibleInterface*> headerCell; | - | ||||||||||||||||||
839 | if (horizontalHeader()) {
| 0 | ||||||||||||||||||
840 | // FIXME | - | ||||||||||||||||||
841 | headerCell.append(new QAccessibleTableHeaderCell(view, m_index.column(), Qt::Horizontal)); | - | ||||||||||||||||||
842 | } never executed: end of block | 0 | ||||||||||||||||||
843 | return headerCell; never executed: return headerCell; | 0 | ||||||||||||||||||
844 | } | - | ||||||||||||||||||
845 | - | |||||||||||||||||||
846 | QHeaderView *QAccessibleTableCell::horizontalHeader() const | - | ||||||||||||||||||
847 | { | - | ||||||||||||||||||
848 | QHeaderView *header = 0; | - | ||||||||||||||||||
849 | - | |||||||||||||||||||
850 | if (false) { dead code: { } | - | ||||||||||||||||||
851 | #ifndef QT_NO_TABLEVIEW dead code: { } | - | ||||||||||||||||||
852 | } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
dead code: { } | - | ||||||||||||||||||
853 | header = tv->horizontalHeader(); | - | ||||||||||||||||||
854 | #endif | - | ||||||||||||||||||
855 | #ifndef QT_NO_TREEVIEW | - | ||||||||||||||||||
856 | } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) { never executed: end of block
| 0 | ||||||||||||||||||
857 | header = tv->header(); | - | ||||||||||||||||||
858 | #endif | - | ||||||||||||||||||
859 | } never executed: end of block | 0 | ||||||||||||||||||
860 | - | |||||||||||||||||||
861 | return header; never executed: return header; | 0 | ||||||||||||||||||
862 | } | - | ||||||||||||||||||
863 | - | |||||||||||||||||||
864 | QHeaderView *QAccessibleTableCell::verticalHeader() const | - | ||||||||||||||||||
865 | { | - | ||||||||||||||||||
866 | QHeaderView *header = 0; | - | ||||||||||||||||||
867 | #ifndef QT_NO_TABLEVIEW | - | ||||||||||||||||||
868 | if (const QTableView *tv = qobject_cast<const QTableView*>(view))
| 0 | ||||||||||||||||||
869 | header = tv->verticalHeader(); never executed: header = tv->verticalHeader(); | 0 | ||||||||||||||||||
870 | #endif | - | ||||||||||||||||||
871 | return header; never executed: return header; | 0 | ||||||||||||||||||
872 | } | - | ||||||||||||||||||
873 | - | |||||||||||||||||||
874 | int QAccessibleTableCell::columnIndex() const | - | ||||||||||||||||||
875 | { | - | ||||||||||||||||||
876 | return m_index.column(); never executed: return m_index.column(); | 0 | ||||||||||||||||||
877 | } | - | ||||||||||||||||||
878 | - | |||||||||||||||||||
879 | int QAccessibleTableCell::rowIndex() const | - | ||||||||||||||||||
880 | { | - | ||||||||||||||||||
881 | if (role() == QAccessible::TreeItem) {
| 0 | ||||||||||||||||||
882 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view); | - | ||||||||||||||||||
883 | Q_ASSERT(treeView); | - | ||||||||||||||||||
884 | int row = treeView->d_func()->viewIndex(m_index); | - | ||||||||||||||||||
885 | return row; never executed: return row; | 0 | ||||||||||||||||||
886 | } | - | ||||||||||||||||||
887 | return m_index.row(); never executed: return m_index.row(); | 0 | ||||||||||||||||||
888 | } | - | ||||||||||||||||||
889 | - | |||||||||||||||||||
890 | bool QAccessibleTableCell::isSelected() const | - | ||||||||||||||||||
891 | { | - | ||||||||||||||||||
892 | return view->selectionModel()->isSelected(m_index); never executed: return view->selectionModel()->isSelected(m_index); | 0 | ||||||||||||||||||
893 | } | - | ||||||||||||||||||
894 | - | |||||||||||||||||||
895 | QStringList QAccessibleTableCell::actionNames() const | - | ||||||||||||||||||
896 | { | - | ||||||||||||||||||
897 | QStringList names; | - | ||||||||||||||||||
898 | names << toggleAction(); | - | ||||||||||||||||||
899 | return names; never executed: return names; | 0 | ||||||||||||||||||
900 | } | - | ||||||||||||||||||
901 | - | |||||||||||||||||||
902 | void QAccessibleTableCell::doAction(const QString& actionName) | - | ||||||||||||||||||
903 | { | - | ||||||||||||||||||
904 | if (actionName == toggleAction()) {
| 0 | ||||||||||||||||||
905 | if (isSelected())
| 0 | ||||||||||||||||||
906 | unselectCell(); never executed: unselectCell(); | 0 | ||||||||||||||||||
907 | else | - | ||||||||||||||||||
908 | selectCell(); never executed: selectCell(); | 0 | ||||||||||||||||||
909 | } | - | ||||||||||||||||||
910 | } never executed: end of block | 0 | ||||||||||||||||||
911 | - | |||||||||||||||||||
912 | QStringList QAccessibleTableCell::keyBindingsForAction(const QString &) const | - | ||||||||||||||||||
913 | { | - | ||||||||||||||||||
914 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||||||||
915 | } | - | ||||||||||||||||||
916 | - | |||||||||||||||||||
917 | - | |||||||||||||||||||
918 | void QAccessibleTableCell::selectCell() | - | ||||||||||||||||||
919 | { | - | ||||||||||||||||||
920 | QAbstractItemView::SelectionMode selectionMode = view->selectionMode(); | - | ||||||||||||||||||
921 | if (!m_index.isValid() || (selectionMode == QAbstractItemView::NoSelection))
| 0 | ||||||||||||||||||
922 | return; never executed: return; | 0 | ||||||||||||||||||
923 | Q_ASSERT(table()); | - | ||||||||||||||||||
924 | QAccessibleTableInterface *cellTable = table()->tableInterface(); | - | ||||||||||||||||||
925 | - | |||||||||||||||||||
926 | switch (view->selectionBehavior()) { | - | ||||||||||||||||||
927 | case QAbstractItemView::SelectItems: never executed: case QAbstractItemView::SelectItems: | 0 | ||||||||||||||||||
928 | break; never executed: break; | 0 | ||||||||||||||||||
929 | case QAbstractItemView::SelectColumns: never executed: case QAbstractItemView::SelectColumns: | 0 | ||||||||||||||||||
930 | if (cellTable)
| 0 | ||||||||||||||||||
931 | cellTable->selectColumn(m_index.column()); never executed: cellTable->selectColumn(m_index.column()); | 0 | ||||||||||||||||||
932 | return; never executed: return; | 0 | ||||||||||||||||||
933 | case QAbstractItemView::SelectRows: never executed: case QAbstractItemView::SelectRows: | 0 | ||||||||||||||||||
934 | if (cellTable)
| 0 | ||||||||||||||||||
935 | cellTable->selectRow(m_index.row()); never executed: cellTable->selectRow(m_index.row()); | 0 | ||||||||||||||||||
936 | return; never executed: return; | 0 | ||||||||||||||||||
937 | } | - | ||||||||||||||||||
938 | - | |||||||||||||||||||
939 | if (selectionMode == QAbstractItemView::SingleSelection) {
| 0 | ||||||||||||||||||
940 | view->clearSelection(); | - | ||||||||||||||||||
941 | } never executed: end of block | 0 | ||||||||||||||||||
942 | - | |||||||||||||||||||
943 | view->selectionModel()->select(m_index, QItemSelectionModel::Select); | - | ||||||||||||||||||
944 | } never executed: end of block | 0 | ||||||||||||||||||
945 | - | |||||||||||||||||||
946 | void QAccessibleTableCell::unselectCell() | - | ||||||||||||||||||
947 | { | - | ||||||||||||||||||
948 | - | |||||||||||||||||||
949 | QAbstractItemView::SelectionMode selectionMode = view->selectionMode(); | - | ||||||||||||||||||
950 | if (!m_index.isValid() || (selectionMode & QAbstractItemView::NoSelection))
| 0 | ||||||||||||||||||
951 | return; never executed: return; | 0 | ||||||||||||||||||
952 | - | |||||||||||||||||||
953 | QAccessibleTableInterface *cellTable = table()->tableInterface(); | - | ||||||||||||||||||
954 | - | |||||||||||||||||||
955 | switch (view->selectionBehavior()) { | - | ||||||||||||||||||
956 | case QAbstractItemView::SelectItems: never executed: case QAbstractItemView::SelectItems: | 0 | ||||||||||||||||||
957 | break; never executed: break; | 0 | ||||||||||||||||||
958 | case QAbstractItemView::SelectColumns: never executed: case QAbstractItemView::SelectColumns: | 0 | ||||||||||||||||||
959 | if (cellTable)
| 0 | ||||||||||||||||||
960 | cellTable->unselectColumn(m_index.column()); never executed: cellTable->unselectColumn(m_index.column()); | 0 | ||||||||||||||||||
961 | return; never executed: return; | 0 | ||||||||||||||||||
962 | case QAbstractItemView::SelectRows: never executed: case QAbstractItemView::SelectRows: | 0 | ||||||||||||||||||
963 | if (cellTable)
| 0 | ||||||||||||||||||
964 | cellTable->unselectRow(m_index.row()); never executed: cellTable->unselectRow(m_index.row()); | 0 | ||||||||||||||||||
965 | return; never executed: return; | 0 | ||||||||||||||||||
966 | } | - | ||||||||||||||||||
967 | - | |||||||||||||||||||
968 | //If the mode is not MultiSelection or ExtendedSelection and only | - | ||||||||||||||||||
969 | //one cell is selected it cannot be unselected by the user | - | ||||||||||||||||||
970 | if ((selectionMode != QAbstractItemView::MultiSelection)
| 0 | ||||||||||||||||||
971 | && (selectionMode != QAbstractItemView::ExtendedSelection)
| 0 | ||||||||||||||||||
972 | && (view->selectionModel()->selectedIndexes().count() <= 1))
| 0 | ||||||||||||||||||
973 | return; never executed: return; | 0 | ||||||||||||||||||
974 | - | |||||||||||||||||||
975 | view->selectionModel()->select(m_index, QItemSelectionModel::Deselect); | - | ||||||||||||||||||
976 | } never executed: end of block | 0 | ||||||||||||||||||
977 | - | |||||||||||||||||||
978 | QAccessibleInterface *QAccessibleTableCell::table() const | - | ||||||||||||||||||
979 | { | - | ||||||||||||||||||
980 | return QAccessible::queryAccessibleInterface(view); never executed: return QAccessible::queryAccessibleInterface(view); | 0 | ||||||||||||||||||
981 | } | - | ||||||||||||||||||
982 | - | |||||||||||||||||||
983 | QAccessible::Role QAccessibleTableCell::role() const | - | ||||||||||||||||||
984 | { | - | ||||||||||||||||||
985 | return m_role; never executed: return m_role; | 0 | ||||||||||||||||||
986 | } | - | ||||||||||||||||||
987 | - | |||||||||||||||||||
988 | QAccessible::State QAccessibleTableCell::state() const | - | ||||||||||||||||||
989 | { | - | ||||||||||||||||||
990 | QAccessible::State st; | - | ||||||||||||||||||
991 | if (!view)
| 0 | ||||||||||||||||||
992 | return st; never executed: return st; | 0 | ||||||||||||||||||
993 | - | |||||||||||||||||||
994 | QRect globalRect = view->rect(); | - | ||||||||||||||||||
995 | globalRect.translate(view->mapToGlobal(QPoint(0,0))); | - | ||||||||||||||||||
996 | if (!globalRect.intersects(rect()))
| 0 | ||||||||||||||||||
997 | st.invisible = true; never executed: st.invisible = true; | 0 | ||||||||||||||||||
998 | - | |||||||||||||||||||
999 | if (view->selectionModel()->isSelected(m_index))
| 0 | ||||||||||||||||||
1000 | st.selected = true; never executed: st.selected = true; | 0 | ||||||||||||||||||
1001 | if (view->selectionModel()->currentIndex() == m_index)
| 0 | ||||||||||||||||||
1002 | st.focused = true; never executed: st.focused = true; | 0 | ||||||||||||||||||
1003 | if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked)
| 0 | ||||||||||||||||||
1004 | st.checked = true; never executed: st.checked = true; | 0 | ||||||||||||||||||
1005 | - | |||||||||||||||||||
1006 | Qt::ItemFlags flags = m_index.flags(); | - | ||||||||||||||||||
1007 | if (flags & Qt::ItemIsSelectable) {
| 0 | ||||||||||||||||||
1008 | st.selectable = true; | - | ||||||||||||||||||
1009 | st.focusable = true; | - | ||||||||||||||||||
1010 | if (view->selectionMode() == QAbstractItemView::MultiSelection)
| 0 | ||||||||||||||||||
1011 | st.multiSelectable = true; never executed: st.multiSelectable = true; | 0 | ||||||||||||||||||
1012 | if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
| 0 | ||||||||||||||||||
1013 | st.extSelectable = true; never executed: st.extSelectable = true; | 0 | ||||||||||||||||||
1014 | } never executed: end of block | 0 | ||||||||||||||||||
1015 | if (m_role == QAccessible::TreeItem) {
| 0 | ||||||||||||||||||
1016 | const QTreeView *treeView = qobject_cast<const QTreeView*>(view); | - | ||||||||||||||||||
1017 | if (treeView->model()->hasChildren(m_index))
| 0 | ||||||||||||||||||
1018 | st.expandable = true; never executed: st.expandable = true; | 0 | ||||||||||||||||||
1019 | if (treeView->isExpanded(m_index))
| 0 | ||||||||||||||||||
1020 | st.expanded = true; never executed: st.expanded = true; | 0 | ||||||||||||||||||
1021 | } never executed: end of block | 0 | ||||||||||||||||||
1022 | return st; never executed: return st; | 0 | ||||||||||||||||||
1023 | } | - | ||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | - | |||||||||||||||||||
1026 | QRect QAccessibleTableCell::rect() const | - | ||||||||||||||||||
1027 | { | - | ||||||||||||||||||
1028 | QRect r; | - | ||||||||||||||||||
1029 | r = view->visualRect(m_index); | - | ||||||||||||||||||
1030 | - | |||||||||||||||||||
1031 | if (!r.isNull()) {
| 0 | ||||||||||||||||||
1032 | r.translate(view->viewport()->mapTo(view, QPoint(0,0))); | - | ||||||||||||||||||
1033 | r.translate(view->mapToGlobal(QPoint(0, 0))); | - | ||||||||||||||||||
1034 | } never executed: end of block | 0 | ||||||||||||||||||
1035 | return r; never executed: return r; | 0 | ||||||||||||||||||
1036 | } | - | ||||||||||||||||||
1037 | - | |||||||||||||||||||
1038 | QString QAccessibleTableCell::text(QAccessible::Text t) const | - | ||||||||||||||||||
1039 | { | - | ||||||||||||||||||
1040 | QAbstractItemModel *model = view->model(); | - | ||||||||||||||||||
1041 | QString value; | - | ||||||||||||||||||
1042 | switch (t) { | - | ||||||||||||||||||
1043 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
1044 | value = model->data(m_index, Qt::AccessibleTextRole).toString(); | - | ||||||||||||||||||
1045 | if (value.isEmpty())
| 0 | ||||||||||||||||||
1046 | value = model->data(m_index, Qt::DisplayRole).toString(); never executed: value = model->data(m_index, Qt::DisplayRole).toString(); | 0 | ||||||||||||||||||
1047 | break; never executed: break; | 0 | ||||||||||||||||||
1048 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||||||||
1049 | value = model->data(m_index, Qt::AccessibleDescriptionRole).toString(); | - | ||||||||||||||||||
1050 | break; never executed: break; | 0 | ||||||||||||||||||
1051 | default: never executed: default: | 0 | ||||||||||||||||||
1052 | break; never executed: break; | 0 | ||||||||||||||||||
1053 | } | - | ||||||||||||||||||
1054 | return value; never executed: return value; | 0 | ||||||||||||||||||
1055 | } | - | ||||||||||||||||||
1056 | - | |||||||||||||||||||
1057 | void QAccessibleTableCell::setText(QAccessible::Text /*t*/, const QString &text) | - | ||||||||||||||||||
1058 | { | - | ||||||||||||||||||
1059 | if (!(m_index.flags() & Qt::ItemIsEditable))
| 0 | ||||||||||||||||||
1060 | return; never executed: return; | 0 | ||||||||||||||||||
1061 | view->model()->setData(m_index, text); | - | ||||||||||||||||||
1062 | } never executed: end of block | 0 | ||||||||||||||||||
1063 | - | |||||||||||||||||||
1064 | bool QAccessibleTableCell::isValid() const | - | ||||||||||||||||||
1065 | { | - | ||||||||||||||||||
1066 | return view && view->model() && m_index.isValid(); never executed: return view && view->model() && m_index.isValid();
| 0 | ||||||||||||||||||
1067 | } | - | ||||||||||||||||||
1068 | - | |||||||||||||||||||
1069 | QAccessibleInterface *QAccessibleTableCell::parent() const | - | ||||||||||||||||||
1070 | { | - | ||||||||||||||||||
1071 | return QAccessible::queryAccessibleInterface(view); never executed: return QAccessible::queryAccessibleInterface(view); | 0 | ||||||||||||||||||
1072 | } | - | ||||||||||||||||||
1073 | - | |||||||||||||||||||
1074 | QAccessibleInterface *QAccessibleTableCell::child(int) const | - | ||||||||||||||||||
1075 | { | - | ||||||||||||||||||
1076 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1077 | } | - | ||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_) | - | ||||||||||||||||||
1080 | : view(view_), index(index_), orientation(orientation_) | - | ||||||||||||||||||
1081 | { | - | ||||||||||||||||||
1082 | Q_ASSERT(index_ >= 0); | - | ||||||||||||||||||
1083 | } never executed: end of block | 0 | ||||||||||||||||||
1084 | - | |||||||||||||||||||
1085 | QAccessible::Role QAccessibleTableHeaderCell::role() const | - | ||||||||||||||||||
1086 | { | - | ||||||||||||||||||
1087 | if (orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||
1088 | return QAccessible::ColumnHeader; never executed: return QAccessible::ColumnHeader; | 0 | ||||||||||||||||||
1089 | return QAccessible::RowHeader; never executed: return QAccessible::RowHeader; | 0 | ||||||||||||||||||
1090 | } | - | ||||||||||||||||||
1091 | - | |||||||||||||||||||
1092 | QAccessible::State QAccessibleTableHeaderCell::state() const | - | ||||||||||||||||||
1093 | { | - | ||||||||||||||||||
1094 | QAccessible::State s; | - | ||||||||||||||||||
1095 | if (QHeaderView *h = headerView()) {
| 0 | ||||||||||||||||||
1096 | s.invisible = !h->testAttribute(Qt::WA_WState_Visible); | - | ||||||||||||||||||
1097 | s.disabled = !h->isEnabled(); | - | ||||||||||||||||||
1098 | } never executed: end of block | 0 | ||||||||||||||||||
1099 | return s; never executed: return s; | 0 | ||||||||||||||||||
1100 | } | - | ||||||||||||||||||
1101 | - | |||||||||||||||||||
1102 | QRect QAccessibleTableHeaderCell::rect() const | - | ||||||||||||||||||
1103 | { | - | ||||||||||||||||||
1104 | QHeaderView *header = 0; | - | ||||||||||||||||||
1105 | if (false) { dead code: { } | - | ||||||||||||||||||
1106 | #ifndef QT_NO_TABLEVIEW dead code: { } | - | ||||||||||||||||||
1107 | } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
dead code: { } | - | ||||||||||||||||||
1108 | if (orientation == Qt::Horizontal) {
| 0 | ||||||||||||||||||
1109 | header = tv->horizontalHeader(); | - | ||||||||||||||||||
1110 | } else { never executed: end of block | 0 | ||||||||||||||||||
1111 | header = tv->verticalHeader(); | - | ||||||||||||||||||
1112 | } never executed: end of block | 0 | ||||||||||||||||||
1113 | #endif | - | ||||||||||||||||||
1114 | #ifndef QT_NO_TREEVIEW | - | ||||||||||||||||||
1115 | } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
| 0 | ||||||||||||||||||
1116 | header = tv->header(); | - | ||||||||||||||||||
1117 | #endif | - | ||||||||||||||||||
1118 | } never executed: end of block | 0 | ||||||||||||||||||
1119 | if (!header)
| 0 | ||||||||||||||||||
1120 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
1121 | QPoint zero = header->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
1122 | int sectionSize = header->sectionSize(index); | - | ||||||||||||||||||
1123 | int sectionPos = header->sectionPosition(index); | - | ||||||||||||||||||
1124 | return orientation == Qt::Horizontal never executed: return orientation == Qt::Horizontal ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height()) : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize);
| 0 | ||||||||||||||||||
1125 | ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height()) never executed: return orientation == Qt::Horizontal ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height()) : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize); | 0 | ||||||||||||||||||
1126 | : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize); never executed: return orientation == Qt::Horizontal ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height()) : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize); | 0 | ||||||||||||||||||
1127 | } | - | ||||||||||||||||||
1128 | - | |||||||||||||||||||
1129 | QString QAccessibleTableHeaderCell::text(QAccessible::Text t) const | - | ||||||||||||||||||
1130 | { | - | ||||||||||||||||||
1131 | QAbstractItemModel *model = view->model(); | - | ||||||||||||||||||
1132 | QString value; | - | ||||||||||||||||||
1133 | switch (t) { | - | ||||||||||||||||||
1134 | case QAccessible::Name: never executed: case QAccessible::Name: | 0 | ||||||||||||||||||
1135 | value = model->headerData(index, orientation, Qt::AccessibleTextRole).toString(); | - | ||||||||||||||||||
1136 | if (value.isEmpty())
| 0 | ||||||||||||||||||
1137 | value = model->headerData(index, orientation, Qt::DisplayRole).toString(); never executed: value = model->headerData(index, orientation, Qt::DisplayRole).toString(); | 0 | ||||||||||||||||||
1138 | break; never executed: break; | 0 | ||||||||||||||||||
1139 | case QAccessible::Description: never executed: case QAccessible::Description: | 0 | ||||||||||||||||||
1140 | value = model->headerData(index, orientation, Qt::AccessibleDescriptionRole).toString(); | - | ||||||||||||||||||
1141 | break; never executed: break; | 0 | ||||||||||||||||||
1142 | default: never executed: default: | 0 | ||||||||||||||||||
1143 | break; never executed: break; | 0 | ||||||||||||||||||
1144 | } | - | ||||||||||||||||||
1145 | return value; never executed: return value; | 0 | ||||||||||||||||||
1146 | } | - | ||||||||||||||||||
1147 | - | |||||||||||||||||||
1148 | void QAccessibleTableHeaderCell::setText(QAccessible::Text, const QString &) | - | ||||||||||||||||||
1149 | { | - | ||||||||||||||||||
1150 | return; never executed: return; | 0 | ||||||||||||||||||
1151 | } | - | ||||||||||||||||||
1152 | - | |||||||||||||||||||
1153 | bool QAccessibleTableHeaderCell::isValid() const | - | ||||||||||||||||||
1154 | { | - | ||||||||||||||||||
1155 | return view && view->model() && (index >= 0) never executed: return view && view->model() && (index >= 0) && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount()));
| 0 | ||||||||||||||||||
1156 | && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount())); never executed: return view && view->model() && (index >= 0) && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount()));
| 0 | ||||||||||||||||||
1157 | } | - | ||||||||||||||||||
1158 | - | |||||||||||||||||||
1159 | QAccessibleInterface *QAccessibleTableHeaderCell::parent() const | - | ||||||||||||||||||
1160 | { | - | ||||||||||||||||||
1161 | return QAccessible::queryAccessibleInterface(view); never executed: return QAccessible::queryAccessibleInterface(view); | 0 | ||||||||||||||||||
1162 | } | - | ||||||||||||||||||
1163 | - | |||||||||||||||||||
1164 | QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const | - | ||||||||||||||||||
1165 | { | - | ||||||||||||||||||
1166 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
1167 | } | - | ||||||||||||||||||
1168 | - | |||||||||||||||||||
1169 | QHeaderView *QAccessibleTableHeaderCell::headerView() const | - | ||||||||||||||||||
1170 | { | - | ||||||||||||||||||
1171 | QHeaderView *header = 0; | - | ||||||||||||||||||
1172 | if (false) { dead code: { } | - | ||||||||||||||||||
1173 | #ifndef QT_NO_TABLEVIEW dead code: { } | - | ||||||||||||||||||
1174 | } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
dead code: { } | - | ||||||||||||||||||
1175 | if (orientation == Qt::Horizontal) {
| 0 | ||||||||||||||||||
1176 | header = tv->horizontalHeader(); | - | ||||||||||||||||||
1177 | } else { never executed: end of block | 0 | ||||||||||||||||||
1178 | header = tv->verticalHeader(); | - | ||||||||||||||||||
1179 | } never executed: end of block | 0 | ||||||||||||||||||
1180 | #endif | - | ||||||||||||||||||
1181 | #ifndef QT_NO_TREEVIEW | - | ||||||||||||||||||
1182 | } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
| 0 | ||||||||||||||||||
1183 | header = tv->header(); | - | ||||||||||||||||||
1184 | #endif | - | ||||||||||||||||||
1185 | } never executed: end of block | 0 | ||||||||||||||||||
1186 | return header; never executed: return header; | 0 | ||||||||||||||||||
1187 | } | - | ||||||||||||||||||
1188 | - | |||||||||||||||||||
1189 | #endif // QT_NO_ITEMVIEWS | - | ||||||||||||||||||
1190 | - | |||||||||||||||||||
1191 | QT_END_NAMESPACE | - | ||||||||||||||||||
1192 | - | |||||||||||||||||||
1193 | #endif // QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |