Tweak in icon / callsign

* conversion to Icon in callsign
* toQIcon function
This commit is contained in:
Klaus Basan
2015-01-22 11:05:25 +01:00
parent 65957c0ebe
commit b629a9325b
4 changed files with 36 additions and 14 deletions

View File

@@ -41,17 +41,7 @@ namespace BlackMisc
{
if (callsign.hasSuffix())
{
QString t = 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);
return suffixToIcon(callsign.getSuffix());
}
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?
*/
@@ -195,5 +201,6 @@ namespace BlackMisc
return a;
}
} // namespace
} // namespace

View File

@@ -99,6 +99,12 @@ namespace BlackMisc
//! List of real ("TWR") and treated like ATC suffixes (e.g. OBS);
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:
//! \copydoc CValueObject::convertToQString()
virtual QString convertToQString(bool i18n = false) const override;
@@ -106,9 +112,6 @@ namespace BlackMisc
//! Unify the callsign
static QString unifyCallsign(const QString &callsign);
//! representing icon
static const CIcon &convertToIcon(const CCallsign &callsign);
private:
BLACK_ENABLE_TUPLE_CONVERSION(CCallsign)
QString m_callsignAsSet;

View File

@@ -20,6 +20,14 @@ namespace BlackMisc
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
}
/*
* Icon
*/
QIcon CIcon::toQIcon() const
{
return QIcon(toPixmap());
}
/*
* Rotate
*/

View File

@@ -14,6 +14,7 @@
#include "icons.h"
#include "pqangle.h"
#include <QIcon>
namespace BlackMisc
{
@@ -38,6 +39,9 @@ namespace BlackMisc
//! Corresponding pixmap
QPixmap toPixmap() const;
//! A QIcon
QIcon toQIcon() const;
//! Icon set?
bool isSet() const { return (this->m_index != static_cast<int>(CIcons::NotSet));}