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

Small fixes, but that have an impact of how things are visualized.

* Move "not tagged" elements to the end. We sort the rest (when they have tags), but keep untagged elements (the category) at the end of the view, since the user had
"less" interest on them.

* Break the law again of "dirs first". If we have on a folder only a tagged file (and is a file) and the rest are folders, that file goes first, since it was tagged.

* If we are on the same category, dirs go first. Here we make them citizens of first class.

* Commas instead of spaces when building categories for tags, they make it more readable and less error-prone (we can have tags "a", "dog" and "a dog" as tags, right?, 
so spaces here make the thing a bit hard to distinguish, I have two tags "a", "dog", or the tag "a dog") ;)

* Return an empty string when the item is not tagged at the method tagsForIndex. This way we always show untagged items the latest ones very easily (without nasty string 
checks). We will let the categorizer put a fancy name for them, if the returned string was empty.

CCMAIL: peter.penz@gmx.at

svn path=/trunk/KDE/kdebase/apps/; revision=679097
parent 80a0d665
......@@ -177,6 +177,10 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
case DolphinView::SortByTags: {
retString = DolphinSortFilterProxyModel::tagsForIndex(index);
if (retString.isEmpty())
retString = i18n("Not yet tagged");
break;
}
#endif
......
......@@ -176,6 +176,14 @@ bool DolphinSortFilterProxyModel::lessThanGeneralPurpose(const QModelIndex &left
return leftRating > rightRating;
}
case DolphinView::SortByTags: {
const QString leftTags = tagsForIndex(left);
const QString rightTags = tagsForIndex(right);
if (leftTags.isEmpty() && !rightTags.isEmpty())
return false;
else if (!leftTags.isEmpty() && rightTags.isEmpty())
return true;
return naturalCompare(tagsForIndex(left), tagsForIndex(right)) < 0;
}
#endif
......@@ -194,8 +202,9 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
const KFileItem* rightFileItem = dirModel->itemForIndex(right);
// If we are sorting by rating, folders and files are citizens of the same
// class
if (sortRole() != DolphinView::SortByRating)
// class. Same if we are sorting by tags.
if ((sortRole() != DolphinView::SortByRating) &&
(sortRole() != DolphinView::SortByTags))
{
// On our priority, folders go above regular files.
if (leftFileItem->isDir() && !rightFileItem->isDir()) {
......@@ -323,6 +332,11 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
if (leftRating == rightRating) {
// On our priority, folders go above regular files.
// This checks are needed (don't think it's the same doing it here
// than above). Here we make dirs citizens of first class because
// we know we are on the same category. On the check we do on the
// top of the method we don't know, so we remove that check when we
// are sorting by rating. (ereslibre)
if (leftFileItem->isDir() && !rightFileItem->isDir()) {
return true;
} else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
......@@ -338,7 +352,28 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
}
case DolphinView::SortByTags: {
return naturalCompare(tagsForIndex(left), tagsForIndex(right)) < 0;
const QString leftTags = tagsForIndex(left);
const QString rightTags = tagsForIndex(right);
if (leftTags == rightTags) {
// On our priority, folders go above regular files.
// This checks are needed (don't think it's the same doing it here
// than above). Here we make dirs citizens of first class because
// we know we are on the same category. On the check we do on the
// top of the method we don't know, so we remove that check when we
// are sorting by tags. (ereslibre)
if (leftFileItem->isDir() && !rightFileItem->isDir()) {
return true;
} else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
return false;
}
return sortCaseSensitivity() ?
(naturalCompare(leftFileItem->name(), rightFileItem->name()) < 0) :
(naturalCompare(leftFileItem->name().toLower(), rightFileItem->name().toLower()) < 0);
}
return naturalCompare(leftTags, rightTags) < 0;
}
#endif
}
......@@ -384,12 +419,11 @@ QString DolphinSortFilterProxyModel::tagsForIndex(const QModelIndex& index)
foreach (const QString& str, stringList) {
tagsString += str;
tagsString += ' ';
tagsString += ", ";
}
}
if (tagsString.isEmpty()) {
tagsString = i18n("(no tags)");
if (!tagsString.isEmpty())
tagsString.resize(tagsString.size() - 2);
}
return tagsString;
......
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