refs #452, adjusted aircraft/aviation classes

* support for loading from datastore
* improved timestamp handling
* new color and country classes
* new attributes
* updates for missing parts in CUser
This commit is contained in:
Klaus Basan
2015-09-23 03:20:36 +02:00
committed by Mathew Sutcliffe
parent c5f7179588
commit ae24700299
45 changed files with 2762 additions and 401 deletions

View File

@@ -17,11 +17,14 @@
#include "blackmisc/propertyindex.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/datastore.h"
#include "blackmisc/statusmessagelist.h"
namespace BlackMisc
{
namespace Aviation
{
class CAirlineIcaoCode;
//! Value object for ICAO classification
class BLACKMISC_EXPORT CAircraftIcaoCode :
public CValueObject<CAircraftIcaoCode>,
@@ -40,6 +43,8 @@ namespace BlackMisc
IndexIsMilitary,
IndexIsLegacy,
IndexIsVtol,
IndexRank,
IndexDesignatorManufacturer
};
//! Default constructor.
@@ -50,7 +55,7 @@ namespace BlackMisc
//! Constructor
CAircraftIcaoCode(const QString &icao, const QString &combinedType, const QString &manufacturer,
const QString &model, const QString &wtc, bool realworld, bool legacy, bool military);
const QString &model, const QString &wtc, bool realworld, bool legacy, bool military, int rank);
//! Get ICAO designator, e.g. "B737"
const QString &getDesignator() const { return m_designator; }
@@ -68,26 +73,44 @@ namespace BlackMisc
const QString &getCombinedType() const { return this->m_combinedType; }
//! Combined type available?
bool hasCombinedType() const { return this->getCombinedType().length() == 3; }
bool hasValidCombinedType() const;
//! Get engine type, e.g. "J"
QString getEngineType() const;
//! Engine count if any, -1 if no value is set
int getEngineCount() const;
//! Engine count as string, if not available ""
QString getEngineCountString() const;
//! Aircraft type, such a L(andplane), S(eaplane), H(elicopter)
QString getAircraftType() const;
//! Set type
void setCombinedType(const QString &type) { this->m_combinedType = type.trimmed().toUpper(); }
//! Get model description, e.g. "A-330-200"
const QString &getModelDescription() const { return m_modelDescription; }
//! Designator + Manufacturer
QString getDesignatorManufacturer() const;
//! Set the model description
void setModelDescription(const QString &modelDescription) { m_modelDescription = modelDescription.trimmed(); }
//! Has model description
bool hasModelDescription() const { return !this->m_modelDescription.isEmpty(); }
//! Get manufacturer, e.g. "Airbus"
const QString &getManufacturer() const { return m_manufacturer; }
//! Set the manufacturer
void setManufacturer(const QString &manufacturer) { m_manufacturer = manufacturer.trimmed(); }
//! Manufacturer
bool hasManufacturer() const;
//! Get WTC
const QString &getWtc() const { return m_wtc; }
@@ -100,9 +123,45 @@ namespace BlackMisc
//! Is VTOL aircraft (helicopter, tilt wing)
bool isVtol() const;
//! Military?
bool isMilitary() const { return m_military; }
//! Real world aircraft?
bool isRealWorld() const { return m_realWorld; }
//! Legacy aircraft
bool isLegacyAircraft() const { return m_legacy; }
//! Flags
void setCodeFlags(bool military, bool legacy, bool realWorld);
//! Military
void setMilitary(bool military);
//! Real world
void setRealWorld(bool realWorld);
//! Legacy
void setLegacy(bool legacy);
//! Ranking
int getRank() const { return m_rank; }
//! Ranking
QString getRankString() const;
//! Ranking
void setRank(int rank);
//! Comined descriptive string with key
QString getCombinedStringWithKey() const;
//! All data set?
bool hasCompleteData() const;
//! Matches designator string?
bool matchesDesignator(const QString &designator) const;
//! \copydoc CValueObject::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
@@ -112,14 +171,23 @@ namespace BlackMisc
//! \copydoc CValueObject::convertToQString
QString convertToQString(bool i18n = false) const;
//! Update missing parts
void updateMissingParts(const CAircraftIcaoCode &otherIcaoCode);
//! Validate data
BlackMisc::CStatusMessageList validate() const;
//! Valid designator?
static bool isValidDesignator(const QString &designator);
//! Valid combined type
static bool isValidCombinedType(const QString &combinedType);
//! Valid WTC code?
static bool isValidWtc(const QString &candidate);
//! From our database JSON format
static CAircraftIcaoCode fromDatabaseJson(const QJsonObject &json);
static CAircraftIcaoCode fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
private:
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftIcaoCode)
@@ -127,14 +195,17 @@ namespace BlackMisc
QString m_combinedType; //!< "L2J"
QString m_manufacturer; //!< "Airbus"
QString m_modelDescription; //!< "A-330-200"
QString m_wtc; //!< wake turbulence "M","H" "L/M", "L"
bool m_realworld = true; //!< real world aircraft
QString m_wtc; //!< wake turbulence "M","H" "L/M", "L", we only use the one letter versions
bool m_realWorld = true; //!< real world aircraft
bool m_legacy = false; //!< legacy code
bool m_military = false; //!< military aircraft?
int m_rank = 10; //!< rank among same codes
//! Create a combined string like L2J
static QString createdCombinedString(const QString &type, const QString &engineCount, const QString &engine);
//! Create a combined string like L2J
static QString createdCombinedString(const QString &type, int engineCount, const QString &engine);
};
} // namespace
} // namespace
@@ -142,14 +213,16 @@ namespace BlackMisc
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftIcaoCode)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftIcaoCode, (
o.m_dbKey,
o.m_timestampMSecsSinceEpoch,
o.m_designator,
o.m_combinedType,
o.m_manufacturer,
o.m_modelDescription,
o.m_wtc,
o.m_military,
o.m_realworld,
o.m_legacy
o.m_realWorld,
o.m_legacy,
o.m_rank
))
#endif // guard