MCPcopy Create free account
hub / github.com/MultiMC/Launcher / unselectColumn

Method unselectColumn

launcher/ui/instanceview/AccessibleInstanceView.cpp:311–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311bool AccessibleInstanceView::unselectColumn(int column)
312{
313 auto model = view()->model();
314 if (!model || !view()->selectionModel()) {
315 return false;
316 }
317
318 QModelIndex index = model->index(0, column, view()->rootIndex());
319 if (!index.isValid()) {
320 return false;
321 }
322
323 QItemSelection selection(index, index);
324
325 switch (view()->selectionMode()) {
326 case QAbstractItemView::SingleSelection: {
327 //In SingleSelection and ContiguousSelection once an item
328 //is selected, there's no way for the user to unselect all items
329 if (selectedColumnCount() == 1) {
330 return false;
331 }
332 break;
333 }
334 case QAbstractItemView::ContiguousSelection:
335 if (selectedColumnCount() == 1) {
336 return false;
337 }
338
339 if ((!column || view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex()))
340 && view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) {
341 //If there are columns selected both at the left of the current row and at the right
342 //of the current row, the ones which are at the right will be deselected
343 selection = QItemSelection(index, model->index(0, columnCount() - 1, view()->rootIndex()));
344 }
345 default:
346 break;
347 }
348
349 view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Columns);
350 return true;
351}
352
353QAccessible::Role AccessibleInstanceView::role() const
354{

Callers 1

unselectCellMethod · 0.80

Calls 4

modelMethod · 0.80
isColumnSelectedMethod · 0.80
indexMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected