]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
Whenever we are trying to sort, bypass lessThanGeneralPurpose when is not allowed...
[dolphin.git] / src / dolphinview.cpp
index 91a41b531b664e53c74878c774da1441bf60cdc6..5f7fc11480b24117f0fb027641c0cebef931b4fe 100644 (file)
@@ -219,7 +219,12 @@ bool DolphinView::showHiddenFiles() const
 
 void DolphinView::setCategorizedSorting(bool categorized)
 {
-    if (!supportsCategorizedSorting() || (categorized == categorizedSorting())) {
+    if (categorized && !supportsCategorizedSorting()) {
+        setCategorizedSorting(false);
+        return;
+    }
+
+    if (categorized == categorizedSorting()) {
         return;
     }
 
@@ -252,15 +257,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 +428,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);