MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / unselectRow

Method unselectRow

launcher/ui/instanceview/AccessibleInstanceView.cpp:268–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268bool 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
311bool AccessibleInstanceView::unselectColumn(int column)
312{

Callers 1

unselectCellMethod · 0.80

Calls 5

QItemSelectionClass · 0.85
modelMethod · 0.80
isRowSelectedMethod · 0.80
indexMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected