mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 12:15:29 +08:00
Ref T353, clean string used with remarks and route
* use ASCII only characters * simplify string * max. length
This commit is contained in:
@@ -24,13 +24,13 @@ namespace BlackMisc
|
|||||||
CFlightPlanRemarks::CFlightPlanRemarks()
|
CFlightPlanRemarks::CFlightPlanRemarks()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, bool parse) : m_remarks(remarks)
|
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, bool parse) : m_remarks(cleanRemarks(remarks))
|
||||||
{
|
{
|
||||||
if (parse) { this->parseFlightPlanRemarks(); }
|
if (parse) { this->parseFlightPlanRemarks(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, CVoiceCapabilities voiceCapabilities, bool parse) :
|
CFlightPlanRemarks::CFlightPlanRemarks(const QString &remarks, CVoiceCapabilities voiceCapabilities, bool parse) :
|
||||||
m_remarks(remarks), m_voiceCapabilities(voiceCapabilities)
|
m_remarks(cleanRemarks(remarks)), m_voiceCapabilities(voiceCapabilities)
|
||||||
{
|
{
|
||||||
if (parse) { this->parseFlightPlanRemarks(); }
|
if (parse) { this->parseFlightPlanRemarks(); }
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,15 @@ namespace BlackMisc
|
|||||||
if (r.contains("/V/", Qt::CaseInsensitive)) { r.replace("/V/", newCaps, Qt::CaseInsensitive); return r; }
|
if (r.contains("/V/", Qt::CaseInsensitive)) { r.replace("/V/", newCaps, Qt::CaseInsensitive); return r; }
|
||||||
if (r.contains("/R/", Qt::CaseInsensitive)) { r.replace("/R/", newCaps, Qt::CaseInsensitive); return r; }
|
if (r.contains("/R/", Qt::CaseInsensitive)) { r.replace("/R/", newCaps, Qt::CaseInsensitive); return r; }
|
||||||
if (r.contains("/T/", Qt::CaseInsensitive)) { r.replace("/T/", newCaps, Qt::CaseInsensitive); return r; }
|
if (r.contains("/T/", Qt::CaseInsensitive)) { r.replace("/T/", newCaps, Qt::CaseInsensitive); return r; }
|
||||||
return newCaps + " " + r;
|
return newCaps % QStringLiteral(" ") % r;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CFlightPlanRemarks::cleanRemarks(const QString &remarksIn)
|
||||||
|
{
|
||||||
|
QString r = remarksIn;
|
||||||
|
r.replace(':', ' ');
|
||||||
|
r = asciiOnlyString(removeAccents(remarksIn));
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFlightPlanRemarks::parseFlightPlanRemarks(bool force)
|
void CFlightPlanRemarks::parseFlightPlanRemarks(bool force)
|
||||||
@@ -161,6 +169,13 @@ namespace BlackMisc
|
|||||||
m_equipmentSuffix = parts[2];
|
m_equipmentSuffix = parts[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFlightPlan::setRoute(const QString &route)
|
||||||
|
{
|
||||||
|
QString r = route;
|
||||||
|
r.replace(':', ' ');
|
||||||
|
m_route = asciiOnlyString(r).left(MaxRouteLength).toUpper();
|
||||||
|
}
|
||||||
|
|
||||||
void CFlightPlan::setRemarks(const QString &remarks)
|
void CFlightPlan::setRemarks(const QString &remarks)
|
||||||
{
|
{
|
||||||
m_remarks = CFlightPlanRemarks(remarks, true);
|
m_remarks = CFlightPlanRemarks(remarks, true);
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ namespace BlackMisc
|
|||||||
//! Replace the voice capabilities remarks part
|
//! Replace the voice capabilities remarks part
|
||||||
static QString replaceVoiceCapabilities(const QString &newCaps, const QString &oldRemarks);
|
static QString replaceVoiceCapabilities(const QString &newCaps, const QString &oldRemarks);
|
||||||
|
|
||||||
|
//! Clean up remarks string
|
||||||
|
static QString cleanRemarks(const QString &remarksIn);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_remarks; //!< the unparsed string
|
QString m_remarks; //!< the unparsed string
|
||||||
QString m_radioTelephony; //!< radio telephony designator
|
QString m_radioTelephony; //!< radio telephony designator
|
||||||
@@ -226,7 +229,7 @@ namespace BlackMisc
|
|||||||
void setFlightRule(FlightRules flightRules) { m_flightRules = flightRules; }
|
void setFlightRule(FlightRules flightRules) { m_flightRules = flightRules; }
|
||||||
|
|
||||||
//! Set route string
|
//! Set route string
|
||||||
void setRoute(const QString &route) { m_route = route.trimmed().left(MaxRouteLength).toUpper(); }
|
void setRoute(const QString &route);
|
||||||
|
|
||||||
//! Set remarks string (max 100 characters)
|
//! Set remarks string (max 100 characters)
|
||||||
void setRemarks(const QString &remarks);
|
void setRemarks(const QString &remarks);
|
||||||
|
|||||||
@@ -164,6 +164,12 @@ namespace BlackMisc
|
|||||||
return removeChars(string, [](QChar c) { return !is09OrSeparator(c); });
|
return removeChars(string, [](QChar c) { return !is09OrSeparator(c); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! String only with 0-9
|
||||||
|
inline QString asciiOnlyString(const QString &string)
|
||||||
|
{
|
||||||
|
return removeChars(string.simplified(), [](QChar c) { return c.unicode() > 127; });
|
||||||
|
}
|
||||||
|
|
||||||
//! Return string in apostrophes
|
//! Return string in apostrophes
|
||||||
BLACKMISC_EXPORT const QString inApostrophes(const QString &in, bool ignoreEmpty = false);
|
BLACKMISC_EXPORT const QString inApostrophes(const QString &in, bool ignoreEmpty = false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user