mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 10:47:01 +08:00
Return a default-constructed QString instead of implicitly converting an empty string literal.
This commit is contained in:
@@ -298,7 +298,7 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftIcaoCode::getEngineType() const
|
||||
{
|
||||
if (m_combinedType.length() != 3) return "";
|
||||
if (m_combinedType.length() != 3) return {};
|
||||
return m_combinedType.right(1);
|
||||
}
|
||||
|
||||
@@ -322,15 +322,15 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftIcaoCode::getEngineCountString() const
|
||||
{
|
||||
if (m_combinedType.length() < 2) { return ""; }
|
||||
if (m_combinedType.length() < 2) { return {}; }
|
||||
return m_combinedType.mid(1, 1);
|
||||
}
|
||||
|
||||
QString CAircraftIcaoCode::getAircraftType() const
|
||||
{
|
||||
if (m_combinedType.length() < 1) { return ""; }
|
||||
if (m_combinedType.length() < 1) { return {}; }
|
||||
QString c(m_combinedType.at(0));
|
||||
if (c == "-") { return ""; }
|
||||
if (c == "-") { return {}; }
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftIcaoCode::getCombinedIataStringWithKey() const
|
||||
{
|
||||
if (!this->hasIataCode()) { return ""; }
|
||||
if (!this->hasIataCode()) { return {}; }
|
||||
return this->getIataCode() % u" [IATA" %
|
||||
(this->hasDesignator() ? (u' ' % this->getDesignator()) : QString()) %
|
||||
(this->hasManufacturer() ? (u' ' % this->getManufacturer()) : QString()) %
|
||||
@@ -487,7 +487,7 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftIcaoCode::getCombinedFamilyStringWithKey() const
|
||||
{
|
||||
if (!this->hasFamily()) { return ""; }
|
||||
if (!this->hasFamily()) { return {}; }
|
||||
return this->getFamily() % u" [family" %
|
||||
(this->hasDesignator() ? (u' ' % this->getDesignator()) : QString()) %
|
||||
(this->hasManufacturer() ? (u' ' % this->getManufacturer()) : QString()) %
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace BlackMisc
|
||||
QString CAirportIcaoCode::unifyAirportCode(const QString &icaoCode)
|
||||
{
|
||||
const QString code = icaoCode.trimmed().toUpper();
|
||||
if (code.length() != 4) return "";
|
||||
if (containsChar(code, [](QChar c) { return !c.isLetterOrNumber(); })) { return ""; }
|
||||
if (code.length() != 4) return {};
|
||||
if (containsChar(code, [](QChar c) { return !c.isLetterOrNumber(); })) { return {}; }
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace BlackMisc
|
||||
|
||||
QString CCallsign::getAsObserverCallsignString() const
|
||||
{
|
||||
if (this->isEmpty()) { return ""; }
|
||||
if (this->isEmpty()) { return {}; }
|
||||
QString obs = this->getStringAsSet();
|
||||
if (obs.endsWith("_OBS", Qt::CaseInsensitive)) { return obs; } // already OBS
|
||||
if (obs.contains('_')) { obs = obs.left(obs.lastIndexOf('_')); }
|
||||
@@ -168,8 +168,8 @@ namespace BlackMisc
|
||||
|
||||
QString CCallsign::getAirlineSuffix() const
|
||||
{
|
||||
if (m_callsign.length() < 3) { return ""; }
|
||||
if (this->isAtcCallsign()) { return ""; }
|
||||
if (m_callsign.length() < 3) { return {}; }
|
||||
if (this->isAtcCallsign()) { return {}; }
|
||||
|
||||
thread_local const QRegularExpression regExp("^[A-Z]{3,}");
|
||||
QRegularExpressionMatch match = regExp.match(m_callsign);
|
||||
@@ -184,7 +184,7 @@ namespace BlackMisc
|
||||
const QString number = match.captured(1);
|
||||
if (number.length() >= 3 && airline.length() == 4) { return airline.left(3); }
|
||||
|
||||
return ""; // invalid
|
||||
return {}; // invalid
|
||||
}
|
||||
|
||||
bool CCallsign::hasSuffix() const
|
||||
|
||||
@@ -130,9 +130,9 @@ namespace BlackMisc
|
||||
{
|
||||
const int maxIndex = remarks.size() - 1;
|
||||
int f = remarks.indexOf(marker);
|
||||
if (f < 0) { return ""; }
|
||||
if (f < 0) { return {}; }
|
||||
f += marker.length();
|
||||
if (maxIndex <= f) { return ""; }
|
||||
if (maxIndex <= f) { return {}; }
|
||||
|
||||
// the remarks are poorly formatted:
|
||||
// 1) sometimes the values are enclosed in "/", like "/REG/D-AMBZ/"
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (CSelcal::isValidCharacter(c)) { s += c;}
|
||||
}
|
||||
return CSelcal::isValidCode(s) ? s : QString("");
|
||||
return CSelcal::isValidCode(s) ? s : QString();
|
||||
}
|
||||
|
||||
bool CSelcal::equalsString(const QString &code) const
|
||||
|
||||
Reference in New Issue
Block a user