When calling arg() on a QString constructed from a literal, use QStringLiteral.

This commit is contained in:
Mat Sutcliffe
2018-12-20 21:32:39 +00:00
parent ace7650ebe
commit 6c05c5249d
99 changed files with 227 additions and 291 deletions

View File

@@ -31,8 +31,7 @@ namespace BlackMisc
QString CAircraftEngine::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
static const QString s("%1: %2");
return s.arg(m_number).arg(BlackMisc::boolToOnOff(m_on));
return QStringLiteral("%1: %2").arg(m_number).arg(BlackMisc::boolToOnOff(m_on));
}
} // namespace
} // namespace

View File

@@ -82,8 +82,7 @@ namespace BlackMisc
QString CAircraftIcaoCode::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
static const QString s("%1 %2 %3");
return s.arg(this->getDesignatorDbKey(), this->getCombinedType(), this->getWtc()).trimmed();
return QStringLiteral("%1 %2 %3").arg(this->getDesignatorDbKey(), this->getCombinedType(), this->getWtc()).trimmed();
}
void CAircraftIcaoCode::updateMissingParts(const CAircraftIcaoCode &otherIcaoCode)
@@ -143,8 +142,7 @@ namespace BlackMisc
score += 50; // same designator
if (log)
{
static const QString s("Same designator: %1");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Same designator: %1").arg(score));
}
int scoreOld = score;
@@ -153,30 +151,27 @@ namespace BlackMisc
else if (this->getRank() < 10) { score += (10 - this->getRank()); }
if (score > scoreOld)
{
static const QString s("Added rank: %1");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Added rank: %1").arg(score));
}
}
else
{
if (this->hasFamily() && this->getFamily() == otherCode.getFamily())
{
static const QString s("Added family: %1");
score += 30;
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Added family: %1").arg(score));
}
else if (this->hasValidCombinedType() && otherCode.getCombinedType() == this->getCombinedType())
{
static const QString s("Added combined code: %1");
score += 20;
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Added combined code: %1").arg(score));
}
else if (this->hasValidCombinedType())
{
if (this->getEnginesCount() == otherCode.getEnginesCount()) { score += 2; }
if (this->getEngineType() == otherCode.getEngineType()) { score += 2; }
if (this->getAircraftType() == otherCode.getAircraftType()) { score += 2; }
CMatchingUtils::addLogDetailsToList(log, *this, QString("Added combined code parts: %1").arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Added combined code parts: %1").arg(score));
}
}
@@ -185,14 +180,12 @@ namespace BlackMisc
{
if (this->matchesManufacturer(otherCode.getManufacturer()))
{
static const QString s("Matches manufacturer '%1': %2");
score += 10;
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(this->getManufacturer()).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Matches manufacturer '%1': %2").arg(this->getManufacturer()).arg(score));
}
else if (this->getManufacturer().contains(otherCode.getManufacturer(), Qt::CaseInsensitive))
{
static const QString s("Contains manufacturer '%1': %2");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(this->getManufacturer()).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Contains manufacturer '%1': %2").arg(this->getManufacturer()).arg(score));
score += 5;
}
}
@@ -200,9 +193,8 @@ namespace BlackMisc
// 0..75 so far
if (this->isMilitary() == otherCode.isMilitary())
{
static const QString s("Matches military flag '%1': %2");
score += 10;
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(boolToYesNo(this->isMilitary())).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Matches military flag '%1': %2").arg(boolToYesNo(this->isMilitary())).arg(score));
}
// 0..85
return score;

View File

@@ -1030,8 +1030,7 @@ namespace BlackMisc
QString CAircraftSituation::getPBHInfo() const
{
static const QString pbh("P: %1 %2 B: %3 %4 H: %5 %6");
return pbh.arg(
return QStringLiteral("P: %1 %2 B: %3 %4 H: %5 %6").arg(
this->getPitch().valueRoundedWithUnit(CAngleUnit::deg(), 1, true), this->getPitch().valueRoundedWithUnit(CAngleUnit::rad(), 5, true),
this->getBank().valueRoundedWithUnit(CAngleUnit::deg(), 1, true), this->getBank().valueRoundedWithUnit(CAngleUnit::rad(), 5, true),
this->getHeading().valueRoundedWithUnit(CAngleUnit::deg(), 1, true), this->getHeading().valueRoundedWithUnit(CAngleUnit::rad(), 5, true)

View File

@@ -379,31 +379,31 @@ namespace BlackMisc
if (otherCode.hasValidDesignator() && this->getDesignator() == otherCode.getDesignator())
{
score += 60;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Same designator: %1").arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Same designator: %1").arg(score));
}
// only for DB values we check VA
if (bothFromDb && this->isVirtualAirline() == otherCode.isVirtualAirline())
{
score += 20;
CMatchingUtils::addLogDetailsToList(log, *this, QString("VA equality: %1").arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("VA equality: %1").arg(score));
}
// consider the various names
if (this->hasName() && this->getName() == otherCode.getName())
{
score += 20;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Same name '%1': %2").arg(this->getName()).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Same name '%1': %2").arg(this->getName()).arg(score));
}
else if (this->hasTelephonyDesignator() && this->getTelephonyDesignator() == otherCode.getTelephonyDesignator())
{
score += 15;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Same telephony '%1': %2").arg(this->getTelephonyDesignator()).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Same telephony '%1': %2").arg(this->getTelephonyDesignator()).arg(score));
}
else if (this->hasSimplifiedName() && this->getSimplifiedName() == otherCode.getSimplifiedName())
{
score += 10;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Same simplified name '%1': %2").arg(this->getSimplifiedName()).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Same simplified name '%1': %2").arg(this->getSimplifiedName()).arg(score));
}
return score;
}

View File

@@ -78,9 +78,8 @@ namespace BlackMisc
if (m_datum == FlightLevel)
{
static const QString fls("FL%1");
const int fl = qRound(this->CLength::value(CLengthUnit::ft()) / 100.0);
return fls.arg(fl);
return QStringLiteral("FL%1").arg(fl);
}
else
{

View File

@@ -503,7 +503,7 @@ namespace BlackMisc
{
if (msgs)
{
msgs->push_back(ex.toStatusMessage(getLogCategories(), QString("Parsing flight plan from '%1' failed.").arg(fileName)));
msgs->push_back(ex.toStatusMessage(getLogCategories(), QStringLiteral("Parsing flight plan from '%1' failed.").arg(fileName)));
}
}
return CFlightPlan();

View File

@@ -20,13 +20,12 @@ namespace BlackMisc
{
QString CHeading::convertToQString(bool i18n) const
{
static const QString s("%1 %2");
return i18n ?
s.arg(CAngle::convertToQString(i18n),
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
this->isMagneticHeading() ?
QCoreApplication::translate("Aviation", "magnetic") :
QCoreApplication::translate("Aviation", "true")) :
s.arg(CAngle::convertToQString(i18n),
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
this->isMagneticHeading() ? "magnetic" : "true");
}

View File

@@ -429,8 +429,7 @@ namespace BlackMisc
QString CLivery::asHtmlSummary(const QString &separator) const
{
static const QString html = "%1%2Airline: %3";
return html.arg(
return QStringLiteral("%1%2Airline: %3").arg(
this->getCombinedCodePlusInfoAndId(), separator,
this->getAirlineIcaoCode().getDesignator().isEmpty() ? "No airline" : this->getAirlineIcaoCode().getCombinedStringWithKey()
).replace(" ", "&nbsp;");
@@ -456,7 +455,7 @@ namespace BlackMisc
// 2 color liveries 25..85
score = 25;
score += 60 * colorMultiplier;
CMatchingUtils::addLogDetailsToList(log, *this, QString("2 color liveries, color multiplier %1: %2").arg(colorMultiplier).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("2 color liveries, color multiplier %1: %2").arg(colorMultiplier).arg(score));
}
else if (this->isAirlineLivery() && otherLivery.isAirlineLivery())
{
@@ -467,10 +466,10 @@ namespace BlackMisc
// same ICAO at least means 30, max 50
score = qRound(0.5 * this->getAirlineIcaoCode().calculateScore(otherLivery.getAirlineIcaoCode(), log));
score += 25 * colorMultiplier;
CMatchingUtils::addLogDetailsToList(log, *this, QString("2 airline liveries, color multiplier %1: %2").arg(colorMultiplier).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("2 airline liveries, color multiplier %1: %2").arg(colorMultiplier).arg(score));
if (this->isMilitary() == otherLivery.isMilitary())
{
CMatchingUtils::addLogDetailsToList(log, *this, QString("Mil.flag '%1' matches: %2").arg(boolToYesNo(this->isMilitary())).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Mil.flag '%1' matches: %2").arg(boolToYesNo(this->isMilitary())).arg(score));
score += 10;
}
}
@@ -481,7 +480,7 @@ namespace BlackMisc
// 25 is weaker as same ICAO code / 2 from above
score = preferColorLiveries ? 25 : 0;
score += 25 * colorMultiplier; // needs to be the same as in 2 airlines
CMatchingUtils::addLogDetailsToList(log, *this, QString("Color/airline mixed, color multiplier %1: %2").arg(colorMultiplier).arg(score));
CMatchingUtils::addLogDetailsToList(log, *this, QStringLiteral("Color/airline mixed, color multiplier %1: %2").arg(colorMultiplier).arg(score));
}
return score;
}