applets/kicker: store the first char in `firstChar`

wilder-5.26
Fushan Wen 4 years ago
parent 93f70563d8
commit 9e2b393867
No known key found for this signature in database
GPG Key ID: 2E48D1487C91DCAA
  1. 9
      applets/kicker/plugin/appentry.cpp

@ -52,10 +52,13 @@ QString groupName(const QString &name)
if (name.isEmpty()) { if (name.isEmpty()) {
return QString(); return QString();
} }
const QChar firstChar = name[0];
// Here we will apply a locale based strategy for the first character. // Here we will apply a locale based strategy for the first character.
// If first character is hangul, run decomposition and return the choseong (consonants). // If first character is hangul, run decomposition and return the choseong (consonants).
if (name[0].script() == QChar::Script_Hangul) { if (firstChar.script() == QChar::Script_Hangul) {
auto decomposed = name[0].decomposition(); auto decomposed = firstChar.decomposition();
if (decomposed.isEmpty()) { if (decomposed.isEmpty()) {
return name.left(1); return name.left(1);
} }
@ -66,7 +69,7 @@ QString groupName(const QString &name)
// 1. it does not make much sense to have every different Kanji to have a different group. // 1. it does not make much sense to have every different Kanji to have a different group.
// 2. ICU transliterator can't yet convert Kanji to Hiragana. // 2. ICU transliterator can't yet convert Kanji to Hiragana.
// https://unicode-org.atlassian.net/browse/ICU-5874 // https://unicode-org.atlassian.net/browse/ICU-5874
if (name[0].script() == QChar::Script_Han) { if (firstChar.script() == QChar::Script_Han) {
// Unicode Han // Unicode Han
return QString::fromUtf8("\xe6\xbc\xa2"); return QString::fromUtf8("\xe6\xbc\xa2");
} }

Loading…
Cancel
Save