mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Hide model string for ATC clients
This commit is contained in:
@@ -43,5 +43,23 @@ namespace BlackGui
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "model");
|
||||
(void)QT_TRANSLATE_NOOP("ViewClientList", "server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVariant CClientListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
static const CPropertyIndex ms( {CClient::IndexModel, CAircraftModel::IndexModelString});
|
||||
if (role != Qt::DisplayRole) { return CListModelBase::data(index, role); }
|
||||
CPropertyIndex pi = modelIndexToPropertyIndex(index);
|
||||
if (pi == ms)
|
||||
{
|
||||
// no model string for ATC
|
||||
CClient client = this->at(index);
|
||||
bool atc = client.isAtc();
|
||||
if (atc)
|
||||
{
|
||||
return QVariant("ATC");
|
||||
}
|
||||
}
|
||||
return CListModelBase::data(index, role);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -20,9 +20,7 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
/*!
|
||||
* Server list model
|
||||
*/
|
||||
//! Client list model
|
||||
class CClientListModel : public CListModelBase<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>
|
||||
{
|
||||
|
||||
@@ -32,7 +30,11 @@ namespace BlackGui
|
||||
|
||||
//! Destructor
|
||||
virtual ~CClientListModel() {}
|
||||
|
||||
//! \copydoc QAbstractListModel::data()
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
|
||||
@@ -116,9 +116,7 @@ namespace BlackGui
|
||||
Qt::SortOrder m_sortOrder; //!< sort order (asc/desc)
|
||||
};
|
||||
|
||||
/*!
|
||||
* List model
|
||||
*/
|
||||
//! List model
|
||||
template <typename ObjectType, typename ContainerType> class CListModelBase :
|
||||
public CListModelBaseNonTemplate
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user