Commit 2e9466db authored by Rafael Fernández López's avatar Rafael Fernández López
Browse files

Ideal behavior when showing hidden files. Hooah !

svn path=/trunk/KDE/kdebase/apps/; revision=676752
parent a888403f
......@@ -84,12 +84,12 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
retString = data.toString().toUpper().at(0);
else if (item->isHidden() && data.toString().at(0) == '.' &&
data.toString().at(1).isLetter())
retString = i18n(".%1 (Hidden)", data.toString().toUpper().at(1));
retString = data.toString().toUpper().at(1);
else if (item->isHidden() && data.toString().at(0) == '.' &&
!data.toString().at(1).isLetter())
retString = i18n("Others (Hidden)");
retString = i18n("Others");
else if (item->isHidden() && data.toString().at(0) != '.')
retString = i18n("%1 (Hidden)", data.toString().toUpper().at(0));
retString = data.toString().toUpper().at(0);
else if (item->isHidden())
retString = data.toString().toUpper().at(0);
else
......@@ -98,22 +98,14 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
break;
case DolphinView::SortBySize:
int fileSize = (item) ? item->size() : -1;
if (item && item->isDir() && !item->isHidden()) {
if (item && item->isDir()) {
retString = i18n("Folders");
} else if (fileSize < 5242880 && !item->isHidden()) {
} else if (fileSize < 5242880) {
retString = i18n("Small");
} else if (fileSize < 10485760 && !item->isHidden()) {
} else if (fileSize < 10485760) {
retString = i18n("Medium");
} else if (!item->isHidden()){
} else {
retString = i18n("Big");
} else if (item && item->isDir() && item->isHidden()) {
retString = i18n("Folders (Hidden)");
} else if (fileSize < 5242880 && item->isHidden()) {
retString = i18n("Small (Hidden)");
} else if (fileSize < 10485760 && item->isHidden()) {
retString = i18n("Medium (Hidden)");
} else if (item->isHidden()){
retString = i18n("Big (Hidden)");
}
break;
}
......
......@@ -125,27 +125,14 @@ bool DolphinSortFilterProxyModel::lessThanGeneralPurpose(const QModelIndex &left
const QVariant leftData = dirModel->data(left, sortRole());
const QVariant rightData = dirModel->data(right, sortRole());
// Give preference to hidden items. They will be shown above regular
// items
if (leftFileItem->isHidden() && !rightFileItem->isHidden())
return true;
else if (!leftFileItem->isHidden() && rightFileItem->isHidden())
return false;
QString leftStr = leftData.toString();
QString rightStr = rightData.toString();
// If we are handling two items of the same preference, just take in
// count their names. There is no need to check for case sensitivity
// here, since this is the method that explores for new categories
return leftData.toString().toLower() < rightData.toString().toLower();
// We don't care about case for building categories
return naturalCompare(leftStr.toLower(), rightStr.toLower()) < 0;
}
else if (sortRole() == DolphinView::SortBySize) // If we are sorting by size
{
// Give preference to hidden items. They will be shown above regular
// items
if (leftFileItem->isHidden() && !rightFileItem->isHidden())
return true;
else if (!leftFileItem->isHidden() && rightFileItem->isHidden())
return false;
// If we are sorting by size, show folders first. We will sort them
// correctly later
if (leftFileItem->isDir() && !rightFileItem->isDir())
......@@ -188,17 +175,19 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
}
// So we are in the same priority, what counts now is their names
const QString leftStr = leftData.toString();
const QString rightStr = rightData.toString();
QString leftStr = leftData.toString();
QString rightStr = rightData.toString();
leftStr = leftStr.at(0) == '.' ? leftStr.mid(1) : leftStr;
rightStr = rightStr.at(0) == '.' ? rightStr.mid(1) : rightStr;
return sortCaseSensitivity() ? (naturalCompare(leftStr, rightStr) < 0) :
(naturalCompare(leftStr.toLower(), rightStr.toLower()) < 0);
}
}
else if (sortRole() == DolphinView::SortBySize) { // If we are sorting by size
// Priority: hidden > folders > regular files. If an item is
// hidden (doesn't matter if file or folder) will have higher
// preference than a non-hidden item
// 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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment