+ if (isColumnViewActive()) {
+ // In opposite to QAbstractItemView::selectAll() there is no virtual method
+ // for adjusting the invertion of a selection. As the generic approach by using
+ // the selection model does not work for the column view, we delegate this task:
+ m_columnView->invertSelection();
+ } else {
+ QItemSelectionModel* selectionModel = itemView()->selectionModel();
+ const QAbstractItemModel* itemModel = selectionModel->model();
+
+ const QModelIndex topLeft = itemModel->index(0, 0);
+ const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+ itemModel->columnCount() - 1);
+
+ QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+ }