+void DolphinView::selectAll()
+{
+ QAbstractItemView* view = m_viewAccessor.itemView();
+ // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
+ // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
+ // selection instead of selecting all items. This is bypassed for KDE 4.0
+ // by invoking clearSelection() first.
+ view->clearSelection();
+ view->selectAll();
+}
+
+void DolphinView::invertSelection()
+{
+ QItemSelectionModel* selectionModel = m_viewAccessor.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);
+
+ const QItemSelection selection(topLeft, bottomRight);
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+}
+
+void DolphinView::clearSelection()
+{
+ QItemSelectionModel* selModel = m_viewAccessor.itemView()->selectionModel();
+ const QModelIndex currentIndex = selModel->currentIndex();
+ selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current |
+ QItemSelectionModel::Clear);
+ m_selectedItems.clear();
+}
+