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 | | ||
1909 | static std::vector<QChar> lettersAtoZ; | 1909 | if(m_collator.compare(newFirstChar, QChar(QLatin1Char('A'))) >=0 && m_collator.compare(newFirstChar, QChar(QLatin1Char('Z'))) <= 0) | ||
1910 | lettersAtoZ.reserve('Z' - 'A' + 1); | 1910 | { | ||
1911 | if (lettersAtoZ.empty()) { | 1911 | // WARNING! Symbols based on latin 'Z' like 'Z' with acute are treated wrong as non Latin and put in a new group. | ||
1912 | for (char c = 'A'; c <= 'Z'; ++c) { | 1912 | | ||
1913 | lettersAtoZ.push_back(QLatin1Char(c)); | 1913 | // Try to find a matching group in the range 'A' to 'Z'. | ||
1914 | static std::vector<QChar> lettersAtoZ; | ||||
1915 | lettersAtoZ.reserve('Z' - 'A' + 1); | ||||
1916 | if (lettersAtoZ.empty()) { | ||||
1917 | for (char c = 'A'; c <= 'Z'; ++c) { | ||||
1918 | lettersAtoZ.push_back(QLatin1Char(c)); | ||||
1919 | } | ||||
1914 | } | 1920 | } | ||
1915 | } | | |||
1916 | 1921 | | |||
1917 | auto localeAwareLessThan = [this](QChar c1, QChar c2) -> bool { | 1922 | auto localeAwareLessThan = [this](QChar c1, QChar c2) -> bool { | ||
1918 | return m_collator.compare(c1, c2) < 0; | 1923 | return m_collator.compare(c1, c2) < 0; | ||
1919 | }; | 1924 | }; | ||
1920 | 1925 | | |||
1921 | std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan); | 1926 | std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan); | ||
1922 | if (it != lettersAtoZ.end()) { | 1927 | if (it != lettersAtoZ.end()) { | ||
1923 | if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) { | 1928 | if (localeAwareLessThan(newFirstChar, *it)) { | ||
1924 | // newFirstChar belongs to the group preceding *it. | 1929 | // newFirstChar belongs to the group preceding *it. | ||
1925 | // Example: for an umlaut 'A' in the German locale, *it would be 'B' now. | 1930 | // Example: for an umlaut 'A' in the German locale, *it would be 'B' now. | ||
1926 | --it; | 1931 | --it; | ||
1932 | } | ||||
1933 | newGroupValue = *it; | ||||
1927 | } | 1934 | } | ||
1928 | newGroupValue = *it; | 1935 | | ||
1929 | } else { | 1936 | } else { | ||
1937 | // Characters from non Latin-based scripts | ||||
1930 | newGroupValue = newFirstChar; | 1938 | newGroupValue = newFirstChar; | ||
1931 | } | 1939 | } | ||
1932 | } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) { | 1940 | } else if (newFirstChar >= QLatin1Char('0') && newFirstChar <= QLatin1Char('9')) { | ||
Context not available. |