X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/3bf8fa5901f200d26acc2eb527eef88087e6edb9..93f8093b661d6cd8db6dd747fbdfe38ebd38294b:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 91a41b531..a85e2db9b 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -252,15 +252,24 @@ void DolphinView::selectAll() void DolphinView::invertSelection() { - QItemSelectionModel* selectionModel = itemView()->selectionModel(); - const QAbstractItemModel* itemModel = selectionModel->model(); + if (isColumnViewActive()) { + // QAbstractItemView does not offer a virtual method invertSelection() + // as counterpart to QAbstractItemView::selectAll(). This makes it + // necessary to delegate the inverting of the selection to the + // column view, as only the selection of the active column should get + // inverted. + 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); + 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); + const QItemSelection selection(topLeft, bottomRight); + selectionModel->select(selection, QItemSelectionModel::Toggle); + } } bool DolphinView::hasSelection() const @@ -414,8 +423,7 @@ void DolphinView::updateView(const KUrl& url, const KUrl& rootUrl) return; } - const bool restoreColumnView = !isColumnViewActive() - && !rootUrl.isEmpty() + const bool restoreColumnView = !rootUrl.isEmpty() && !rootUrl.equals(url, KUrl::CompareWithoutTrailingSlash) && rootUrl.isParentOf(url);