]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix name grouping feature for cyrillic names
authorAndrey Yashkin <andreyyashkin@gmail.com>
Sun, 28 Jul 2019 15:06:12 +0000 (17:06 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 28 Jul 2019 15:07:05 +0000 (17:07 +0200)
Summary:
All files and folders with cyrillic names are placed in latin 'A' group. This patch fixes this issue.

BUG: 406867
FIXED-IN: 19.11.80

Test Plan:
Make grouping by name in the dir with cyrillic files or dirs in it.
See screenshots below.
Before {F6985465}
After {F6985459}

Reviewers: #dolphin, ngraham, cfeck, elvisangelaccio

Reviewed By: #dolphin, ngraham, elvisangelaccio

Subscribers: hein, cfeck, ngraham, elvisangelaccio, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D22303

src/kitemviews/kfileitemmodel.cpp

index 8145a00f11ba1f2fc22bd9f7aca0679c3ddfdfdb..3cc140701634770d1d82d4d5d21de17a0d60babe 100644 (file)
@@ -1905,30 +1905,8 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
         if (firstChar != newFirstChar) {
             QString newGroupValue;
             if (newFirstChar.isLetter()) {
-                // Try to find a matching group in the range 'A' to 'Z'.
-                static std::vector<QChar> lettersAtoZ;
-                lettersAtoZ.reserve('Z' - 'A' + 1);
-                if (lettersAtoZ.empty()) {
-                    for (char c = 'A'; c <= 'Z'; ++c) {
-                        lettersAtoZ.push_back(QLatin1Char(c));
-                    }
-                }
-
-                auto localeAwareLessThan = [this](QChar c1, QChar c2) -> bool {
-                    return m_collator.compare(c1, c2) < 0;
-                };
-
-                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;
-                }
+                // Put together compatibility equivalent letters like latin 'A' and umlaut 'A' from the German locale
+                newGroupValue = QString(newFirstChar).normalized(QString::NormalizationForm_KD).at(0);
             } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) {
                 // Apply group '0 - 9' for any name that starts with a digit
                 newGroupValue = i18nc("@title:group Groups that start with a digit", "0 - 9");