6#include <QRegularExpression>
7#include <QRegularExpressionMatch>
18namespace swift::misc::aviation
21 : m_callsignAsSet(callsign.trimmed()), m_callsign(
CCallsign::
unifyCallsign(callsign, hint)), m_typeHint(hint)
26 m_telephonyDesignator(telephonyDesignator.trimmed()), m_typeHint(hint)
36 qRegisterMetaType<CCallsign::TypeHint>();
109 return std::numeric_limits<int>::max();
254 return m_callsign.endsWith(
"SUP");
259 return m_callsignAsSet ==
"*" || m_callsign ==
"*" || m_callsignAsSet ==
"BROADCAST";
264 m_callsignAsSet =
"BROADCAST";
265 m_callsign =
"BROADCAST";
270 m_callsignAsSet =
"SUP";
276 return m_callsign.startsWith(pilotCallsign.
asString()) &&
277 m_callsign.size() == pilotCallsign.
asString().
size() + 1 &&
278 m_callsign.at(m_callsign.size() - 1) >=
'A' && m_callsign.at(m_callsign.size() - 1) <=
'Z';
284 if (m_callsignAsSet.startsWith(
'*'))
297 if (m_callsign.length() >= 4)
299 return m_callsign.left(4).toUpper();
365 flightNumber.
clear();
366 if (m_callsign.length() < 3)
386 if (airline.
length() == 3)
388 flightIdentification = m_callsign.
length() > 3 ? m_callsign.mid(3) :
QString();
393 flightIdentification = m_callsign.
length() > 4 ? m_callsign.mid(4) :
QString();
398 if (flightNumber.
length() >= 1 && airline.
length() == 4)
400 flightIdentification = m_callsign.
mid(3);
401 return airline.
left(3);
454 return other == (*this);
466 case IndexCallsignString:
return { this->
asString() };
469 case IndexSuffix:
return { this->
getSuffix() };
485 case IndexCallsignStringAsSet: m_callsignAsSet = variant.
toString();
break;
486 case IndexTelephonyDesignator: m_telephonyDesignator = variant.
toString();
break;
500 case IndexCallsignString:
return m_callsign.compare(compareValue.m_callsign,
Qt::CaseInsensitive);
501 case IndexCallsignStringAsSet:
503 case IndexTelephonyDesignator:
504 return m_telephonyDesignator.compare(compareValue.m_telephonyDesignator,
Qt::CaseInsensitive);
508 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Compare failed");
518 default:
return !this->
isEmpty();
550 static const QStringList a({
"APP",
"GND",
"DEP",
"TWR",
"DEL",
"CTR" });
556 static const QStringList a({
"ATIS",
"APP",
"GND",
"OBS",
"DEP",
"TWR",
"DEL",
"CTR",
"SUP",
"FSS",
"INS" });
Value object for icons. An icon is stored in the global icon repository and identified by its index....
static const CIcon & iconByIndex(CIcons::IconIndex index)
Icon for given index.
static const QString & aviation()
Aviation specific.
A sequence of log categories.
static CLogCategoryList fromQStringList(const QStringList &stringList)
Convert a string list, such as that returned by toQStringList(), into a CLogCategoryList.
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
void push_back(const T &value)
Appends an element at the end of the sequence.
Streamable status message, e.g.
swift::misc::StatusSeverity StatusSeverity
Status severities.
Status messages, e.g. from Core -> GUI.
int getSuffixSortOrder() const
Sort order by suffix.
const QString & getTelephonyDesignator() const
Get callsign telephony designator (how callsign is pronounced).
void clear()
Clear this callsign.
int comparePropertyByIndex(CPropertyIndexRef index, const CCallsign &compareValue) const
Compare for index.
bool isMaybeCopilotCallsign(const CCallsign &pilotCallsign) const
Returns true if this is a co-pilot callsign of pilot. The logic is that the callsign is the same as t...
static int suffixToSortOrder(const QString &suffix)
Index for ATC suffix, if unknown int max value.
QString getSuffix() const
Get the callsign suffix ("TWR", "ATIS" ...) if any ("_" is removed).
TypeHint
Representing what.
bool hasSuffix() const
Suffix such as "_TWR"?
void markAsBroadcastCallsign()
Set a human readable name as "broadcast" callsign.
QString convertToQString(bool i18n=false) const
Cast as QString.
int getFlightNumberInt() const
Flight number as integer.
QString getFlightIndentification() const
Flight number (e.g. DLH1234 -> 1234) if applicable.
static const QStringList & atcCallsignSuffixes()
List of real ATC suffixes (e.g. TWR);.
static bool looksLikeAtcCallsign(const QString &callsign)
Does this look like an ATC callsign.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void markAsWallopCallsign()
Set a human readable name as "wallop-channel" callsign.
QString getFlightNumber() const
Flight number (e.g. DLH1234 -> 1234) if applicable.
bool isSupervisorCallsign() const
Supervisor?
static void addLogDetailsToList(CStatusMessageList *log, const CCallsign &callsign, const QString &message, const QStringList &extraCategories={}, CStatusMessage::StatusSeverity s=CStatusMessage::SeverityInfo)
Specialized log for matching / reverse lookup.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isObserverCallsign() const
Observer callsign?
bool isAtcAlikeCallsign() const
ATC alike callsign.
CCallsign()=default
Default constructor.
const QString & asString() const
Get callsign (normalized).
static CStatusMessage logMessage(const CCallsign &callsign, const QString &message, const QStringList &extraCategories={}, CStatusMessage::StatusSeverity s=CStatusMessage::SeverityInfo)
Specialized log message for matching / reverse lookup.
const QString & getStringAsSet() const
Get callsign.
static QString unifyCallsign(const QString &callsign, TypeHint hint=NoHint)
Unify the callsign by removing illegal characters.
bool isEmpty() const
Is empty?
static bool isValidAircraftCallsign(const QString &callsign)
Valid callsign?
TypeHint getTypeHint() const
Type hint.
static const CIcon & convertToIcon(const CCallsign &callsign)
Representing icon.
QString getAsObserverCallsignString() const
Makes this callsign looking like an observer callsign (DAMBZ -> DAMBZ_OBS).
bool hasAtcSuffix() const
Has an ATC suffix?
QString getIcaoCode() const
Get ICAO code, if this makes sense (EDDF_TWR -> EDDF).
QString getAirlinePrefix() const
Airline suffix (e.g. DLH1234 -> DLH) if applicable.
static const CIcon & atcSuffixToIcon(const QString &suffix)
Suffix to icon.
bool isAtcCallsign() const
ATC callsign.
static void registerMetadata()
Register metadata.
QString getFsdCallsignString() const
The callsign string used with FSD.
bool isSameAsSet() const
Same as set callsign?
bool equalsString(const QString &callsignString) const
Equals callsign string?
bool isBroadcastCallsign() const
Pseudo callsing for broadcast messages.
static bool isValidAtcCallsign(const QString &callsign)
Valid callsign?
bool isValid() const
Valid callsign?
static const QStringList & atcAlikeCallsignSuffixes()
List of real ("TWR") and treated like ATC suffixes (e.g. OBS);.
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
QString removeChars(const QString &s, F predicate)
Return a string with characters removed that match the given predicate.
bool containsChar(const QString &s, F predicate)
True if any character in the string matches the given predicate.
bool isDigit(char32_t ucs4)
bool isLetterOrNumber(char32_t ucs4)
bool isUpper(char32_t ucs4)
QRegularExpressionMatch match(QStringView subjectView, qsizetype offset, QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions) const const
QString captured(QAnyStringView name) const const
bool hasMatch() const const
QString & append(QChar ch)
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) &&
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) &&
QString section(QChar sep, qsizetype start, qsizetype end, QString::SectionFlags flags) const const
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
int toInt(bool *ok, int base) const const
QString toUpper() const const
QString trimmed() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool endsWith(QChar ch) const const
QVariant fromValue(T &&value)
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.