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)
58 : m_simulator(simulator), m_modelString(model.trimmed().toUpper()), m_name(name.trimmed()),
59 m_description(description.trimmed()), m_modelType(type)
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
'\'';
91 obj.
insert(
"version", CBuildConfig::getVersionString());
101 QString flag = CDatastoreUtility::boolToDbYN(sim.
isFSX());
103 flag = CDatastoreUtility::boolToDbYN(sim.
isP3D());
105 flag = CDatastoreUtility::boolToDbYN(sim.
isFS9());
107 flag = CDatastoreUtility::boolToDbYN(sim.
isMSFS());
109 flag = CDatastoreUtility::boolToDbYN(sim.
isMSFS2024());
111 flag = CDatastoreUtility::boolToDbYN(sim.
isXPlane());
113 flag = CDatastoreUtility::boolToDbYN(sim.
isFG());
136 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
139 auto &&maybeMemo = helper.
maybeMemoize(member.in(*
this));
150 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
162 return QStringLiteral(
163 "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10")
216 m_callsign = callsign;
234 return m_modelString % u
", " % m_modelStringAlias;
249 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
251 return IDatastoreObjectWithIntegerKey::propertyByIndex(index);
258 case IndexModelString:
return { m_modelString };
259 case IndexModelStringAlias:
return { m_modelStringAlias };
269 case IndexSimulatorInfoAsString:
return { m_simulator.
toQString() };
270 case IndexDescription:
return { m_description };
271 case IndexName:
return { m_name };
272 case IndexFileName:
return { m_fileName };
274 case IndexSupportedParts:
return { m_supportedParts };
297 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
299 IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant);
306 case IndexModelString: m_modelString = variant.
toString();
break;
307 case IndexModelStringAlias: m_modelStringAlias = variant.
toString();
break;
311 case IndexDescription: m_description = variant.
toString();
break;
313 case IndexName: m_name = variant.
toString();
break;
316 case IndexModelType: m_modelType = variant.
value<
ModelType>();
break;
317 case IndexFileName: m_fileName = variant.
toString();
break;
322 case IndexFileTimestamp:
324 else if (variant.
canConvert<qint64>()) { m_fileTimestamp = variant.
value<qint64>(); }
334 case IndexHasQueriedModelString:
break;
335 case IndexModelTypeAsString:
break;
336 case IndexModelModeAsString:
break;
337 case IndexModelModeAsIcon:
break;
338 case IndexFileTimestampFormattedYmdhms:
break;
339 case IndexSimulatorInfoAsString:
break;
340 case IndexMembersDbStatus:
break;
348 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
350 return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);
358 case IndexModelStringAlias:
363 case IndexHasQueriedModelString:
365 case IndexAircraftIcaoCode:
368 case IndexDistributor:
377 case IndexModelTypeAsString:
378 case IndexModelType:
return Compare::compare(m_modelType, compareValue.
getModelType());
379 case IndexSimulatorInfoAsString:
380 case IndexSimulatorInfo:
382 case IndexFileTimestamp:
383 case IndexFileTimestampFormattedYmdhms:
return Compare::compare(m_fileTimestamp, compareValue.m_fileTimestamp);
385 case IndexModelModeAsString:
386 case IndexModelModeAsIcon:
return Compare::compare(m_modelMode, compareValue.
getModelMode());
390 Q_ASSERT_X(
false, Q_FUNC_INFO,
"No comparison");
396 if (m_aircraftIcao == aircraftIcaoCode) {
return false; }
397 m_aircraftIcao = aircraftIcaoCode;
409 m_aircraftIcao = aircraftIcaoCode;
440 if (order < 0) {
return false; }
448 if (distributors.
isEmpty()) {
return false; }
450 const int noDistributorOrder = distributors.
size();
459 else { m_distributor.
setOrder(noDistributorOrder); }
461 else { m_distributor.
setOrder(noDistributorOrder); }
481 if (distributors.
isEmpty()) {
return false; }
493 if (mode == All) {
return true; }
494 return (mode & m_modelMode) > 0;
504 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"wrong mode");
break;
516 return (
static_cast<int>(simulator.
getSimulator()) &
static_cast<int>(this->getSimulator().getSimulator())) > 0;
563 static const QString p(
"swift_");
575 if (!aircraftIcao && !livery && !model) {
return {}; }
598 for (
int c = 0; c < ls.
length(); c++)
600 const QChar m = ls[c];
601 if ((m ==
'm' || m ==
'a' || m ==
'l') && (c + 1) < ls.
length())
603 const int cs = c + 1;
605 while (cc < ls.
length() && ls[cc].isDigit()) { cc++; }
609 const int id = idString.
toInt();
612 if (m ==
'm') { ids.
model = id; }
613 else if (m ==
'a') { ids.
aircraft = id; }
614 else if (m ==
'l') { ids.
livery = id; }
635 if (m_fileTimestamp < 0 || otherModel.m_fileTimestamp > m_fileTimestamp)
647 if (m_modelType == TypeUnknown) { m_modelType = otherModel.
getModelType(); }
648 if (m_modelMode == Undefined) { m_modelType = otherModel.
getModelType(); }
682 if (m_description.
isEmpty()) {
return false; }
683 if (!ignoreAutoGenerated) {
return true; }
691 return (this->
isLoadedFromDb() ? QStringLiteral(
"M") : QStringLiteral(
"m")) %
695 QStringLiteral(
"C-") :
698 QStringLiteral(
"a")));
727 if (stripModelDirIndicator.
isEmpty())
732 else { i = m_fileName.
lastIndexOf(stripModelDirIndicator); }
733 if (i < 0) {
return false; }
742 if (!fi.
exists()) {
return false; }
775 return stringCompare(modelString, m_modelString, sensitivity);
781 return stringCompare(modelString, m_modelStringAlias, sensitivity);
789 CCallsign::addLogDetailsToList(
791 QStringLiteral(
"ICAO score: %1 | livery score: %2").arg(icaoScore).arg(liveryScore));
792 return qRound(0.5 * (icaoScore + liveryScore));
811 if (withNestedObjects)
827 u
"Model '%1' same %2 '%3'");
833 u
"Model '%1' changed %2 '%3'->'%4'");
844 if (details) { details->
push_back(msgNoDbModel); }
849 bool changed =
false;
853 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"livery"),
855 this->getLivery().getCombinedCodePlusInfoAndId()));
863 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"aircraft ICAO"),
865 this->getAircraftIcaoCode().getDesignatorDbKey()));
872 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"distributor"),
874 this->getDistributor().getDescription()));
881 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"simulator"),
883 this->getSimulator().toQString()));
891 this->getDescription()));
899 equalMessage(equal, *
this, QStringLiteral(
"name"), dbModel.
getName(), this->getName()));
907 this->getModelModeAsString()));
915 this->getCG().toQString(
true)));
922 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"Supported parts"),
928 if (changed && details)
934 if (details) { details->
push_back(validationMsgs); }
940 static const QString queried(
"queried");
941 static const QString matching(
"matching");
942 static const QString db(
"database");
943 static const QString def(
"map.default");
944 static const QString ownSim(
"own simulator");
945 static const QString set(
"manually set");
946 static const QString fsinn(
"FSInn");
947 static const QString probe(
"probe");
948 static const QString reverse(
"reverse lookup");
949 static const QString unknown(
"unknown");
963 default:
return unknown;
970 if (n.
count(
'/') < 2) {
return n; }
984 static const QString i(
"Include");
985 static const QString e(
"Exclude");
989 case Include:
return i;
990 case Exclude:
return e;
991 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"wrong mode");
1027 static const QString prefixAircraftIcao(
"ac_");
1028 static const QString prefixLivery(
"liv_");
1029 static const QString prefixDistributor(
"dist_");
1031 const int idAircraftIcao = json.
value(prefixAircraftIcao % u
"id").
toInt(-1);
1032 const int idLivery = json.
value(prefixLivery % u
"id").
toInt(-1);
1035 CAircraftIcaoCode aircraftIcao(CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1036 CLivery livery(CLivery::fromDatabaseJson(json, prefixLivery));
1043 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1051 static const QString prefixAircraftIcao(
"ac_");
1052 static const QString prefixLivery(
"liv_");
1053 static const QString prefixDistributor(
"dist_");
1055 const int idAircraftIcao = json.
value(prefixAircraftIcao % u
"id").
toInt(-1);
1056 const int idLivery = json.
value(prefixLivery % u
"id").
toInt(-1);
1058 const bool cachedAircraftIcao = (idAircraftIcao >= 0) && aircraftIcaos.
contains(idAircraftIcao);
1059 const bool cachedLivery = (idLivery >= 0) && liveries.
contains(idLivery);
1060 const bool cachedDistributor = !idDistributor.
isEmpty() && distributors.
contains(idDistributor);
1063 aircraftIcaos[idAircraftIcao] :
1064 CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1066 CLivery livery(cachedLivery ? liveries[idLivery] : CLivery::fromDatabaseJson(json, prefixLivery));
1068 CDistributor distributor(cachedDistributor ? distributors[idDistributor] :
1076 if (!cachedAircraftIcao)
1079 if (catId >= 0 && categories.
contains(catId)) { aircraftIcao.
setCategory(categories[catId]); }
1085 aircraftIcaos[aircraftIcao.
getDbKey()] = aircraftIcao;
1088 if (!cachedDistributor && distributor.
isLoadedFromDb()) { distributors[distributor.
getDbKey()] = distributor; }
1091 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1096 static const QString ag(
"swift auto generated");
1102 if (p.
isEmpty()) {
return {}; }
1110 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.
CAircraftModel()=default
Default constructor.
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.
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.
QDateTime fromMSecsSinceEpoch(qint64 msecs)
bool isValid() const const
qint64 toMSecsSinceEpoch() const const
QString toString(QStringView format) const const
QString absolutePath() const const
QDir absoluteDir() const const
QString absoluteFilePath() const const
bool exists(const QString &path)
bool isReadable() const const
QDateTime lastModified() const const
QByteArray toJson(QJsonDocument::JsonFormat format) const const
QJsonValueRef value() const const
QJsonObject::iterator end()
QJsonObject::iterator find(QLatin1StringView key)
QJsonObject::iterator insert(QLatin1StringView key, const QJsonValue &value)
QJsonValue value(QLatin1StringView key) const const
bool isNull() const const
bool isUndefined() const const
double toDouble(double defaultValue) const const
int toInt(int defaultValue) const const
QString toString() const const
bool contains(const Key &key) const const
qsizetype count() const const
QString arg(Args &&... args) const const
QString::iterator begin()
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) &&
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) &&
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString section(QChar sep, qsizetype start, qsizetype end, QString::SectionFlags flags) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
int toInt(bool *ok, int base) const const
QString toLower() const const
QString toUpper() const const
bool canConvert() const const
QVariant fromValue(T &&value)
QString toString() const const
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.