mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 06:35:41 +08:00
Formatting, help text beautifyHelpMessage, improved convertToQString
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a34be02e07
commit
c1482dca36
@@ -29,7 +29,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
//! Value object for ICAO classification
|
||||
class BLACKMISC_EXPORT CAircraftIcaoCode :
|
||||
public CValueObject<CAircraftIcaoCode>,
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackMisc
|
||||
QLatin1Literal(" gs: ") % (this->m_groundSpeed.toQString(i18n)) %
|
||||
QLatin1Literal(" elevation: ") % (this->m_groundElevation.toQString(i18n)) %
|
||||
QLatin1Literal(" heading: ") % (this->m_heading.toQString(i18n)) %
|
||||
QLatin1Literal(" timestamp: ") % (this->getFormattedUtcTimestampDhms());
|
||||
QLatin1Literal(" timestamp: ") % (this->hasValidTimestamp() ? this->getFormattedUtcTimestampDhms() : QStringLiteral("-"));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackMisc
|
||||
{ }
|
||||
|
||||
CAirport::CAirport(const CAirportIcaoCode &icao, const BlackMisc::Geo::CCoordinateGeodetic &position, const QString &descriptiveName) :
|
||||
m_icao(icao), m_descriptiveName(descriptiveName), m_position(position)
|
||||
m_descriptiveName(descriptiveName), m_icao(icao), m_position(position)
|
||||
{ }
|
||||
|
||||
void CAirport::updateMissingParts(const CAirport &airport)
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace BlackMisc
|
||||
//! Value object encapsulating information about an airpot.
|
||||
class BLACKMISC_EXPORT CAirport :
|
||||
public CValueObject<CAirport>,
|
||||
public BlackMisc::Db::IDatastoreObjectWithIntegerKey,
|
||||
public Geo::ICoordinateWithRelativePosition
|
||||
public Geo::ICoordinateWithRelativePosition,
|
||||
public BlackMisc::Db::IDatastoreObjectWithIntegerKey
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
@@ -148,23 +148,25 @@ namespace BlackMisc
|
||||
static CAirport fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
|
||||
|
||||
private:
|
||||
CAirportIcaoCode m_icao;
|
||||
QString m_descriptiveName;
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_position;
|
||||
CCountry m_country;
|
||||
bool m_operating;
|
||||
CAirportIcaoCode m_icao;
|
||||
BlackMisc::CCountry m_country;
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_position;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAirport,
|
||||
BLACK_METAMEMBER(dbKey),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch),
|
||||
BLACK_METAMEMBER(icao),
|
||||
BLACK_METAMEMBER(descriptiveName),
|
||||
BLACK_METAMEMBER(position),
|
||||
BLACK_METAMEMBER(country),
|
||||
BLACK_METAMEMBER(operating),
|
||||
// ICoordinateWithRelativePosition
|
||||
BLACK_METAMEMBER(relativeDistance),
|
||||
BLACK_METAMEMBER(relativeBearing)
|
||||
BLACK_METAMEMBER(relativeBearing),
|
||||
// IDatastoreObjectWithIntegerKey
|
||||
BLACK_METAMEMBER(dbKey),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -84,93 +85,49 @@ namespace BlackMisc
|
||||
|
||||
QString CAtcStation::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s = i18n ?
|
||||
QCoreApplication::translate("Aviation", "ATC station") :
|
||||
"ATC station";
|
||||
s.append(' ').append(this->m_callsign.toQString(i18n));
|
||||
static const QString atcI18n(QCoreApplication::translate("Aviation", "ATC station"));
|
||||
static const QString rangeI18n(QCoreApplication::translate("Aviation", "range"));
|
||||
static const QString fromUtcI18n(QCoreApplication::translate("Aviation", "from(UTC)"));
|
||||
static const QString untilUtcI18n(QCoreApplication::translate("Aviation", "until(UTC)"));
|
||||
|
||||
// position
|
||||
s.append(' ').append(this->m_position.toQString(i18n));
|
||||
const QString s = (i18n ? atcI18n : QLatin1Literal("ATC station")) %
|
||||
QLatin1Char(' ') % this->m_callsign.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_position.toQString(i18n) %
|
||||
QLatin1String(" online: ") % boolToYesNo(m_isOnline) %
|
||||
|
||||
// Online?
|
||||
s.append(' ');
|
||||
if (this->m_isOnline)
|
||||
{
|
||||
i18n ? s.append(QCoreApplication::translate("Aviation", "online")) : s.append("online");
|
||||
}
|
||||
else
|
||||
{
|
||||
i18n ? s.append(QCoreApplication::translate("Aviation", "offline")) : s.append("offline");
|
||||
}
|
||||
// controller
|
||||
(!this->m_controller.isValid() ? QStringLiteral("") :
|
||||
QStringLiteral(" ") % this->m_controller.toQString(i18n)) %
|
||||
|
||||
// controller name
|
||||
if (this->m_controller.isValid())
|
||||
{
|
||||
s.append(' ');
|
||||
s.append(this->m_controller.toQString(i18n));
|
||||
}
|
||||
// frequency
|
||||
QLatin1Char(' ') % this->m_frequency.valueRoundedWithUnit(3, i18n) %
|
||||
|
||||
// frequency
|
||||
s.append(' ');
|
||||
s.append(this->m_frequency.valueRoundedWithUnit(3, i18n));
|
||||
// ATIS
|
||||
(!this->hasAtis() ? QStringLiteral("") :
|
||||
QStringLiteral(" ") % this->m_atis.toQString(i18n)) %
|
||||
|
||||
// ATIS
|
||||
if (this->hasAtis())
|
||||
{
|
||||
s.append(' ');
|
||||
s.append(this->m_atis.toQString(i18n));
|
||||
}
|
||||
// METAR
|
||||
(!this->hasMetar() ? QStringLiteral("") :
|
||||
QStringLiteral(" ") % this->m_metar.toQString(i18n)) %
|
||||
|
||||
// METAR
|
||||
if (this->hasMetar())
|
||||
{
|
||||
s.append(' ');
|
||||
s.append(this->m_metar.toQString(i18n));
|
||||
}
|
||||
// range
|
||||
QLatin1Char(' ') % (i18n ? rangeI18n : QLatin1Literal("range")) %
|
||||
QLatin1Char(' ') % this->m_range.toQString(i18n) %
|
||||
|
||||
// range
|
||||
s.append(' ');
|
||||
i18n ? s.append(s.append(QCoreApplication::translate("Aviation", "range"))) : s.append("range");
|
||||
s.append(": ");
|
||||
s.append(this->m_range.toQString(i18n));
|
||||
// distance / bearing
|
||||
QLatin1Char(' ') % ICoordinateWithRelativePosition::convertToQString(i18n) %
|
||||
|
||||
// distance to plane
|
||||
if (this->m_relativeDistance.isPositiveWithEpsilonConsidered())
|
||||
{
|
||||
s.append(' ');
|
||||
i18n ? s.append(QCoreApplication::translate("Aviation", "distance")) : s.append("distance");
|
||||
s.append(' ');
|
||||
s.append(this->m_relativeDistance.toQString(i18n));
|
||||
}
|
||||
// booking from/until
|
||||
QLatin1Char(' ') %
|
||||
(i18n ? fromUtcI18n : QLatin1Literal("from(UTC)")) %
|
||||
QLatin1Char(' ') %
|
||||
(this->m_bookedFromUtc.isNull() ? QLatin1String("-") : this->m_bookedFromUtc.toString("yy-MM-dd HH:mm")) %
|
||||
|
||||
// from / to
|
||||
if (!this->hasBookingTimes()) return s;
|
||||
QLatin1Char(' ') %
|
||||
(i18n ? untilUtcI18n : QLatin1Literal("until(UTC)")) %
|
||||
QLatin1Char(' ') %
|
||||
(this->m_bookedUntilUtc.isNull() ? QLatin1String("-") : this->m_bookedUntilUtc.toString("yy-MM-dd HH:mm"));
|
||||
|
||||
// append from
|
||||
s.append(' ');
|
||||
i18n ? s.append(s.append(QCoreApplication::translate("Aviation", "from(UTC)"))) : s.append("from(UTC)");
|
||||
s.append(": ");
|
||||
if (this->m_bookedFromUtc.isNull())
|
||||
{
|
||||
s.append('-');
|
||||
}
|
||||
else
|
||||
{
|
||||
s.append(this->m_bookedFromUtc.toString("yy-MM-dd HH:mm"));
|
||||
}
|
||||
|
||||
// append to
|
||||
s.append(' ');
|
||||
i18n ? s.append(s.append(QCoreApplication::translate("Aviation", "until(UTC)"))) : s.append("to(UTC)");
|
||||
s.append(": ");
|
||||
if (this->m_bookedFromUtc.isNull())
|
||||
{
|
||||
s.append('-');
|
||||
}
|
||||
else
|
||||
{
|
||||
s.append(this->m_bookedUntilUtc.toString("yy-MM-dd HH:mm"));
|
||||
}
|
||||
return s;
|
||||
|
||||
// force strings for translation in resource files
|
||||
|
||||
@@ -77,17 +77,11 @@ namespace BlackMisc
|
||||
bool isOnline = false, const QDateTime &bookedFromUtc = QDateTime(), const QDateTime &bookedUntilUtc = QDateTime(),
|
||||
const CInformationMessage &atis = CInformationMessage(CInformationMessage::ATIS), const CInformationMessage &metar = CInformationMessage(CInformationMessage::METAR));
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
//! Has booking times?
|
||||
bool hasBookingTimes() const;
|
||||
|
||||
//! Has ATIS?
|
||||
bool hasAtis() const
|
||||
{
|
||||
return this->m_atis.hasMessage();
|
||||
}
|
||||
bool hasAtis() const { return this->m_atis.hasMessage(); }
|
||||
|
||||
//! Has METAR?
|
||||
bool hasMetar() const;
|
||||
@@ -256,6 +250,9 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
private:
|
||||
CCallsign m_callsign;
|
||||
BlackMisc::Network::CUser m_controller;
|
||||
@@ -277,9 +274,9 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(position),
|
||||
BLACK_METAMEMBER(range),
|
||||
BLACK_METAMEMBER(isOnline),
|
||||
BLACK_METAMEMBER(atis),
|
||||
BLACK_METAMEMBER(bookedFromUtc),
|
||||
BLACK_METAMEMBER(bookedUntilUtc),
|
||||
BLACK_METAMEMBER(atis),
|
||||
BLACK_METAMEMBER(metar),
|
||||
BLACK_METAMEMBER(voiceRoom),
|
||||
BLACK_METAMEMBER(relativeDistance),
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace BlackMisc
|
||||
|
||||
QString CCallsign::unifyCallsign(const QString &callsign)
|
||||
{
|
||||
return removeChars(callsign.toUpper(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
|
||||
return removeChars(callsign.toUpper().trimmed(), [](QChar c) { return !c.isLetterOrNumber() && c != '_'; });
|
||||
}
|
||||
|
||||
const CIcon &CCallsign::convertToIcon(const CCallsign &callsign)
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace BlackMisc
|
||||
|
||||
//! Constructor
|
||||
CCallsign(const QString &callsign, TypeHint hint = NoHint)
|
||||
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign.trimmed())), m_typeHint(hint)
|
||||
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign)), m_typeHint(hint)
|
||||
{}
|
||||
|
||||
//! Constructor
|
||||
CCallsign(const QString &callsign, const QString &telephonyDesignator, TypeHint hint = NoHint)
|
||||
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign.trimmed())), m_telephonyDesignator(telephonyDesignator.trimmed()), m_typeHint(hint)
|
||||
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign)), m_telephonyDesignator(telephonyDesignator.trimmed()), m_typeHint(hint)
|
||||
{}
|
||||
|
||||
//! Constructor, needed to disambiguate implicit conversion from string literal.
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
QString CInformationMessage::convertToQString(bool /** i18n **/) const
|
||||
QString CInformationMessage::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return this->m_message;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,5 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -29,9 +29,7 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CInformationMessage : public CValueObject<CInformationMessage>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Type
|
||||
*/
|
||||
//! Type
|
||||
enum InformationType
|
||||
{
|
||||
Unspecified,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
#include <tuple>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Db;
|
||||
@@ -69,9 +70,7 @@ namespace BlackMisc
|
||||
QString s(getCombinedCode());
|
||||
if (!this->getDescription().isEmpty())
|
||||
{
|
||||
s += " (";
|
||||
s += this->getDescription();
|
||||
s += ")";
|
||||
s += QLatin1Literal(" (") % this->getDescription() % QLatin1Literal(")");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -117,20 +116,16 @@ namespace BlackMisc
|
||||
|
||||
QString CLivery::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(i18n ? QCoreApplication::translate("Aviation", "Livery") : "Livery");
|
||||
if (this->hasCombinedCode())
|
||||
{
|
||||
s.append(' ');
|
||||
s.append(m_combinedCode);
|
||||
}
|
||||
s.append(' ');
|
||||
s.append(this->m_airline.toQString(i18n));
|
||||
s.append(' ');
|
||||
if (!this->m_description.isEmpty()) { s.append(' ').append(this->m_description); }
|
||||
if (this->m_colorFuselage.isValid()) { s.append(" F: ").append(this->m_colorFuselage.hex()); }
|
||||
if (this->m_colorTail.isValid()) { s.append(" T: ").append(this->m_colorTail.hex()); }
|
||||
s.append(" Mil: ").append(boolToYesNo(this->isMilitary()));
|
||||
return s;
|
||||
static const QString livery("Livery");
|
||||
static const QString liveryI18n(QCoreApplication::translate("Aviation", "Livery"));
|
||||
|
||||
return (i18n ? liveryI18n : livery) %
|
||||
QLatin1Literal(" cc: '") % m_combinedCode %
|
||||
QLatin1Literal("' airline: '") % m_airline.toQString(i18n) %
|
||||
QLatin1Literal("' desc.: '") % m_description %
|
||||
QLatin1Literal("' F: '") % m_colorFuselage.hex() %
|
||||
QLatin1Literal("' T: '") % m_colorTail.hex() %
|
||||
QLatin1Literal("' Mil: ") % boolToYesNo(this->isMilitary());
|
||||
|
||||
// force strings for translation in resource files
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "Livery");
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace BlackMisc
|
||||
CAircraftSituationList::registerMetadata();
|
||||
CAirlineIcaoCode::registerMetadata();
|
||||
CAirlineIcaoCodeList::registerMetadata();
|
||||
CAirport::registerMetadata();
|
||||
CAirportIcaoCode::registerMetadata();
|
||||
CAirport::registerMetadata();
|
||||
CAirportList::registerMetadata();
|
||||
CAltitude::registerMetadata();
|
||||
CAtcStation::registerMetadata();
|
||||
|
||||
@@ -25,6 +25,33 @@ namespace BlackMisc
|
||||
qRegisterMetaType<TransponderMode>();
|
||||
}
|
||||
|
||||
CTransponder::CTransponder(int transponderCode, CTransponder::TransponderMode transponderMode) :
|
||||
m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
||||
{ }
|
||||
|
||||
CTransponder::CTransponder(int transponderCode, QString transponderMode) :
|
||||
m_transponderCode(transponderCode), m_transponderMode(StateStandby)
|
||||
{
|
||||
this->setModeAsString(transponderMode);
|
||||
}
|
||||
|
||||
CTransponder::CTransponder(QString transponderCode, CTransponder::TransponderMode transponderMode) :
|
||||
m_transponderCode(0), m_transponderMode(transponderMode)
|
||||
{
|
||||
bool ok = false;
|
||||
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||
}
|
||||
|
||||
CTransponder::CTransponder(QString transponderCode, QString transponderMode) :
|
||||
m_transponderCode(0), m_transponderMode(StateStandby)
|
||||
{
|
||||
bool ok = false;
|
||||
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||
this->setModeAsString(transponderMode);
|
||||
}
|
||||
|
||||
bool CTransponder::validValues() const
|
||||
{
|
||||
if (this->isDefaultValue()) return true; // special case
|
||||
@@ -62,11 +89,11 @@ namespace BlackMisc
|
||||
if (modeString.startsWith("Mode C", Qt::CaseInsensitive)) return ModeC;
|
||||
if (modeString.startsWith("C", Qt::CaseInsensitive)) return ModeC;
|
||||
if (modeString.startsWith("Mode S", Qt::CaseInsensitive)) return ModeS;
|
||||
if (modeString.contains("Mode 1", Qt::CaseInsensitive)) return ModeMil1;
|
||||
if (modeString.contains("Mode 2", Qt::CaseInsensitive)) return ModeMil2;
|
||||
if (modeString.contains("Mode 3", Qt::CaseInsensitive)) return ModeMil3;
|
||||
if (modeString.contains("Mode 4", Qt::CaseInsensitive)) return ModeMil4;
|
||||
if (modeString.contains("Mode 5", Qt::CaseInsensitive)) return ModeMil5;
|
||||
if (modeString.contains("1", Qt::CaseInsensitive)) return ModeMil1;
|
||||
if (modeString.contains("2", Qt::CaseInsensitive)) return ModeMil2;
|
||||
if (modeString.contains("3", Qt::CaseInsensitive)) return ModeMil3;
|
||||
if (modeString.contains("4", Qt::CaseInsensitive)) return ModeMil4;
|
||||
if (modeString.contains("5", Qt::CaseInsensitive)) return ModeMil5;
|
||||
return StateStandby;
|
||||
}
|
||||
|
||||
@@ -114,6 +141,11 @@ namespace BlackMisc
|
||||
return CTransponder::isValidTransponderCode(QString::number(transponderCode));
|
||||
}
|
||||
|
||||
CTransponder CTransponder::getStandardTransponder(qint32 transponderCode, CTransponder::TransponderMode mode)
|
||||
{
|
||||
return CTransponder(transponderCode, mode);
|
||||
}
|
||||
|
||||
const QString &CTransponder::modeAsString(CTransponder::TransponderMode mode)
|
||||
{
|
||||
static QString m;
|
||||
@@ -206,6 +238,5 @@ namespace BlackMisc
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
namespace Aviation
|
||||
{
|
||||
//! Transponder
|
||||
@@ -37,9 +36,9 @@ namespace BlackMisc
|
||||
//! Transponder codes
|
||||
enum TransponderMode
|
||||
{
|
||||
StateStandby = 0, // not a real mode, more a state
|
||||
StateStandby = 0, //!< not a real mode, more a state
|
||||
ModeMil1 = 1, ModeMil2 = 2, ModeMil3 = 3, ModeMil4 = 4, ModeMil5 = 5,
|
||||
StateIdent = 10, // not a real mode, more a state
|
||||
StateIdent = 10, //!< not a real mode, more a state
|
||||
ModeA = 11,
|
||||
ModeC = 12,
|
||||
ModeS = 20
|
||||
@@ -62,44 +61,22 @@ namespace BlackMisc
|
||||
CTransponder() : m_transponderCode(0), m_transponderMode(StateStandby) {}
|
||||
|
||||
//! Constructor
|
||||
CTransponder(int transponderCode, TransponderMode transponderMode) :
|
||||
m_transponderCode(transponderCode), m_transponderMode(transponderMode)
|
||||
{ }
|
||||
CTransponder(int transponderCode, TransponderMode transponderMode);
|
||||
|
||||
//! Constructor with transponder mode as string
|
||||
CTransponder(int transponderCode, QString transponderMode) :
|
||||
m_transponderCode(transponderCode), m_transponderMode(StateStandby)
|
||||
{
|
||||
this->setModeAsString(transponderMode);
|
||||
}
|
||||
CTransponder(int transponderCode, QString transponderMode);
|
||||
|
||||
//! Constructor, code as string
|
||||
CTransponder(QString transponderCode, TransponderMode transponderMode) :
|
||||
m_transponderCode(0), m_transponderMode(transponderMode)
|
||||
{
|
||||
bool ok = false;
|
||||
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||
}
|
||||
CTransponder(QString transponderCode, TransponderMode transponderMode);
|
||||
|
||||
//! Constructor
|
||||
CTransponder(QString transponderCode, QString transponderMode) :
|
||||
m_transponderCode(0), m_transponderMode(StateStandby)
|
||||
{
|
||||
bool ok = false;
|
||||
this->m_transponderCode = transponderCode.toInt(&ok);
|
||||
if (!ok) this->m_transponderCode = -1; // will cause assert / exception
|
||||
this->setModeAsString(transponderMode);
|
||||
}
|
||||
CTransponder(QString transponderCode, QString transponderMode);
|
||||
|
||||
//! Are set values valid?
|
||||
bool validValues() const;
|
||||
|
||||
//! Transponder mode as string
|
||||
QString getModeAsString() const
|
||||
{
|
||||
return modeAsString(this->getTransponderMode());
|
||||
}
|
||||
QString getModeAsString() const { return modeAsString(this->getTransponderMode()); }
|
||||
|
||||
//! In any sending mode such as MIL1 oder ModeS
|
||||
bool isInNormalSendingMode() const;
|
||||
@@ -111,25 +88,16 @@ namespace BlackMisc
|
||||
bool isIdentifying() const { return StateIdent == m_transponderMode; }
|
||||
|
||||
//! Transponder mode as string
|
||||
void setModeAsString(const QString &mode)
|
||||
{
|
||||
this->setTransponderMode(CTransponder::modeFromString(mode));
|
||||
}
|
||||
void setModeAsString(const QString &mode) { this->setTransponderMode(CTransponder::modeFromString(mode)); }
|
||||
|
||||
//! Transponder mode
|
||||
TransponderMode getTransponderMode() const
|
||||
{
|
||||
return this->m_transponderMode;
|
||||
}
|
||||
TransponderMode getTransponderMode() const { return this->m_transponderMode; }
|
||||
|
||||
//! Transponder mode as string
|
||||
static const QString &modeAsString(TransponderMode mode);
|
||||
|
||||
//! Transponder code
|
||||
int getTransponderCode() const
|
||||
{
|
||||
return this->m_transponderCode;
|
||||
}
|
||||
int getTransponderCode() const { return this->m_transponderCode; }
|
||||
|
||||
//! Transponder code
|
||||
QString getTransponderCodeFormatted() const;
|
||||
@@ -158,26 +126,23 @@ namespace BlackMisc
|
||||
//! Set IFR
|
||||
void setIFR() { this->m_transponderCode = 2000; }
|
||||
|
||||
//! Transponder unit
|
||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
|
||||
{
|
||||
return CTransponder(transponderCode, mode);
|
||||
}
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Is valid transponder code?
|
||||
static bool isValidTransponderCode(const QString &transponderCode);
|
||||
|
||||
//! Is valid transponder code?
|
||||
static bool isValidTransponderCode(qint32 transponderMode);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
//! Transponder unit
|
||||
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode);
|
||||
|
||||
private:
|
||||
//! Default value?
|
||||
@@ -192,7 +157,6 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(transponderMode)
|
||||
);
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
CDBusServer::CDBusServer(const QString &service, const QString &address, QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_serverMode = modeOfAddress(address);
|
||||
@@ -347,7 +346,7 @@ namespace BlackMisc
|
||||
|
||||
QString CDBusServer::normalizeAddress(const QString &address)
|
||||
{
|
||||
QString lc(address.toLower().trimmed());
|
||||
const QString lc(address.toLower().trimmed());
|
||||
|
||||
if (lc.isEmpty()) { return sessionBusAddress(); }
|
||||
if (lc == sessionBusAddress() || lc == systemBusAddress()) { return lc; }
|
||||
@@ -400,8 +399,8 @@ namespace BlackMisc
|
||||
{
|
||||
QString name = coreServiceName();
|
||||
QDBusConnection connection = dbusAddress == systemBusAddress() ?
|
||||
QDBusConnection::connectToBus(QDBusConnection::SystemBus, name) :
|
||||
QDBusConnection::connectToBus(QDBusConnection::SessionBus, name);
|
||||
QDBusConnection::connectToBus(QDBusConnection::SystemBus, name) :
|
||||
QDBusConnection::connectToBus(QDBusConnection::SessionBus, name);
|
||||
|
||||
// todo: further checks would need to go here
|
||||
// failing session bus not detected yet
|
||||
@@ -419,5 +418,4 @@ namespace BlackMisc
|
||||
QString unused;
|
||||
return isDBusAvailable(dbusAddress, unused, timeoutMs);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
#include <cmath>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -144,6 +145,14 @@ namespace BlackMisc
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString ICoordinateGeodetic::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return this->latitudeAsString() % QLatin1Char(' ') %
|
||||
this->longitudeAsString() % QLatin1Char(' ') %
|
||||
this->geodeticHeightAsString();
|
||||
}
|
||||
|
||||
CVariant CCoordinateGeodetic::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
@@ -328,6 +337,13 @@ namespace BlackMisc
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString ICoordinateWithRelativePosition::convertToQString(bool i18n) const
|
||||
{
|
||||
return m_relativeBearing.toQString(i18n) % QLatin1Char(' ') %
|
||||
m_relativeDistance.toQString(i18n) % QLatin1Char(' ') %
|
||||
ICoordinateGeodetic::convertToQString(i18n);
|
||||
}
|
||||
|
||||
ICoordinateWithRelativePosition::ICoordinateWithRelativePosition()
|
||||
{ }
|
||||
|
||||
|
||||
@@ -104,6 +104,9 @@ namespace BlackMisc
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
protected:
|
||||
//! Can given index be handled?
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
@@ -165,6 +168,9 @@ namespace BlackMisc
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
ICoordinateWithRelativePosition();
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include <QtGlobal>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
CPixmap::CPixmap(const QPixmap &pixmap) : m_pixmap(pixmap), m_hasCachedPixmap(true)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define BLACKMISC_SAMPLEUTILS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -24,7 +23,6 @@ namespace BlackMisc
|
||||
//! Utils for sample programms
|
||||
class BLACKMISC_EXPORT CSampleUtils
|
||||
{
|
||||
|
||||
public:
|
||||
//! Select directory among given ones
|
||||
static QString selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -56,18 +57,12 @@ namespace BlackMisc
|
||||
|
||||
QString CAircraftModel::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s = this->m_modelString;
|
||||
if (!s.isEmpty()) { s += " type: "; }
|
||||
s += this->getModelTypeAsString();
|
||||
s += ' ';
|
||||
s += this->getAircraftIcaoCode().toQString(i18n);
|
||||
s += ' ';
|
||||
s += this->m_livery.toQString(i18n);
|
||||
if (!this->m_fileName.isEmpty())
|
||||
{
|
||||
s += ' ';
|
||||
s += m_fileName;
|
||||
}
|
||||
const QString s =
|
||||
this->m_modelString %
|
||||
QLatin1Literal(" type: '") % this->getModelTypeAsString() %
|
||||
QLatin1Literal("' ICAO: '") % this->getAircraftIcaoCode().toQString(i18n) %
|
||||
QLatin1Literal("' {") % this->m_livery.toQString(i18n) %
|
||||
QLatin1Literal("} file: '") % this->m_fileName % QLatin1Literal("'");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -149,14 +144,9 @@ namespace BlackMisc
|
||||
{
|
||||
if (this->hasValidDbKey())
|
||||
{
|
||||
if (this->hasModelString())
|
||||
{
|
||||
return QString(this->getModelString()).append(" ").append(this->getDbKeyAsStringInParentheses());
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->getDbKeyAsString();
|
||||
}
|
||||
return this->hasModelString() ?
|
||||
QString(this->getModelString()).append(" ").append(this->getDbKeyAsStringInParentheses()) :
|
||||
this->getDbKeyAsString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,7 +165,7 @@ namespace BlackMisc
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::propertyByIndex(index); }
|
||||
if (IOrderable::canHandleIndex(index)) { return IOrderable::propertyByIndex(index);}
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
@@ -229,7 +219,7 @@ namespace BlackMisc
|
||||
if (IOrderable::canHandleIndex(index)) { IOrderable::setPropertyByIndex(index, variant); return; }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant); return; }
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <tuple>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -530,24 +530,15 @@ namespace BlackMisc
|
||||
|
||||
QString CSimulatedAircraft::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->m_callsign.toQString(i18n));
|
||||
s += " ";
|
||||
s += this->m_pilot.toQString(i18n);
|
||||
s += " ";
|
||||
s += this->m_situation.toQString(i18n);
|
||||
s += " ";
|
||||
s += this->m_com1system.toQString(i18n);
|
||||
s += " ";
|
||||
s += this->m_com2system.toQString(i18n);
|
||||
s += " ";
|
||||
s += this->m_transponder.toQString(i18n);
|
||||
s += " enabled: ";
|
||||
s += BlackMisc::boolToYesNo(this->isEnabled());
|
||||
s += " ";
|
||||
s += " rendered: ";
|
||||
s += BlackMisc::boolToYesNo(this->isRendered());
|
||||
s += " ";
|
||||
s += this->m_model.toQString(i18n);
|
||||
const QString s = this->m_callsign.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_pilot.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_situation.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_com1system.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_com2system.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_transponder.toQString(i18n) %
|
||||
QLatin1Literal(" enabled: ") % BlackMisc::boolToYesNo(this->isEnabled()) %
|
||||
QLatin1Literal(" rendered: ") % BlackMisc::boolToYesNo(this->isRendered()) %
|
||||
QLatin1Char(' ') % this->getModel().toQString(i18n);
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATEDAIRCRAFT_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATEDAIRCRAFT_H
|
||||
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/aviation/aircraftlights.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
@@ -21,18 +22,17 @@
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/aviation/selcal.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/pq/frequency.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
@@ -100,9 +100,6 @@ namespace BlackMisc
|
||||
//! Constructor.
|
||||
CSimulatedAircraft(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Network::CUser &user, const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
//! Get callsign.
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_callsign; }
|
||||
|
||||
@@ -137,7 +134,6 @@ namespace BlackMisc
|
||||
bool setAircraftIcaoCode(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode) { return m_model.setAircraftIcaoCode(aircraftIcaoCode);}
|
||||
|
||||
//! Set ICAO info
|
||||
//! \deprecated
|
||||
bool setIcaoCodes(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode, const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcaoCode);
|
||||
|
||||
//! Get livery
|
||||
@@ -329,12 +325,6 @@ namespace BlackMisc
|
||||
//! Combined ICAO / color string
|
||||
QString getCombinedIcaoLiveryString(bool networkModel = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CSimulatedAircraft &compareValue) const;
|
||||
|
||||
@@ -407,9 +397,18 @@ namespace BlackMisc
|
||||
//! Set the synchronisation flag
|
||||
void setPartsSynchronized(bool synchronized) { m_partsSynchronized = synchronized; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CCallsign m_callsign;
|
||||
BlackMisc::Network::CUser m_pilot;
|
||||
|
||||
Reference in New Issue
Block a user