]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Implement DolphinView::sorting()
authorFrank Reininghaus <frank78ac@googlemail.com>
Sat, 17 Sep 2011 15:49:20 +0000 (17:49 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sat, 17 Sep 2011 20:51:57 +0000 (22:51 +0200)
This fixes the problem that changing the sorting criterion
from 'Name' to 'Date' and then back to 'Name' doesn't work.

src/views/dolphinview.cpp
src/views/dolphinview.h

index cdcb9f7cbba5bb2e48ba25ee2c832748a2ac8b6f..11fe17ac56f4f23b7a0bbff0d66fe1135918a890 100644 (file)
@@ -358,8 +358,8 @@ void DolphinView::setSorting(Sorting sorting)
 
 DolphinView::Sorting DolphinView::sorting() const
 {
-    return DolphinView::SortByName;
-    //return m_viewAccessor.proxyModel()->sorting();
+    KItemModelBase* model = m_container->controller()->model();
+    return sortingForSortRole(model->sortRole());
 }
 
 void DolphinView::setSortOrder(Qt::SortOrder order)
@@ -1283,4 +1283,21 @@ QByteArray DolphinView::sortRoleForSorting(Sorting sorting) const
     return QByteArray();
 }
 
+DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole) const
+{
+    static QHash<QByteArray, DolphinView::Sorting> sortHash;
+    if (sortHash.isEmpty()) {
+        sortHash.insert("name", SortByName);
+        sortHash.insert("size", SortBySize);
+        sortHash.insert("date", SortByDate);
+        sortHash.insert("permissions", SortByPermissions);
+        sortHash.insert("owner", SortByOwner);
+        sortHash.insert("group", SortByGroup);
+        sortHash.insert("type", SortByType);
+        sortHash.insert("destination", SortByDestination);
+        sortHash.insert("path", SortByPath);
+    }
+    return sortHash.value(sortRole);
+}
+
 #include "dolphinview.moc"
index 8d10942733cec7f8996663ec8095f3bca765dee7..cc2e25b495538fb6e7e49a7cdc091d471c6de995 100644 (file)
@@ -736,6 +736,7 @@ private:
     void updateWritableState();
 
     QByteArray sortRoleForSorting(Sorting sorting) const;
+    Sorting sortingForSortRole(const QByteArray& sortRole) const;
 
 private:
     bool m_active : 1;