Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/kfileitemmodel.cpp
Context not available. | |||||
1905 | if (firstChar != newFirstChar) { | 1905 | if (firstChar != newFirstChar) { | ||
---|---|---|---|---|---|
1906 | QString newGroupValue; | 1906 | QString newGroupValue; | ||
1907 | if (newFirstChar.isLetter()) { | 1907 | if (newFirstChar.isLetter()) { | ||
1908 | // Try to find a matching group in the range 'A' to 'Z'. | 1908 | // Put together compatibility equivalent letters like latin 'A' and umlaut 'A' from the German locale | ||
1909 | static std::vector<QChar> lettersAtoZ; | 1909 | newGroupValue = QString(newFirstChar).normalized(QString::NormalizationForm_KD).at(0); | ||
1910 | lettersAtoZ.reserve('Z' - 'A' + 1); | | |||
1911 | if (lettersAtoZ.empty()) { | | |||
1912 | for (char c = 'A'; c <= 'Z'; ++c) { | | |||
1913 | lettersAtoZ.push_back(QLatin1Char(c)); | | |||
1914 | } | | |||
1915 | } | | |||
1916 | | ||||
1917 | auto localeAwareLessThan = [this](QChar c1, QChar c2) -> bool { | | |||
1918 | return m_collator.compare(c1, c2) < 0; | | |||
1919 | }; | | |||
1920 | | ||||
1921 | std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan); | | |||
1922 | if (it != lettersAtoZ.end()) { | | |||
1923 | if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) { | | |||
1924 | // newFirstChar belongs to the group preceding *it. | | |||
1925 | // Example: for an umlaut 'A' in the German locale, *it would be 'B' now. | | |||
1926 | --it; | | |||
1927 | } | | |||
1928 | newGroupValue = *it; | | |||
1929 | } else { | | |||
1930 | newGroupValue = newFirstChar; | | |||
1931 | } | | |||
1932 | } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) { | 1910 | } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) { | ||
1933 | // Apply group '0 - 9' for any name that starts with a digit | 1911 | // Apply group '0 - 9' for any name that starts with a digit | ||
1934 | newGroupValue = i18nc("@title:group Groups that start with a digit", "0 - 9"); | 1912 | newGroupValue = i18nc("@title:group Groups that start with a digit", "0 - 9"); | ||
Context not available. |