mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Tweak in icon / callsign
* conversion to Icon in callsign * toQIcon function
This commit is contained in:
@@ -41,17 +41,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (callsign.hasSuffix())
|
if (callsign.hasSuffix())
|
||||||
{
|
{
|
||||||
QString t = callsign.getSuffix();
|
return suffixToIcon(callsign.getSuffix());
|
||||||
if (t.length() < 3) { return CIconList::iconByIndex(CIcons::NetworkRoleUnknown); }
|
|
||||||
if ("APP" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleApproach); }
|
|
||||||
if ("GND" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleGround); }
|
|
||||||
if ("TWR" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleTower); }
|
|
||||||
if ("DEL" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleDelivery); }
|
|
||||||
if ("CTR" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleCenter); }
|
|
||||||
if ("SUP" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleSup); }
|
|
||||||
if ("OBS" == t) { return CIconList::iconByIndex(CIcons::NetworkRoleObs); }
|
|
||||||
if ("ATIS" == t) { return CIconList::iconByIndex(CIcons::AviationAtis); }
|
|
||||||
return CIconList::iconByIndex(CIcons::NetworkRoleUnknown);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -59,6 +49,22 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CIcon &CCallsign::suffixToIcon(const QString &suffix)
|
||||||
|
{
|
||||||
|
if (suffix.length() < 3) { return CIconList::iconByIndex(CIcons::NetworkRoleUnknown); }
|
||||||
|
QString sfx = suffix.toUpper();
|
||||||
|
if ("APP" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleApproach); }
|
||||||
|
if ("GND" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleGround); }
|
||||||
|
if ("TWR" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleTower); }
|
||||||
|
if ("DEL" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleDelivery); }
|
||||||
|
if ("CTR" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleCenter); }
|
||||||
|
if ("SUP" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleSup); }
|
||||||
|
if ("OBS" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleObs); }
|
||||||
|
if ("ATIS" == sfx) { return CIconList::iconByIndex(CIcons::AviationAtis); }
|
||||||
|
if ("VATSIM" == sfx) { return CIconList::iconByIndex(CIcons::NetworkRoleMnt); }
|
||||||
|
return CIconList::iconByIndex(CIcons::NetworkRoleUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ATC callsign?
|
* ATC callsign?
|
||||||
*/
|
*/
|
||||||
@@ -195,5 +201,6 @@ namespace BlackMisc
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ namespace BlackMisc
|
|||||||
//! List of real ("TWR") and treated like ATC suffixes (e.g. OBS);
|
//! List of real ("TWR") and treated like ATC suffixes (e.g. OBS);
|
||||||
static const QStringList &atcAlikeCallsignSuffixes();
|
static const QStringList &atcAlikeCallsignSuffixes();
|
||||||
|
|
||||||
|
//! Suffix to icon
|
||||||
|
static const BlackMisc::CIcon &suffixToIcon(const QString &suffix);
|
||||||
|
|
||||||
|
//! Representing icon
|
||||||
|
static const CIcon &convertToIcon(const CCallsign &callsign);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc CValueObject::convertToQString()
|
//! \copydoc CValueObject::convertToQString()
|
||||||
virtual QString convertToQString(bool i18n = false) const override;
|
virtual QString convertToQString(bool i18n = false) const override;
|
||||||
@@ -106,9 +112,6 @@ namespace BlackMisc
|
|||||||
//! Unify the callsign
|
//! Unify the callsign
|
||||||
static QString unifyCallsign(const QString &callsign);
|
static QString unifyCallsign(const QString &callsign);
|
||||||
|
|
||||||
//! representing icon
|
|
||||||
static const CIcon &convertToIcon(const CCallsign &callsign);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CCallsign)
|
BLACK_ENABLE_TUPLE_CONVERSION(CCallsign)
|
||||||
QString m_callsignAsSet;
|
QString m_callsignAsSet;
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ namespace BlackMisc
|
|||||||
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
|
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Icon
|
||||||
|
*/
|
||||||
|
QIcon CIcon::toQIcon() const
|
||||||
|
{
|
||||||
|
return QIcon(toPixmap());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rotate
|
* Rotate
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "pqangle.h"
|
#include "pqangle.h"
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,9 @@ namespace BlackMisc
|
|||||||
//! Corresponding pixmap
|
//! Corresponding pixmap
|
||||||
QPixmap toPixmap() const;
|
QPixmap toPixmap() const;
|
||||||
|
|
||||||
|
//! A QIcon
|
||||||
|
QIcon toQIcon() const;
|
||||||
|
|
||||||
//! Icon set?
|
//! Icon set?
|
||||||
bool isSet() const { return (this->m_index != static_cast<int>(CIcons::NotSet));}
|
bool isSet() const { return (this->m_index != static_cast<int>(CIcons::NotSet));}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user