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());
135 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
138 auto &&maybeMemo = helper.
maybeMemoize(member.in(*
this));
147 introspect<CAircraftModel>().forEachMember([&,
this](
auto member) {
158 return QStringLiteral(
159 "Model: %1 changed: %2%3Simulator: %4 Mode: %5 Distributor: %6%7Aircraft ICAO: %8%9Livery: %10")
212 m_callsign = callsign;
230 return m_modelString % u
", " % m_modelStringAlias;
245 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
247 return IDatastoreObjectWithIntegerKey::propertyByIndex(index);
254 case IndexModelString:
return QVariant(m_modelString);
255 case IndexModelStringAlias:
return QVariant(m_modelStringAlias);
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);
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:
320 else if (variant.
canConvert<qint64>()) { m_fileTimestamp = variant.
value<qint64>(); }
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);
354 case IndexModelStringAlias:
359 case IndexHasQueriedModelString:
361 case IndexAircraftIcaoCode:
364 case IndexDistributor:
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;
559 static const QString p(
"swift_");
571 if (!aircraftIcao && !livery && !model) {
return QString(); }
594 for (
int c = 0; c < ls.
length(); c++)
596 const QChar m = ls[c];
597 if ((m ==
'm' || m ==
'a' || m ==
'l') && (c + 1) < ls.
length())
599 const int cs = c + 1;
601 while (cc < ls.
length() && ls[cc].isDigit()) { cc++; }
605 const int id = idString.
toInt();
608 if (m ==
'm') { ids.
model = id; }
609 else if (m ==
'a') { ids.
aircraft = id; }
610 else if (m ==
'l') { ids.
livery = id; }
631 if (m_fileTimestamp < 0 || otherModel.m_fileTimestamp > m_fileTimestamp)
643 if (m_modelType == TypeUnknown) { m_modelType = otherModel.
getModelType(); }
644 if (m_modelMode == Undefined) { m_modelType = otherModel.
getModelType(); }
678 if (m_description.
isEmpty()) {
return false; }
679 if (!ignoreAutoGenerated) {
return true; }
687 return (this->
isLoadedFromDb() ? QStringLiteral(
"M") : QStringLiteral(
"m")) %
691 QStringLiteral(
"C-") :
694 QStringLiteral(
"a")));
723 if (stripModelDirIndicator.
isEmpty())
728 else { i = m_fileName.
lastIndexOf(stripModelDirIndicator); }
729 if (i < 0) {
return false; }
738 if (!fi.
exists()) {
return false; }
771 return stringCompare(modelString, m_modelString, sensitivity);
777 return stringCompare(modelString, m_modelStringAlias, sensitivity);
785 CCallsign::addLogDetailsToList(
787 QStringLiteral(
"ICAO score: %1 | livery score: %2").arg(icaoScore).arg(liveryScore));
788 return qRound(0.5 * (icaoScore + liveryScore));
807 if (withNestedObjects)
823 u
"Model '%1' same %2 '%3'");
829 u
"Model '%1' changed %2 '%3'->'%4'");
840 if (details) { details->
push_back(msgNoDbModel); }
845 bool changed =
false;
849 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"livery"),
851 this->getLivery().getCombinedCodePlusInfoAndId()));
859 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"aircraft ICAO"),
861 this->getAircraftIcaoCode().getDesignatorDbKey()));
868 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"distributor"),
870 this->getDistributor().getDescription()));
877 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"simulator"),
879 this->getSimulator().toQString()));
887 this->getDescription()));
895 equalMessage(equal, *
this, QStringLiteral(
"name"), dbModel.
getName(), this->getName()));
903 this->getModelModeAsString()));
911 this->getCG().toQString(
true)));
918 validationMsgs.
push_back(equalMessage(equal, *
this, QStringLiteral(
"Supported parts"),
924 if (changed && details)
930 if (details) { details->
push_back(validationMsgs); }
936 static const QString queried(
"queried");
937 static const QString matching(
"matching");
938 static const QString db(
"database");
939 static const QString def(
"map.default");
940 static const QString ownSim(
"own simulator");
941 static const QString set(
"manually set");
942 static const QString fsinn(
"FSInn");
943 static const QString probe(
"probe");
944 static const QString reverse(
"reverse lookup");
945 static const QString unknown(
"unknown");
959 default:
return unknown;
966 if (n.
count(
'/') < 2) {
return n; }
980 static const QString i(
"Include");
981 static const QString e(
"Exclude");
985 case Include:
return i;
986 case Exclude:
return e;
987 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"wrong mode");
1023 static const QString prefixAircraftIcao(
"ac_");
1024 static const QString prefixLivery(
"liv_");
1025 static const QString prefixDistributor(
"dist_");
1027 const int idAircraftIcao = json.
value(prefixAircraftIcao % u
"id").
toInt(-1);
1028 const int idLivery = json.
value(prefixLivery % u
"id").
toInt(-1);
1031 CAircraftIcaoCode aircraftIcao(CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1032 CLivery livery(CLivery::fromDatabaseJson(json, prefixLivery));
1039 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1047 static const QString prefixAircraftIcao(
"ac_");
1048 static const QString prefixLivery(
"liv_");
1049 static const QString prefixDistributor(
"dist_");
1051 const int idAircraftIcao = json.
value(prefixAircraftIcao % u
"id").
toInt(-1);
1052 const int idLivery = json.
value(prefixLivery % u
"id").
toInt(-1);
1054 const bool cachedAircraftIcao = (idAircraftIcao >= 0) && aircraftIcaos.
contains(idAircraftIcao);
1055 const bool cachedLivery = (idLivery >= 0) && liveries.
contains(idLivery);
1056 const bool cachedDistributor = !idDistributor.
isEmpty() && distributors.
contains(idDistributor);
1059 aircraftIcaos[idAircraftIcao] :
1060 CAircraftIcaoCode::fromDatabaseJson(json, prefixAircraftIcao));
1062 CLivery livery(cachedLivery ? liveries[idLivery] : CLivery::fromDatabaseJson(json, prefixLivery));
1064 CDistributor distributor(cachedDistributor ? distributors[idDistributor] :
1072 if (!cachedAircraftIcao)
1075 if (catId >= 0 && categories.
contains(catId)) { aircraftIcao.
setCategory(categories[catId]); }
1081 aircraftIcaos[aircraftIcao.
getDbKey()] = aircraftIcao;
1084 if (!cachedDistributor && distributor.
isLoadedFromDb()) { distributors[distributor.
getDbKey()] = distributor; }
1087 return CAircraftModel::fromDatabaseJsonBaseImpl(json, prefix, aircraftIcao, livery, distributor);
1092 static const QString ag(
"swift auto generated");
1106 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.
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.