7 #include <QJsonDocument>
12 #include <QStringBuilder>
26 using namespace swift::config;
27 using namespace swift::misc::aviation;
28 using namespace swift::misc::physical_quantities;
29 using namespace swift::misc::db;
33 namespace swift::misc::simulation
35 void CAircraftModel::registerMetadata()
38 qRegisterMetaType<ModelType>();
42 : m_modelString(model.trimmed().toUpper()), m_modelType(type)
47 : m_aircraftIcao(icao), m_livery(livery), m_modelString(model.trimmed().toUpper()), m_modelType(type)
52 : m_aircraftIcao(icao), m_livery(livery), m_modelString(model.trimmed().toUpper()),
53 m_description(description.trimmed()), m_modelType(type)
57 const CSimulatorInfo &simulator,
const QString &name,
const QString &description)
58 : m_simulator(simulator), m_modelString(model.trimmed().toUpper()), m_name(name.trimmed()),
59 m_description(description.trimmed()), m_modelType(type)
63 const CSimulatorInfo &simulator,
const QString &name,
const QString &description,
65 : m_aircraftIcao(icao), m_livery(livery), m_simulator(simulator), m_modelString(model.trimmed().toUpper()),
66 m_name(name.trimmed()), m_description(description.trimmed()), m_modelType(type)
77 u
"} file: '" % m_fileName % u
'\'';
87 obj.insert(
"name", this->
getName());
88 obj.insert(
"modelstring", QJsonValue(m_modelString));
89 obj.insert(
"description", QJsonValue(m_description));
90 obj.insert(
"parts", QJsonValue(m_supportedParts));
91 obj.insert(
"version", CBuildConfig::getVersionString());
95 obj.insert(
"cgft", QJsonValue());
97 else { obj.insert(
"cgft", QJsonValue(m_cg.
value(CLengthUnit::ft()))); }
101 QString flag = CDatastoreUtility::boolToDbYN(sim.
isFSX());
102 obj.insert(
"simfsx", QJsonValue(flag));
103 flag = CDatastoreUtility::boolToDbYN(sim.
isP3D());
104 obj.insert(
"simp3d", QJsonValue(flag));
105 flag = CDatastoreUtility::boolToDbYN(sim.
isFS9());
106 obj.insert(
"simfs9", QJsonValue(flag));
107 flag = CDatastoreUtility::boolToDbYN(sim.
isMSFS());
108 obj.insert(
"simmsfs", QJsonValue(flag));
109 flag = CDatastoreUtility::boolToDbYN(sim.
isMSFS2024());
110 obj.insert(
"simmsfs2024", QJsonValue(flag));
111 flag = CDatastoreUtility::boolToDbYN(sim.
isXPlane());
112 obj.insert(
"simxplane", QJsonValue(flag));
113 flag = CDatastoreUtility::boolToDbYN(sim.
isFG());
114 obj.insert(
"simfg", QJsonValue(flag));
135 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
138 auto &&maybeMemo = helper.
maybeMemoize(member.in(*
this));
147 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
151 if (it != json.end()) { it.value() >> helper.
maybeUnmemoize(member.in(*
this)).get(); }
158 return QStringLiteral(
159 "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10")
165 .replace(
" ",
" ");
212 m_callsign = callsign;
230 return m_modelString % u
", " % m_modelStringAlias;
244 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
245 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
247 return IDatastoreObjectWithIntegerKey::propertyByIndex(index);
254 case IndexModelString:
return QVariant(m_modelString);
255 case IndexModelStringAlias:
return QVariant(m_modelStringAlias);
258 case IndexModelType:
return QVariant::fromValue(m_modelType);
260 case IndexModelMode:
return QVariant::fromValue(m_modelMode);
265 case IndexSimulatorInfoAsString:
return QVariant(m_simulator.
toQString());
266 case IndexDescription:
return QVariant(m_description);
267 case IndexName:
return QVariant(m_name);
268 case IndexFileName:
return QVariant(m_fileName);
270 case IndexSupportedParts:
return QVariant(m_supportedParts);
271 case IndexFileTimestamp:
return QVariant::fromValue(this->
getFileTimestamp());
293 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
295 IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant);
302 case IndexModelString: m_modelString = variant.toString();
break;
303 case IndexModelStringAlias: m_modelStringAlias = variant.toString();
break;
307 case IndexDescription: m_description = variant.toString();
break;
309 case IndexName: m_name = variant.toString();
break;
312 case IndexModelType: m_modelType = variant.value<
ModelType>();
break;
313 case IndexFileName: m_fileName = variant.toString();
break;
318 case IndexFileTimestamp:
319 if (variant.canConvert<QDateTime>()) { this->
setFileTimestamp(variant.value<QDateTime>()); }
320 else if (variant.canConvert<qint64>()) { m_fileTimestamp = variant.value<qint64>(); }
323 if (
static_cast<QMetaType::Type
>(variant.type()) == QMetaType::QString)
327 else { m_modelMode = variant.value<
ModelMode>(); }
330 case IndexHasQueriedModelString:
break;
331 case IndexModelTypeAsString:
break;
332 case IndexModelModeAsString:
break;
333 case IndexModelModeAsIcon:
break;
334 case IndexFileTimestampFormattedYmdhms:
break;
335 case IndexSimulatorInfoAsString:
break;
336 case IndexMembersDbStatus:
break;
344 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
346 return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);
349 if (index.
isMyself()) {
return m_modelString.compare(compareValue.
getModelString(), Qt::CaseInsensitive); }
353 case IndexModelString:
return m_modelString.compare(compareValue.
getModelString(), Qt::CaseInsensitive);
354 case IndexModelStringAlias:
355 return m_modelStringAlias.compare(compareValue.
getModelStringAlias(), Qt::CaseInsensitive);
358 Qt::CaseInsensitive);
359 case IndexHasQueriedModelString:
361 case IndexAircraftIcaoCode:
364 case IndexDistributor:
366 case IndexDescription:
return m_description.compare(compareValue.
getDescription(), Qt::CaseInsensitive);
367 case IndexName:
return m_name.compare(compareValue.
getName(), Qt::CaseInsensitive);
370 case IndexFileName:
return m_fileName.compare(compareValue.
getFileName(), Qt::CaseInsensitive);
372 case IndexSupportedParts:
return m_supportedParts.compare(compareValue.
getSupportedParts());
373 case IndexModelTypeAsString:
374 case IndexModelType:
return Compare::compare(m_modelType, compareValue.
getModelType());
375 case IndexSimulatorInfoAsString:
376 case IndexSimulatorInfo:
378 case IndexFileTimestamp:
379 case IndexFileTimestampFormattedYmdhms:
return Compare::compare(m_fileTimestamp, compareValue.m_fileTimestamp);
381 case IndexModelModeAsString:
382 case IndexModelModeAsIcon:
return Compare::compare(m_modelMode, compareValue.
getModelMode());
386 Q_ASSERT_X(
false, Q_FUNC_INFO,
"No comparison");
392 if (m_aircraftIcao == aircraftIcaoCode) {
return false; }
393 m_aircraftIcao = aircraftIcaoCode;
405 m_aircraftIcao = aircraftIcaoCode;
436 if (order < 0) {
return false; }
444 if (distributors.
isEmpty()) {
return false; }
446 const int noDistributorOrder = distributors.
size();
455 else { m_distributor.
setOrder(noDistributorOrder); }
457 else { m_distributor.
setOrder(noDistributorOrder); }
477 if (distributors.
isEmpty()) {
return false; }
489 if (mode == All) {
return true; }
490 return (mode & m_modelMode) > 0;
500 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"wrong mode");
break;
512 return (
static_cast<int>(simulator.
getSimulator()) &
static_cast<int>(this->getSimulator().getSimulator())) > 0;
522 return this->
hasValidFileTimestamp() ? QDateTime::fromMSecsSinceEpoch(m_fileTimestamp, Qt::UTC) : QDateTime();
534 m_fileTimestamp = timestampUtc.isValid() ? timestampUtc.toMSecsSinceEpoch() : -1;
542 const QDateTime modified = fileInfo.lastModified();
543 if (modified.isValid())
550 const QDateTime created = fileInfo.lastModified();
558 static const QString p(
"swift_");
570 if (!aircraftIcao && !livery && !model) {
return QString(); }
593 for (
int c = 0; c < ls.length(); c++)
595 const QChar m = ls[c];
596 if ((m ==
'm' || m ==
'a' || m ==
'l') && (c + 1) < ls.length())
598 const int cs = c + 1;
600 while (cc < ls.length() && ls[cc].isDigit()) { cc++; }
603 const QString idString = ls.mid(cs, cc - cs);
604 const int id = idString.toInt();
607 if (m ==
'm') { ids.
model = id; }
608 else if (m ==
'a') { ids.
aircraft = id; }
609 else if (m ==
'l') { ids.
livery = id; }
630 if (m_fileTimestamp < 0 || otherModel.m_fileTimestamp > m_fileTimestamp)
642 if (m_modelType == TypeUnknown) { m_modelType = otherModel.
getModelType(); }
643 if (m_modelMode == Undefined) { m_modelType = otherModel.
getModelType(); }
677 if (m_description.isEmpty()) {
return false; }
678 if (!ignoreAutoGenerated) {
return true; }
686 return (this->
isLoadedFromDb() ? QStringLiteral(
"M") : QStringLiteral(
"m")) %
690 QStringLiteral(
"C-") :
693 QStringLiteral(
"a")));
722 if (stripModelDirIndicator.isEmpty())
724 QString strip = md.mid(md.lastIndexOf(
'/'));
725 i = m_fileName.lastIndexOf(strip);
727 else { i = m_fileName.lastIndexOf(stripModelDirIndicator); }
728 if (i < 0) {
return false; }
737 if (!fi.exists()) {
return false; }
738 const bool r = fi.isReadable();
746 return fi.absoluteDir();
758 if (path.isEmpty() || p.isEmpty()) {
return false; }
759 if (path.startsWith(
'/'))
761 if (path.endsWith(
'/')) {
return p.contains(path.mid(1, path.length() - 2), cs); }
762 return p.contains(path.mid(1));
764 if (path.endsWith(
'/')) {
return p.contains(path.left(path.length() - 1), cs); }
765 return (p.contains(path, cs));
770 return stringCompare(modelString, m_modelString, sensitivity);
776 return stringCompare(modelString, m_modelStringAlias, sensitivity);
784 CCallsign::addLogDetailsToList(
786 QStringLiteral(
"ICAO score: %1 | livery score: %2").arg(icaoScore).arg(liveryScore));
787 return qRound(0.5 * (icaoScore + liveryScore));
806 if (withNestedObjects)
817 const QString &oldValue,
const QString &newValue)
822 u
"Model '%1' same %2 '%3'");
828 u
"Model '%1' changed %2 '%3'->'%4'");
839 if (details) { details->
push_back(msgNoDbModel); }
844 bool changed =
false;
848 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"livery"),
850 this->getLivery().getCombinedCodePlusInfoAndId()));
858 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"aircraft ICAO"),
860 this->getAircraftIcaoCode().getDesignatorDbKey()));
867 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"distributor"),
869 this->getDistributor().getDescription()));
876 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"simulator"),
878 this->getSimulator().toQString()));
886 this->getDescription()));
894 equalMessage(equal, *
this, QStringLiteral(
"name"), dbModel.
getName(), this->getName()));
902 this->getModelModeAsString()));
910 this->getCG().toQString(
true)));
917 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"Supported parts"),
923 if (changed && details)
929 if (details) { details->
push_back(validationMsgs); }
935 static const QString queried(
"queried");
936 static const QString matching(
"matching");
937 static const QString db(
"database");
938 static const QString def(
"map.default");
939 static const QString ownSim(
"own simulator");
940 static const QString set(
"manually set");
941 static const QString fsinn(
"FSInn");
942 static const QString probe(
"probe");
943 static const QString reverse(
"reverse lookup");
944 static const QString unknown(
"unknown");
958 default:
return unknown;
965 if (n.count(
'/') < 2) {
return n; }
966 return n.section(
'/', -2, -1);
971 if (mode.isEmpty() || mode.startsWith(
'I', Qt::CaseInsensitive)) {
return Include; }
972 if (mode.startsWith(
'E', Qt::CaseInsensitive)) {
return Exclude; }
979 static const QString i(
"Include");
980 static const QString e(
"Exclude");
984 case Include:
return i;
985 case Exclude:
return e;
986 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"wrong mode");
991 CAircraftModel CAircraftModel::fromDatabaseJsonBaseImpl(
const QJsonObject &json,
const QString &prefix,
995 const QString modelString(json.value(prefix % u
"modelstring").toString());
996 const QString modelStringAlias(json.value(prefix % u
"modelstringalias").toString());
997 const QString modelDescription(json.value(prefix % u
"description").toString());
998 const QString modelName(json.value(prefix % u
"name").toString());
999 const QString modelMode(json.value(prefix % u
"mode").toString());
1000 const QString parts(json.value(prefix % u
"parts").toString());
1003 const QJsonValue cgjv = json.value(prefix % u
"cgft");
1005 (cgjv.isNull() || cgjv.isUndefined()) ? CLength::null() :
CLength(cgjv.toDouble(), CLengthUnit::ft());
1022 static const QString prefixAircraftIcao(
"ac_");
1023 static const QString prefixLivery(
"liv_");
1024 static const QString prefixDistributor(
"dist_");
1025 const QString idDistributor = json.value(prefixDistributor % u
"id").toString();
1026 const int idAircraftIcao = json.value(prefixAircraftIcao % u
"id").toInt(-1);
1027 const int idLivery = json.value(prefixLivery % u
"id").toInt(-1);
1030 CAircraftIcaoCode aircraftIcao(CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1031 CLivery livery(CLivery::fromDatabaseJson(json, prefixLivery));
1038 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1044 const QString &prefix)
1046 static const QString prefixAircraftIcao(
"ac_");
1047 static const QString prefixLivery(
"liv_");
1048 static const QString prefixDistributor(
"dist_");
1049 const QString idDistributor = json.value(prefixDistributor % u
"id").toString();
1050 const int idAircraftIcao = json.value(prefixAircraftIcao % u
"id").toInt(-1);
1051 const int idLivery = json.value(prefixLivery % u
"id").toInt(-1);
1053 const bool cachedAircraftIcao = (idAircraftIcao >= 0) && aircraftIcaos.contains(idAircraftIcao);
1054 const bool cachedLivery = (idLivery >= 0) && liveries.contains(idLivery);
1055 const bool cachedDistributor = !idDistributor.isEmpty() && distributors.contains(idDistributor);
1058 aircraftIcaos[idAircraftIcao] :
1059 CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1061 CLivery livery(cachedLivery ? liveries[idLivery] : CLivery::fromDatabaseJson(json, prefixLivery));
1063 CDistributor distributor(cachedDistributor ? distributors[idDistributor] :
1071 if (!cachedAircraftIcao)
1074 if (catId >= 0 && categories.contains(catId)) { aircraftIcao.
setCategory(categories[catId]); }
1080 aircraftIcaos[aircraftIcao.
getDbKey()] = aircraftIcao;
1083 if (!cachedDistributor && distributor.
isLoadedFromDb()) { distributors[distributor.
getDbKey()] = distributor; }
1086 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1091 static const QString ag(
"swift auto generated");
1097 if (p.isEmpty()) {
return QString(); }
1098 QString pc =
removeChars(p.toUpper(), [](QChar c) { return !supportedParts().contains(c); });
1099 std::sort(pc.begin(), pc.end());
1105 static const QString p(
"EFGLS");
static Qt::CaseSensitivity osFileNameCaseSensitivity()
Case sensitivity for current OS.
static QString appendFilePaths(const QString &path1, const QString &path2)
Append file paths.
static QString fixWindowsUncPath(const QString &filePath)
UNC file paths on Qt start with "/", but UNC file paths only work when they start with "//".
static QString normalizeFilePathToQtStandard(const QString &filePath)
Normalize file path to Qt standard, e.g by turning \ to /.
Value object for icons. An icon is stored in the global icon repository and identified by its index....
static const CIcon & iconByIndex(CIcons::IconIndex index)
Icon for given index.
static const QString & validation()
Validation.
A sequence of log categories.
Memoizer for Ts. Other types are passed through.
decltype(auto) maybeMemoize(const T &member)
If T is in Ts, return the index of member in the memo table. Otherwise, return member.
Unmemoizer for Ts. Other types are passed through.
auto maybeUnmemoize(T &member) const
If T is in Ts, return proxy that will assign to member through the value at the given index in the fl...
Derived & validationError(const char16_t(&format)[N])
Set the severity to error, providing a format string, and adding the validation category.
Derived & validationWarning(const char16_t(&format)[N])
Set the severity to warning, providing a format string, and adding the validation category.
Derived & validationInfo(const char16_t(&format)[N])
Set the severity to info, providing a format string, and adding the validation category.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
size_type size() const
Returns number of elements in the sequence.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
constexpr static auto SeverityError
Status severities.
constexpr static auto SeverityInfo
Status severities.
constexpr static auto SeverityWarning
Status severities.
Status messages, e.g. from Core -> GUI.
void removeSeverity(CStatusMessage::StatusSeverity severity)
Remove given severity.
Mix of the most commonly used mixin classes.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled.
int comparePropertyByIndex(CPropertyIndexRef index, const IOrderable &compareValue) const
Compare for index.
void setOrder(int order)
Set order.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int getOrder() const
Order.
void updateMissingParts(const ITimestampBased &other)
Update missing parts.
QString getFormattedUtcTimestampYmdhms() const
As yyyy MM dd HH mm ss.
void setUtcTimestamp(const QDateTime ×tamp)
Set timestamp.
Value object for ICAO classification.
bool hasDesignator() const
Aircraft designator?
bool hasCategory() const
Has category?
bool hasKnownDesignator() const
Has designator and designator is not "ZZZZ".
bool isVtol() const
Is VTOL aircraft (helicopter, tilt wing)
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
QString getDesignatorDbKey() const
Designator and DB key.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftIcaoCode &compareValue) const
Compare for index.
bool isMilitary() const
Military?
void updateMissingParts(const CAircraftIcaoCode &otherIcaoCode)
Update missing parts.
CStatusMessageList validate() const
Validate data.
int calculateScore(const CAircraftIcaoCode &otherCode, CStatusMessageList *log=nullptr) const
Considers rank, manufacturer and family 0..100.
void setDesignator(const QString &icaoDesignator)
Set ICAO designator, e.g. "B737".
const CAircraftCategory & getCategory() const
Get category.
void setCategory(const CAircraftCategory &category)
Set category.
Value object for ICAO classification.
Value object encapsulating information of a callsign.
int comparePropertyByIndex(CPropertyIndexRef index, const CCallsign &compareValue) const
Compare for index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isEmpty() const
Is empty?
void setTypeHint(TypeHint hint)
Type hint.
Value object encapsulating information about an airpot.
bool isMilitary() const
Military livery.
bool setAirlineIcaoCode(const CAirlineIcaoCode &airlineIcao)
Airline ICAO code.
CStatusMessageList validate() const
Validate data.
const CAirlineIcaoCode & getAirlineIcaoCode() const
Corresponding airline, if any.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString getCombinedCodePlusInfoAndId() const
Combined code, info, plus id.
bool hasValidAirlineDesignator() const
Airline available?
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isColorLivery() const
Color livery?
int comparePropertyByIndex(CPropertyIndexRef index, const CLivery &compareValue) const
Compare for index.
int calculateScore(const CLivery &otherLivery, bool preferColorLiveries=false, CStatusMessageList *log=nullptr) const
Score by comparison to another livery 0..100.
void updateMissingParts(const CLivery &otherLivery)
Update missing parts.
int getDbKey() const
Get DB key.
QJsonValue getDbKeyAsJsonValue() const
Key as JSON value, or null.
QString getDbKeyAsString() const
DB key as string.
bool isLoadedFromDb() const
Loaded from DB.
ColumnIndex
Property index.
void setDbKey(int key)
Set the DB key.
bool isDbEqual(const IDatastoreObjectWithIntegerKey &other) const
Same DB key and hence equal.
QString getDbKeyAsStringInParentheses(const QString &prefix={}) const
Db key in parentheses, e.g. "(3)".
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
bool hasValidDbKey() const
Has valid DB key.
bool isLoadedFromDb() const
Loaded from DB.
bool hasValidDbKey() const
Has valid DB key.
bool isDbEqual(const IDatastoreObjectWithStringKey &other) const
Same DB key and hence equal.
const QString & getDbKey() const
Get DB key.
void setDbKey(const QString &key)
Set the DB key.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
Physical unit length (length)
bool isNull() const
Is quantity null?
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const PQ &pq) const
Compare for index.
double value(MU unit) const
Value in given unit.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
Aircraft model (used by another pilot, my models on disk)
void setFileTimestamp(const QDateTime ×tampUtc)
Set file timestamp.
QString getAllModelStringsAndAliases() const
Get model string and aliases.
QString getSwiftLiveryString(bool aircraftIcao=true, bool livery=true, bool model=true) const
swift livery string (to be sent via network)
const aviation::CCallsign & getCallsign() const
Corresponding callsign if applicable.
void convertFromMemoizedJson(const QJsonObject &json, const MemoHelper::CUnmemoizer &)
From JSON with memoized members (used by CAircraftModelList)
bool hasValidFileTimestamp() const
Valid file timestamp?
void setName(const QString &name)
Name.
bool setDistributorOrder(int order)
Set the distributor order.
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
Matches model string?
bool hasValidSimulator() const
Valid simulator.
ModelMode getModelMode() const
Model mode.
bool hasValidAircraftAndAirlineDesignator() const
Valid airline and aircraft designator?
const aviation::CAirlineIcaoCode & getAirlineIcaoCode() const
Airline ICAO code.
void updateByExistingDirectories(const CAircraftModel &otherModel)
Update the directories from other model.
bool hasKnownAircraftDesignator() const
Has known aircraft designator?
bool hasCategory() const
Assigned a category?
bool hasAirlineDesignator() const
Airline designator?
static CAircraftModel fromDatabaseJsonCaching(const QJsonObject &json, aviation::AircraftIcaoIdMap &aircraftIcaos, const aviation::AircraftCategoryIdMap &categories, aviation::LiveryIdMap &liveries, DistributorIdMap &distributors, const QString &prefix=QString("mod_"))
From swift DB JSON, caching during this process (faster)
bool hasExistingCorrespondingFile() const
Does the corresponding file exist?
bool hasManuallySetString() const
Model string which was manually set.
static const QString & supportedParts()
Supported parts.
const QString & getSupportedParts() const
Supported parts.
bool hasModelStringAlias() const
Non empty model string alias?
static DBTripleIds parseNetworkLiveryString(const QString &liveryString)
Split swift network string.
static const QString & liveryStringPrefix()
Livery string prefix.
void setModelStringAlias(const QString &alias)
Model string alias.
QString convertToQString(bool i18n=false) const
Cast as QString.
const aviation::CLivery & getLivery() const
Get livery.
QString getMembersDbStatus() const
Info, which members (Livery, Aircraft ICAO, ...) are already based on DB data.
bool isInPath(const QString &path, Qt::CaseSensitivity cs) const
Is the file in the give path.
QString getFileDirectoryPath() const
Directory path if any.
ModelMode
Mode, decides if a model is supposed to be used in the model set for model matching or not....
int calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries, CStatusMessageList *log=nullptr) const
Calculate score.
void setModelString(const QString &modelString)
Model string.
void setModelModeAsString(const QString &mode)
Set model mode as string.
QDir getFileDirectory() const
Directory.
void setFileDetailsAndTimestamp(const QFileInfo &fileInfo)
Set file timestamp, timestamp and file name.
bool hasAircraftAndAirlineDesignator() const
Designators.
void updateLocalFileNames(const CAircraftModel &model)
Update file names from local model.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
CSimulatorInfo getSimulator() const
Simulator info.
QString getAllModelStringsAliasesAndDbKey() const
Get model string and aliases.
void normalizeFileNameForDb()
File path for DB (absolute paths make no sense in DB)
@ TypeModelMatchingDefaultModel
a default model assigned by model matching
@ TypeTerrainProbe
peudo aircraft used for terrain probing (FSX)
@ TypeManuallySet
manually set, e.g.
@ TypeFSInnData
model based on FSD ICAO data
@ TypeQueriedFromNetwork
model was queried by network protocol (ICAO data)
@ TypeOwnSimulatorModel
represents own simulator model (AI model, model on disk)
@ TypeDatabaseEntry
used along with mapping definition
@ TypeReverseLookup
reverse lookup model
@ TypeModelMatching
model is result of model matching
const QString & getModelString() const
Model key, either queried or loaded from simulator model.
static const QString & modelTypeToString(ModelType type)
Model type.
void setCallsign(const aviation::CCallsign &callsign)
Corresponding callsign if applicable.
bool isEqualForPublishing(const CAircraftModel &dbModel, CStatusMessageList *details=nullptr) const
Considered equal for publishing, compares if livery etc. are the same DB values.
bool canInitializeFromFsd() const
Can be initialized from FSD.
void setFileName(const QString &fileName)
File name.
bool isVtol() const
VTOL aircraft?
bool hasDistributor() const
Distributor, but not necessarily loaded from DB.
static QString cleanUpPartsString(const QString &p)
Clean up parts string.
bool hasFileName() const
File name?
CStatusMessageList verifyModelData() const
Verify the model data.
QString getFormattedFileTimestampYmdhms() const
File timestamp.
bool isCivilian() const
Civilian model?
void setSupportedParts(const QString &supportedParts)
Supported parts.
bool adjustLocalFileNames(const QString &newModelDir, const QString &stripModelDirIndicator={})
Adjust file names to a new directory.
static ModelMode modelModeFromString(const QString &mode)
Model mode.
const physical_quantities::CLength & getCG() const
Get center of gravity.
bool matchesDbDistributor(const CDistributor &distributor) const
By distributor.
const QString & getName() const
Name.
const QString & getModelModeAsString() const
Model mode as string.
CAircraftModel()
Default constructor.
bool hasAircraftDesignator() const
Has aircraft designator?
const QString & getDescription() const
Descriptive text.
QJsonObject toDatabaseJson() const
To database JSON.
void setDescription(const QString &description)
Descriptive text.
void setSimulator(const CSimulatorInfo &simulator)
Set simulator info.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool matchesModelStringOrAlias(const QString &modelString, Qt::CaseSensitivity sensitivity) const
Matches model string or alias?
const CIcon & getModelModeAsIcon() const
Model mode as string.
void setCG(const physical_quantities::CLength &cg)
Get center of gravity.
CStatusMessageList validate(bool withNestedObjects) const
Validate.
bool matchesMode(simulation::CAircraftModel::ModelModeFilter mode) const
Matches given mode?
const CDistributor & getDistributor() const
Get distributor.
const aviation::CAircraftIcaoCode & getAircraftIcaoCode() const
Aircraft ICAO code.
static const QString & modelModeToString(ModelMode mode)
Model mode.
bool matchesFileName(const QString &fileName) const
Matching file name?
ModelType getModelType() const
Model type.
bool hasQueriedModelString() const
Queried model string?
static CAircraftModel fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString("mod_"))
From swift DB JSON.
bool hasDbDistributor() const
Distributor loaded from DB.
QString getModelStringAndDbKey() const
Model string and DB key (if available)
bool matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const
Matches given simulator?
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftModel &compareValue) const
Compare for index.
const QString & getModelTypeAsString() const
Model type.
const QString & getModelStringAlias() const
Model key, either queried or loaded from simulator model.
void setAircraftIcaoDesignator(const QString &designator)
Set aircraft ICAO code designator.
bool matchesAnyDbDistributor(const CDistributorList &distributors) const
By distributor.
QDateTime getFileTimestamp() const
Get timestamp.
QString asHtmlSummary(const QString &separator="<br>") const
As a brief HTML summary (e.g. used in tooltips)
void setModelMode(ModelMode mode)
Set model mode.
bool hasDescription(bool ignoreAutoGenerated=false) const
Description.
bool hasAnyModelString() const
Any model string or alias?
bool isMilitary() const
Military model?
QJsonObject toMemoizedJson(MemoHelper::CMemoizer &) const
To JSON with memoized members (used by CAircraftModelList)
static bool isSwiftLiveryString(const QString &liveryString)
swift livery string
bool hasModelString() const
Non empty model string?
void setLivery(const aviation::CLivery &livery)
Livery.
void setDistributor(const CDistributor &distributor)
Set distributor.
void setAircraftIcaoCodes(const aviation::CAircraftIcaoCode &aircraftIcaoCode, const aviation::CAirlineIcaoCode &airlineIcaoCode)
Set ICAO codes.
bool setAircraftIcaoCode(const aviation::CAircraftIcaoCode &aircraftIcaoCode)
Set aircraft ICAO code.
QString toDatabaseJsonString(QJsonDocument::JsonFormat format=QJsonDocument::Compact) const
To database JSON.
static const QString & autoGenerated()
Hint, that model was automatically generated (e.g. by auto stashing)
@ IndexAllModelStrings
indluding aliases
const QString & getFileName() const
File name (corresponding data for simulator, only available if representing simulator model.
void updateMissingParts(const CAircraftModel &otherModel, bool dbModelPriority=true)
Update missing parts from another model.
bool matchesSimulator(const CSimulatorInfo &simulator) const
Matches given simulator?
Value object encapsulating information of software distributor.
int comparePropertyByIndex(CPropertyIndexRef index, const CDistributor &compareValue) const
Compare for index.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
const QString & getDescription() const
Get description.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void updateMissingParts(const CDistributor &otherDistributor)
Update missing parts.
static CDistributor fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Object from JSON.
swift::misc::CStatusMessageList validate() const
Validate data.
Value object encapsulating a list of distributors.
CDistributor findByKeyOrAlias(const QString &keyOrAlias) const
Find by id or alias.
bool matchesAnyKeyOrAlias(const QString &keyOrAlias) const
At least is matching key or alias.
Simple hardcoded info about the corresponding simulator.
int comparePropertyByIndex(CPropertyIndexRef index, const CSimulatorInfo &compareValue) const
Cast as QString.
bool isMSFS2024() const
MSFS2024?
Simulator getSimulator() const
Simulator.
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix)
From database JSON.
bool isAnySimulator() const
Any simulator?
bool isXPlane() const
XPlane.
SWIFT_MISC_EXPORT QString inApostrophes(const QString &in, bool ignoreEmpty=false)
Return string in apostrophes.
QString removeChars(const QString &s, F predicate)
Return a string with characters removed that match the given predicate.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
Simple literal type containing a single QLatin1String.
int livery
livery id, by that I have airline id
int aircraft
aircraft ICAO id
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.