Hide model string for ATC clients

This commit is contained in:
Klaus Basan
2014-12-20 18:13:47 +01:00
parent a03bd4d07f
commit 0b03ac1339
6 changed files with 71 additions and 19 deletions

View File

@@ -58,6 +58,22 @@ namespace BlackMisc
}
}
/*
* ATC callsign?
*/
bool CCallsign::isAtcCallsign() const
{
if (this->m_callsignAsSet.contains('_'))
{
if (this->m_callsignAsSet.size() >= 3)
{
QString app = this->m_callsignAsSet.right(3);
return atcCallsignAppendixes().contains(app, Qt::CaseInsensitive);
}
}
return false;
}
/*
* Callsign as Observer
*/
@@ -136,5 +152,14 @@ namespace BlackMisc
return (regexp.match(callsign).hasMatch());
}
/*
* Appendixes
*/
const QStringList &CCallsign::atcCallsignAppendixes()
{
static const QStringList a( { "APP", "GND", "TWR", "DEL", "CTR", "SUP", "FSS" });
return a;
}
} // namespace
} // namespace

View File

@@ -48,6 +48,9 @@ namespace BlackMisc
//! Is empty?
bool isEmpty() const { return this->m_callsignAsSet.isEmpty(); }
//! ATC callsign
bool isAtcCallsign() const;
//! Get callsign.
const QString &asString() const { return this->m_callsign; }
@@ -78,6 +81,9 @@ namespace BlackMisc
//! Valid callsign?
static bool isValidCallsign(const QString &callsign);
//! List of ATC appendixes (e.g. TWR);
static const QStringList &atcCallsignAppendixes();
protected:
//! \copydoc CValueObject::convertToQString()
virtual QString convertToQString(bool i18n = false) const override;

View File

@@ -63,6 +63,9 @@ namespace BlackMisc
//! Callsign used with other client
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_user.getCallsign(); }
//! ATC client
bool isAtc() const { return getCallsign().isAtcCallsign(); }
//! Get capabilities
CPropertyIndexVariantMap getCapabilities() const { return this->m_capabilities; }
@@ -123,23 +126,23 @@ namespace BlackMisc
private:
BLACK_ENABLE_TUPLE_CONVERSION(CClient)
CUser m_user;
CUser m_user;
CAircraftModel m_model;
CPropertyIndexVariantMap m_capabilities;
QString m_server;
CVoiceCapabilities m_voiceCapabilities;
QString m_server;
CVoiceCapabilities m_voiceCapabilities;
};
} // namespace
} // namespace
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CClient, (
o.m_user,
o.m_model,
attr(o.m_capabilities, flags<DisabledForComparison>()),
o.m_server,
o.m_voiceCapabilities
))
o.m_user,
o.m_model,
attr(o.m_capabilities, flags<DisabledForComparison>()),
o.m_server,
o.m_voiceCapabilities
))
Q_DECLARE_METATYPE(BlackMisc::Network::CClient)
#endif // guard