From 0111d9b0a02098065a32b34c9b04fde72addb626 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Mon, 6 Aug 2007 06:56:36 +0000 Subject: Fixed 'Select All' and 'Invert Selection' for the column view (only the items of the currently active column will be selected, not the whole tree). The current implementation is quite slow, but this will be fixed later. svn path=/trunk/KDE/kdebase/apps/; revision=696893 --- src/dolphinview.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/dolphinview.cpp') diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 7fc727475..a9f160d00 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -269,12 +269,27 @@ bool DolphinView::supportsCategorizedSorting() const void DolphinView::selectAll() { - selectAll(QItemSelectionModel::Select); + itemView()->selectAll(); } void DolphinView::invertSelection() { - selectAll(QItemSelectionModel::Toggle); + 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); + } } bool DolphinView::hasSelection() const @@ -878,19 +893,6 @@ void DolphinView::createView() this, SLOT(emitContentsMoved())); } -void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags) -{ - 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, flags); -} - QAbstractItemView* DolphinView::itemView() const { if (m_detailsView != 0) { -- cgit v1.3