| 266 | } |
| 267 | |
| 268 | bool AccessibleInstanceView::unselectRow(int row) |
| 269 | { |
| 270 | if (!view()->model() || !view()->selectionModel()) { |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | QModelIndex index = view()->model()->index(row, 0, view()->rootIndex()); |
| 275 | if (!index.isValid()) { |
| 276 | return false; |
| 277 | } |
| 278 | |
| 279 | QItemSelection selection(index, index); |
| 280 | auto selectionModel = view()->selectionModel(); |
| 281 | |
| 282 | switch (const auto selectionType = view()->selectionMode()) { |
| 283 | case QAbstractItemView::SingleSelection: |
| 284 | // no unselect |
| 285 | if (selectedRowCount() == 1) { |
| 286 | return false; |
| 287 | } |
| 288 | break; |
| 289 | case QAbstractItemView::ContiguousSelection: { |
| 290 | // no unselect |
| 291 | if (selectedRowCount() == 1) { |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | if ((!row || selectionModel->isRowSelected(row - 1, view()->rootIndex())) && selectionModel->isRowSelected(row + 1, view()->rootIndex())) { |
| 297 | //If there are rows selected both up the current row and down the current rown, |
| 298 | //the ones which are down the current row will be deselected |
| 299 | selection = QItemSelection(index, view()->model()->index(rowCount() - 1, 0, view()->rootIndex())); |
| 300 | } |
| 301 | break; |
| 302 | } |
| 303 | case QAbstractItemView::NoSelection: |
| 304 | break; |
| 305 | default: { |
| 306 | // FIXME: See if MultiSelection / ExtendedSelection need to be handled |
| 307 | qWarning() << "Unhandled QAbstractItemView selection type!" << selectionType; |
| 308 | break; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | selectionModel->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); |
| 313 | return true; |
| 314 | } |
| 315 | |
| 316 | bool AccessibleInstanceView::unselectColumn(int column) |
| 317 | { |
no test coverage detected