mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Merge remote-tracking branch 'origin/KDE/4.10'
Conflicts: plasma/applets/folderview/folderview.cpp
This commit is contained in:
commit
8cc479518b
|
@ -35,6 +35,9 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// #define KFILEITEMMODEL_DEBUG
|
// #define KFILEITEMMODEL_DEBUG
|
||||||
|
|
||||||
KFileItemModel::KFileItemModel(QObject* parent) :
|
KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
|
@ -1556,6 +1559,11 @@ bool KFileItemModel::useMaximumUpdateInterval() const
|
||||||
return !m_dirLister->url().isLocalFile();
|
return !m_dirLister->url().isLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool localeAwareLessThan(const QChar& c1, const QChar& c2)
|
||||||
|
{
|
||||||
|
return QString::localeAwareCompare(c1, c2) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_itemData.isEmpty());
|
Q_ASSERT(!m_itemData.isEmpty());
|
||||||
|
@ -1565,7 +1573,6 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
||||||
|
|
||||||
QString groupValue;
|
QString groupValue;
|
||||||
QChar firstChar;
|
QChar firstChar;
|
||||||
bool isLetter = false;
|
|
||||||
for (int i = 0; i <= maxIndex; ++i) {
|
for (int i = 0; i <= maxIndex; ++i) {
|
||||||
if (isChildItem(i)) {
|
if (isChildItem(i)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1581,31 +1588,31 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
||||||
|
|
||||||
if (firstChar != newFirstChar) {
|
if (firstChar != newFirstChar) {
|
||||||
QString newGroupValue;
|
QString newGroupValue;
|
||||||
if (newFirstChar >= QLatin1Char('A') && newFirstChar <= QLatin1Char('Z')) {
|
if (newFirstChar.isLetter()) {
|
||||||
// Apply group 'A' - 'Z'
|
// Try to find a matching group in the range 'A' to 'Z'.
|
||||||
newGroupValue = newFirstChar;
|
static std::vector<QChar> lettersAtoZ;
|
||||||
isLetter = true;
|
if (lettersAtoZ.empty()) {
|
||||||
|
for (char c = 'A'; c <= 'Z'; ++c) {
|
||||||
|
lettersAtoZ.push_back(QLatin1Char(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan);
|
||||||
|
if (it != lettersAtoZ.end()) {
|
||||||
|
if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) {
|
||||||
|
// newFirstChar belongs to the group preceding *it.
|
||||||
|
// Example: for an umlaut 'A' in the German locale, *it would be 'B' now.
|
||||||
|
--it;
|
||||||
|
}
|
||||||
|
newGroupValue = *it;
|
||||||
|
} else {
|
||||||
|
newGroupValue = newFirstChar;
|
||||||
|
}
|
||||||
} else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) {
|
} else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) {
|
||||||
// Apply group '0 - 9' for any name that starts with a digit
|
// Apply group '0 - 9' for any name that starts with a digit
|
||||||
newGroupValue = i18nc("@title:group Groups that start with a digit", "0 - 9");
|
newGroupValue = i18nc("@title:group Groups that start with a digit", "0 - 9");
|
||||||
isLetter = false;
|
|
||||||
} else {
|
} else {
|
||||||
if (isLetter) {
|
|
||||||
// If the current group is 'A' - 'Z' check whether a locale character
|
|
||||||
// fits into the existing group.
|
|
||||||
// TODO: This does not work in the case if e.g. the group 'O' starts with
|
|
||||||
// an umlaut 'O' -> provide unit-test to document this known issue
|
|
||||||
const QChar prevChar(firstChar.unicode() - ushort(1));
|
|
||||||
const QChar nextChar(firstChar.unicode() + ushort(1));
|
|
||||||
const QString currChar(newFirstChar);
|
|
||||||
const bool partOfCurrentGroup = currChar.localeAwareCompare(prevChar) > 0 &&
|
|
||||||
currChar.localeAwareCompare(nextChar) < 0;
|
|
||||||
if (partOfCurrentGroup) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newGroupValue = i18nc("@title:group", "Others");
|
newGroupValue = i18nc("@title:group", "Others");
|
||||||
isLetter = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newGroupValue != groupValue) {
|
if (newGroupValue != groupValue) {
|
||||||
|
|
|
@ -996,7 +996,7 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(const KFileItem& item, Resol
|
||||||
const bool resolveAll = (hint == ResolveAll);
|
const bool resolveAll = (hint == ResolveAll);
|
||||||
|
|
||||||
bool mimeTypeChanged = false;
|
bool mimeTypeChanged = false;
|
||||||
if (!item.isMimeTypeKnown()) {
|
if (!item.isMimeTypeKnown() || !item.isFinalIconKnown()) {
|
||||||
item.determineMimeType();
|
item.determineMimeType();
|
||||||
mimeTypeChanged = true;
|
mimeTypeChanged = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue