┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-06-18 10:39:02 +0000
committerRafael Fernández López <[email protected]>2007-06-18 10:39:02 +0000
commit55a876af21f67dfd5d57a92633f2dd3a2b5dc5ca (patch)
tree3d66099176e32cb5186d5b19c64b656f6d0e2bd1 /src
parent20aedc53294376e05b79da5ea775f740b7a1aa49 (diff)
First show folders when sorting by type, then sort categories alphabetically. Yeah !
svn path=/trunk/KDE/kdebase/apps/; revision=677030
Diffstat (limited to 'src')
-rw-r--r--src/dolphinsortfilterproxymodel.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/dolphinsortfilterproxymodel.cpp b/src/dolphinsortfilterproxymodel.cpp
index 04294b9c2..103928b21 100644
--- a/src/dolphinsortfilterproxymodel.cpp
+++ b/src/dolphinsortfilterproxymodel.cpp
@@ -143,8 +143,15 @@ bool DolphinSortFilterProxyModel::lessThanGeneralPurpose(const QModelIndex &left
}
else if (sortRole() == KDirModel::Type)
{
- return naturalCompare(leftFileItem->mimetype().toLower(),
- rightFileItem->mimetype().toLower()) < 0;
+ // If we are sorting by size, show folders first. We will sort them
+ // correctly later
+ if (leftFileItem->isDir() && !rightFileItem->isDir())
+ return true;
+ else if (!leftFileItem->isDir() && rightFileItem->isDir())
+ return false;
+
+ return naturalCompare(leftFileItem->mimeComment().toLower(),
+ rightFileItem->mimeComment().toLower()) < 0;
}
}
@@ -249,6 +256,23 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
}
else if (sortRole() == KDirModel::Type)
{
+ // If an item is hidden (doesn't matter if file or folder) will have
+ // higher preference than a non-hidden item
+ if (leftFileItem->isHidden() && !rightFileItem->isHidden()) {
+ return true;
+ }
+ else if (!leftFileItem->isHidden() && rightFileItem->isHidden()) {
+ return false;
+ }
+
+ // On our priority, folders go above regular files
+ if (leftFileItem->isDir() && !rightFileItem->isDir()) {
+ return true;
+ }
+ else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
+ return false;
+ }
+
if (leftFileItem->mimetype() == rightFileItem->mimetype())
{
const QString leftStr = dirModel->data(left, KDirModel::Name).toString();