forked from qt-creator/qt-creator
Utils: Use range-based for in QrcParser
+ Avoid modifying the list while iterating it, and also avoid second scan. Change-Id: Idea74c338e24c300dbc3ca2e4f50797914cc5a1a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
890d96d63b
commit
a050ae84e2
@@ -551,18 +551,21 @@ const QStringList QrcParserPrivate::allUiLanguages(const QLocale *locale) const
|
||||
{
|
||||
if (!locale)
|
||||
return languages();
|
||||
QStringList langs = locale->uiLanguages();
|
||||
foreach (const QString &language, langs) { // qt4 support
|
||||
if (language.contains(QLatin1Char('_')) || language.contains(QLatin1Char('-'))) {
|
||||
QStringList splits = QString(language).replace(QLatin1Char('_'), QLatin1Char('-'))
|
||||
.split(QLatin1Char('-'));
|
||||
bool hasEmptyString = false;
|
||||
const QStringList langs = locale->uiLanguages();
|
||||
QStringList allLangs = langs;
|
||||
for (const QString &language : langs) {
|
||||
if (language.isEmpty())
|
||||
hasEmptyString = true;
|
||||
else if (language.contains('_') || language.contains('-')) {
|
||||
const QStringList splits = QString(language).replace('_', '-').split('-');
|
||||
if (splits.size() > 1 && !langs.contains(splits.at(0)))
|
||||
langs.append(splits.at(0));
|
||||
allLangs.append(splits.at(0));
|
||||
}
|
||||
}
|
||||
if (!langs.contains(QString()))
|
||||
langs.append(QString());
|
||||
return langs;
|
||||
if (!hasEmptyString)
|
||||
allLangs.append(QString());
|
||||
return allLangs;
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
Reference in New Issue
Block a user