mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T172, formatting
* this->m_ => m_ * formatting * comments / doxygen
This commit is contained in:
@@ -21,13 +21,12 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
|
||||
QString CClient::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s = this->m_user.toQString(i18n);
|
||||
QString s = m_user.toQString(i18n);
|
||||
s.append(" capabilites: ").append(this->getCapabilitiesAsString());
|
||||
s.append(" model: ").append(this->m_modelString);
|
||||
if (!this->m_server.isEmpty()) { s.append(" server:").append(this->m_server); }
|
||||
s.append(" model: ").append(m_modelString);
|
||||
if (!m_server.isEmpty()) { s.append(" server:").append(m_server); }
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -36,17 +35,17 @@ namespace BlackMisc
|
||||
|
||||
bool CClient::isValid() const
|
||||
{
|
||||
return this->m_user.hasValidCallsign();
|
||||
return m_user.hasValidCallsign();
|
||||
}
|
||||
|
||||
void CClient::setCapability(bool hasCapability, CClient::Capabilities capability)
|
||||
{
|
||||
this->m_capabilities.addValue(static_cast<int>(capability), hasCapability);
|
||||
m_capabilities.addValue(static_cast<int>(capability), hasCapability);
|
||||
}
|
||||
|
||||
void CClient::setCapabilities(const CPropertyIndexVariantMap &capabilities)
|
||||
{
|
||||
this->m_capabilities = capabilities;
|
||||
m_capabilities = capabilities;
|
||||
}
|
||||
|
||||
QString CClient::getCapabilitiesAsString() const
|
||||
@@ -62,9 +61,9 @@ namespace BlackMisc
|
||||
|
||||
bool CClient::hasCapability(CClient::Capabilities capability) const
|
||||
{
|
||||
if (this->m_capabilities.contains(capability))
|
||||
if (m_capabilities.contains(capability))
|
||||
{
|
||||
return this->m_capabilities.value(capability).toBool();
|
||||
return m_capabilities.value(capability).toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -74,17 +73,17 @@ namespace BlackMisc
|
||||
|
||||
void CClient::setUserCallsign(const Aviation::CCallsign &callsign)
|
||||
{
|
||||
this->m_user.setCallsign(callsign);
|
||||
m_user.setCallsign(callsign);
|
||||
}
|
||||
|
||||
CVariant CClient::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CClient::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCapabilities:
|
||||
return CVariant::fromValue(this->m_capabilities);
|
||||
return CVariant::fromValue(m_capabilities);
|
||||
case IndexCapabilitiesString:
|
||||
return CVariant(this->getCapabilitiesAsString());
|
||||
case IndexCallsign:
|
||||
@@ -92,17 +91,17 @@ namespace BlackMisc
|
||||
case IndexUser:
|
||||
return this->getUser().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexModelString:
|
||||
return CVariant(this->m_modelString);
|
||||
return CVariant(m_modelString);
|
||||
case IndexServer:
|
||||
return CVariant(this->m_server);
|
||||
return CVariant(m_server);
|
||||
case IndexVoiceCapabilities:
|
||||
return this->m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||
return m_voiceCapabilities.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceCapabilitiesPixmap:
|
||||
return CVariant::from(this->m_voiceCapabilities.toPixmap());
|
||||
return CVariant::from(m_voiceCapabilities.toPixmap());
|
||||
case IndexVoiceCapabilitiesIcon:
|
||||
return CVariant::fromValue(this->m_voiceCapabilities.toIcon());
|
||||
return CVariant::fromValue(m_voiceCapabilities.toIcon());
|
||||
case IndexVoiceCapabilitiesString:
|
||||
return CVariant(this->m_voiceCapabilities.toQString(true));
|
||||
return CVariant(m_voiceCapabilities.toQString(true));
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -111,26 +110,26 @@ namespace BlackMisc
|
||||
void CClient::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CClient>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCapabilities:
|
||||
this->m_capabilities = variant.value<CPropertyIndexVariantMap>();
|
||||
m_capabilities = variant.value<CPropertyIndexVariantMap>();
|
||||
break;
|
||||
case IndexModelString:
|
||||
this->m_modelString = variant.toQString();
|
||||
m_modelString = variant.toQString();
|
||||
break;
|
||||
case IndexServer:
|
||||
this->m_server = variant.toQString();
|
||||
m_server = variant.toQString();
|
||||
break;
|
||||
case IndexUser:
|
||||
this->m_user.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_user.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexCallsign:
|
||||
this->m_user.setCallsign(variant.value<BlackMisc::Aviation::CCallsign>());
|
||||
m_user.setCallsign(variant.value<BlackMisc::Aviation::CCallsign>());
|
||||
break;
|
||||
case IndexVoiceCapabilities:
|
||||
this->m_voiceCapabilities.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_voiceCapabilities.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCapabilities = BlackMisc::CPropertyIndex::GlobalIndexCClient,
|
||||
IndexCapabilities = CPropertyIndex::GlobalIndexCClient,
|
||||
IndexCapabilitiesString,
|
||||
IndexModelString,
|
||||
IndexServer,
|
||||
@@ -53,7 +53,7 @@ namespace BlackMisc
|
||||
//! The Capabilities enum
|
||||
enum Capabilities
|
||||
{
|
||||
FsdWithInterimPositions = BlackMisc::CPropertyIndex::GlobalIndexClientCapabilities, //!< interim positions
|
||||
FsdWithInterimPositions = CPropertyIndex::GlobalIndexClientCapabilities, //!< interim positions
|
||||
FsdWithIcaoCodes, //!< basically means it is a pilot client handling ICAO code pacakages
|
||||
FsdAtisCanBeReceived, //!< ATIS
|
||||
FsdWithAircraftConfig //!< Aircraft parts
|
||||
@@ -69,7 +69,7 @@ namespace BlackMisc
|
||||
CClient(const CUser &user) : m_user(user) {}
|
||||
|
||||
//! Callsign used with other client
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_user.getCallsign(); }
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_user.getCallsign(); }
|
||||
|
||||
//! ATC client
|
||||
bool isAtc() const { return getCallsign().isAtcAlikeCallsign(); }
|
||||
@@ -78,7 +78,7 @@ namespace BlackMisc
|
||||
bool isValid() const;
|
||||
|
||||
//! Get capabilities
|
||||
CPropertyIndexVariantMap getCapabilities() const { return this->m_capabilities; }
|
||||
CPropertyIndexVariantMap getCapabilities() const { return m_capabilities; }
|
||||
|
||||
//! Set capability
|
||||
void setCapability(bool hasCapability, Capabilities capability);
|
||||
@@ -105,31 +105,31 @@ namespace BlackMisc
|
||||
void setVoiceCapabilities(const QString &flightPlanRemarks) { m_voiceCapabilities = CVoiceCapabilities(flightPlanRemarks);}
|
||||
|
||||
//! User
|
||||
const CUser &getUser() const { return this->m_user; }
|
||||
const CUser &getUser() const { return m_user; }
|
||||
|
||||
//! User
|
||||
void setUser(const CUser &user) { this->m_user = user;}
|
||||
void setUser(const CUser &user) { m_user = user;}
|
||||
|
||||
//! User's callsign
|
||||
void setUserCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Server
|
||||
const QString &getServer() const { return this->m_server; }
|
||||
const QString &getServer() const { return m_server; }
|
||||
|
||||
//! Server
|
||||
void setServer(const QString &server) { this->m_server = server;}
|
||||
void setServer(const QString &server) { m_server = server;}
|
||||
|
||||
//! Model
|
||||
const QString &getQueriedModelString() const { return this->m_modelString; }
|
||||
const QString &getQueriedModelString() const { return m_modelString; }
|
||||
|
||||
//! \copydoc Simulation::CAircraftModel::hasQueriedModelString
|
||||
bool hasQueriedModelString() const { return !this->m_modelString.isEmpty(); }
|
||||
bool hasQueriedModelString() const { return !m_modelString.isEmpty(); }
|
||||
|
||||
//! Set model
|
||||
void setQueriedModelString(const QString &modelString) { this->m_modelString = modelString.trimmed(); }
|
||||
void setQueriedModelString(const QString &modelString) { m_modelString = modelString.trimmed(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
CIcon toIcon() const { return this->m_user.toIcon(); }
|
||||
CIcon toIcon() const { return m_user.toIcon(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
@@ -141,11 +141,11 @@ namespace BlackMisc
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BlackMisc::Network::CUser m_user;
|
||||
BlackMisc::CPropertyIndexVariantMap m_capabilities;
|
||||
QString m_modelString;
|
||||
QString m_server;
|
||||
BlackMisc::Network::CVoiceCapabilities m_voiceCapabilities;
|
||||
CUser m_user;
|
||||
CPropertyIndexVariantMap m_capabilities;
|
||||
QString m_modelString;
|
||||
QString m_server;
|
||||
CVoiceCapabilities m_voiceCapabilities;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CClient,
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace BlackMisc
|
||||
QString CUser::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (this->m_realname.isEmpty()) return "<no realname>";
|
||||
QString s = this->m_realname;
|
||||
if (m_realname.isEmpty()) return "<no realname>";
|
||||
QString s = m_realname;
|
||||
if (this->hasValidId())
|
||||
{
|
||||
s.append(" (").append(this->m_id).append(')');
|
||||
s.append(" (").append(m_id).append(')');
|
||||
}
|
||||
if (this->hasValidCallsign())
|
||||
{
|
||||
@@ -71,12 +71,12 @@ namespace BlackMisc
|
||||
|
||||
void CUser::deriveHomeBaseFromCallsign()
|
||||
{
|
||||
if (this->m_callsign.isEmpty()) { return; }
|
||||
if (this->m_homebase.isEmpty())
|
||||
if (m_callsign.isEmpty()) { return; }
|
||||
if (m_homebase.isEmpty())
|
||||
{
|
||||
if (this->m_callsign.isAtcCallsign())
|
||||
if (m_callsign.isAtcCallsign())
|
||||
{
|
||||
this->m_homebase = this->m_callsign.getIcaoCode();
|
||||
m_homebase = m_callsign.getIcaoCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace BlackMisc
|
||||
QString rn(removeAccents(realname.trimmed().simplified()));
|
||||
if (rn.isEmpty())
|
||||
{
|
||||
this->m_realname = "";
|
||||
m_realname = "";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
// do not beautify before stripping home base
|
||||
this->m_realname = beautifyRealName(rn);
|
||||
m_realname = beautifyRealName(rn);
|
||||
}
|
||||
|
||||
CStatusMessageList CUser::validate() const
|
||||
@@ -187,12 +187,12 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmail: return CVariant(this->m_email);
|
||||
case IndexId: return CVariant(this->m_id);
|
||||
case IndexPassword: return CVariant(this->m_password);
|
||||
case IndexRealName: return CVariant(this->m_realname);
|
||||
case IndexHomebase: return this->m_homebase.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign: return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexEmail: return CVariant(m_email);
|
||||
case IndexId: return CVariant(m_id);
|
||||
case IndexPassword: return CVariant(m_password);
|
||||
case IndexRealName: return CVariant(m_realname);
|
||||
case IndexHomebase: return m_homebase.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
@@ -207,8 +207,8 @@ namespace BlackMisc
|
||||
case IndexId: this->setId(variant.value<QString>()); break;
|
||||
case IndexPassword: this->setPassword(variant.value<QString>()); break;
|
||||
case IndexRealName: this->setRealName(variant.value<QString>()); break;
|
||||
case IndexHomebase: this->m_homebase.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCallsign: this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexHomebase: m_homebase.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
@@ -219,11 +219,11 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmail: return this->m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||
case IndexId: return this->m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||
case IndexRealName: return this->m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||
case IndexHomebase: return this->m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
||||
case IndexCallsign: return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexEmail: return m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||
case IndexId: return m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||
case IndexRealName: return m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||
case IndexHomebase: return m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexPassword: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
*/
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexEmail = BlackMisc::CPropertyIndex::GlobalIndexCUser,
|
||||
IndexEmail = CPropertyIndex::GlobalIndexCUser,
|
||||
IndexId,
|
||||
IndexPassword,
|
||||
IndexRealName,
|
||||
@@ -52,13 +52,13 @@ namespace BlackMisc
|
||||
CUser() = default;
|
||||
|
||||
//! Constructor by callsign
|
||||
CUser(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
CUser(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Constructor.
|
||||
CUser(const QString &id, const QString &realname, const BlackMisc::Aviation::CCallsign &callsign);
|
||||
CUser(const QString &id, const QString &realname, const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Constructor.
|
||||
CUser(const QString &id, const QString &realname, const QString &email = "", const QString &password = "", const BlackMisc::Aviation::CCallsign &callsign = {});
|
||||
CUser(const QString &id, const QString &realname, const QString &email = "", const QString &password = "", const Aviation::CCallsign &callsign = {});
|
||||
|
||||
//! Get full name.
|
||||
QString getRealName() const { return m_realname; }
|
||||
@@ -73,16 +73,16 @@ namespace BlackMisc
|
||||
void setPassword(const QString &pw) { m_password = pw.trimmed(); }
|
||||
|
||||
//! Valid user object?
|
||||
bool isValid() const { return !this->m_realname.isEmpty() && !this->m_id.isEmpty(); }
|
||||
bool isValid() const { return !m_realname.isEmpty() && !m_id.isEmpty(); }
|
||||
|
||||
//! Valid credentials?
|
||||
bool hasValidCredentials() const { return this->isValid() && !this->m_password.isEmpty(); }
|
||||
bool hasValidCredentials() const { return this->isValid() && !m_password.isEmpty(); }
|
||||
|
||||
//! Valid real name?
|
||||
bool hasValidRealName() const { return !this->m_realname.isEmpty(); }
|
||||
bool hasValidRealName() const { return !m_realname.isEmpty(); }
|
||||
|
||||
//! Valid id?
|
||||
bool hasValidId() const { return !this->m_id.isEmpty(); }
|
||||
bool hasValidId() const { return !m_id.isEmpty(); }
|
||||
|
||||
//! Has associated callsign?
|
||||
bool hasValidCallsign() const { return !m_callsign.isEmpty(); }
|
||||
@@ -91,7 +91,7 @@ namespace BlackMisc
|
||||
bool hasValidHomebase() const { return !m_homebase.isEmpty(); }
|
||||
|
||||
//! Validate, provide details about issues
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Get email.
|
||||
QString getEmail() const { return m_email; }
|
||||
@@ -100,7 +100,7 @@ namespace BlackMisc
|
||||
void setEmail(const QString &email) { m_email = email.trimmed(); }
|
||||
|
||||
//! Valid email?
|
||||
bool hasValidEmail() const { return !this->m_email.isEmpty(); }
|
||||
bool hasValidEmail() const { return !m_email.isEmpty(); }
|
||||
|
||||
//! Get id.
|
||||
QString getId() const { return m_id; }
|
||||
@@ -109,28 +109,28 @@ namespace BlackMisc
|
||||
void setId(const QString &id) { m_id = id.trimmed(); }
|
||||
|
||||
//! Homebase
|
||||
const BlackMisc::Aviation::CAirportIcaoCode &getHomeBase() const { return this->m_homebase; }
|
||||
const Aviation::CAirportIcaoCode &getHomeBase() const { return m_homebase; }
|
||||
|
||||
//! Set homebase
|
||||
void setHomeBase(const BlackMisc::Aviation::CAirportIcaoCode &homebase) { this->m_homebase = homebase; }
|
||||
void setHomeBase(const Aviation::CAirportIcaoCode &homebase) { m_homebase = homebase; }
|
||||
|
||||
//! Has home base?
|
||||
bool hasHomeBase() const { return !this->m_homebase.isEmpty(); }
|
||||
bool hasHomeBase() const { return !m_homebase.isEmpty(); }
|
||||
|
||||
//! Get associated callsign.
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
const Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
|
||||
//! Set associated callsign
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void setCallsign(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->getCallsign().toIcon(); }
|
||||
CIcon toIcon() const { return this->getCallsign().toIcon(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CUser &compareValue) const;
|
||||
@@ -158,8 +158,8 @@ namespace BlackMisc
|
||||
QString m_realname;
|
||||
QString m_email;
|
||||
QString m_password;
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
BlackMisc::Aviation::CAirportIcaoCode m_homebase;
|
||||
Aviation::CCallsign m_callsign;
|
||||
Aviation::CAirportIcaoCode m_homebase;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CUser,
|
||||
|
||||
Reference in New Issue
Block a user