| 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 (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 | if ((!row || selectionModel->isRowSelected(row - 1, view()->rootIndex())) && |
| 296 | 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 | } |
| 302 | default: { |
| 303 | break; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | selectionModel->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); |
| 308 | return true; |
| 309 | } |
| 310 | |
| 311 | bool AccessibleInstanceView::unselectColumn(int column) |
| 312 | { |
no test coverage detected