QTranslator: fix narrowing conversion warnings -Wshorten-64-to-32

Change-Id: I50a49c3be2f22e6ad0714455e7a5bdc1d2b52f3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2024-10-10 16:19:11 +03:00
parent 06615a7cb8
commit 4754f0611d

View File

@ -477,9 +477,9 @@ bool QTranslator::load(const QString & filename, const QString & directory,
if (fi.isReadable() && fi.isFile())
break;
int rightmost = 0;
for (int i = 0; i < (int)delims.size(); i++) {
int k = fname.lastIndexOf(delims[i]);
qsizetype rightmost = 0;
for (auto ch : delims) {
qsizetype k = fname.lastIndexOf(ch);
if (k > rightmost)
rightmost = k;
}
@ -628,7 +628,7 @@ static QString find_translation(const QLocale & locale,
QString realname;
realname += path + filename + prefix; // using += in the hope for some reserve capacity
const int realNameBaseSize = realname.size();
const qsizetype realNameBaseSize = realname.size();
// see http://www.unicode.org/reports/tr35/#LanguageMatching for inspiration
@ -641,7 +641,7 @@ static QString find_translation(const QLocale & locale,
// Windows (in other words: this codepath is *not* UNIX-only).
QStringList languages = locale.uiLanguages(QLocale::TagSeparator::Underscore);
qCDebug(lcTranslator) << "Requested UI languages" << languages;
for (int i = languages.size() - 1; i >= 0; --i) {
for (qsizetype i = languages.size() - 1; i >= 0; --i) {
const QString &lang = languages.at(i);
QString lowerLang = lang.toLower();
if (lang != lowerLang)
@ -662,14 +662,14 @@ static QString find_translation(const QLocale & locale,
realname.truncate(realNameBaseSize);
int rightmost = localeName.lastIndexOf(u'_');
qsizetype rightmost = localeName.lastIndexOf(u'_');
if (rightmost <= 0)
break; // no truncations anymore, break
localeName.truncate(rightmost);
}
}
const int realNameBaseSizeFallbacks = path.size() + filename.size();
const qsizetype realNameBaseSizeFallbacks = path.size() + filename.size();
// realname == path + filename + prefix;
if (!suffix.isNull()) {