7#include <QStringBuilder>
17namespace swift::misc::simulation
23 : m_description(description), m_alias1(alias1), m_alias2(alias2), m_simulator(simulator)
66 return m_simulator.matchesAny(simulator);
75 if (IDatastoreObjectWithStringKey::canHandleIndex(index))
77 return IDatastoreObjectWithStringKey::propertyByIndex(index);
90 case IndexSimulator:
return m_simulator.propertyByIndex(index.
copyFrontRemoved());
102 if (IDatastoreObjectWithStringKey::canHandleIndex(index))
104 IDatastoreObjectWithStringKey::setPropertyByIndex(index, variant);
116 case IndexAlias1: m_alias1 = variant.
value<
QString>();
break;
117 case IndexAlias2: m_alias2 = variant.
value<
QString>();
break;
118 case IndexDescription: m_description = variant.
value<
QString>();
break;
119 case IndexSimulator: m_simulator.setPropertyByIndex(index.
copyFrontRemoved(), variant);
break;
126 if (IDatastoreObjectWithStringKey::canHandleIndex(index))
128 return IDatastoreObjectWithStringKey::comparePropertyByIndex(index, compareValue);
142 return m_simulator.comparePropertyByIndex(index.
copyFrontRemoved(), compareValue.m_simulator);
145 Q_ASSERT_X(
false, Q_FUNC_INFO,
"Compare failed");
215 const QString description(json.value(prefix % u
"description").toString());
221 return distributorStub;
225 const QString alias1(json.value(prefix % u
"alias1").toString());
226 const QString alias2(json.value(prefix % u
"alias2").toString());
227 Q_ASSERT_X(!description.
isEmpty(), Q_FUNC_INFO,
"Missing description");
228 CDistributor distributor(
"", description, alias1, alias2, simulator);
272 static const QString k(
"XCSL");
278 static const QString k(
"MSFS");
284 static const QString k(
"MSFS2024");
A sequence of log categories.
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.
void push_back(const T &value)
Appends an element at the end of the sequence.
Streamable status message, e.g.
static constexpr auto SeverityError
Status severities.
Status messages, e.g. from Core -> GUI.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled.
int comparePropertyByIndex(CPropertyIndexRef index, const IOrderable &compareValue) const
Compare for index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setLoadedFromDb(bool loaded)
Mark as loaded from DB.
static bool existsKey(const QJsonObject &json, const QString &prefix=QString())
Is a key available?
bool hasValidDbKey() const
Has valid DB key.
const QString & getDbKey() const
Get DB key.
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
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.
const QString & getAlias1() const
Get alias1.
bool hasAlias1() const
Alias 1?
void setDescription(const QString &description)
Set description.
QString getIdAndDescription() const
Get id and description.
static const QSet< QString > & standardAllFsFamily()
Hardcoded keys for standard models.
static const QString & xplaneXcsl()
Hardcoded keys for standard models.
int comparePropertyByIndex(CPropertyIndexRef index, const CDistributor &compareValue) const
Compare for index.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
static const QSet< QString > & xplaneMostPopular()
Hardcoded keys for standard models.
static const QString & standardMsfs()
Hardcoded keys for standard models.
static const QString & standardXPlane()
Hardcoded keys for standard models.
bool matchesKeyOrAlias(const QString &keyOrAlias) const
Matches key or alias.
static const QString & standardFlightGear()
Hardcoded keys for standard models.
void updateMissingParts(const CDistributor &otherDistributor)
Update missing parts.
bool hasAlias2() const
Alias 2?
bool hasDescription() const
Has description.
bool hasCompleteData() const
Complete data?
QString convertToQString(bool i18n=false) const
Cast as QString.
const QString & getAlias2() const
Get alias2.
static CDistributor fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Object from JSON.
static const QString & standardP3D()
Hardcoded keys for standard models.
static const QString & standardMsfs2024()
Hardcoded keys for standard models.
swift::misc::CStatusMessageList validate() const
Validate data.
ColumnIndex
Property indexes.
void setAlias1(const QString &alias)
Set alias1.
static const QString & xplaneBlueBell()
Hardcoded keys for standard models.
const QString & getDescription() const
Get description.
CDistributor()=default
Default constructor.
bool matchesSimulator(const CSimulatorInfo &simulator) const
Matches simulator.
Simple hardcoded info about the corresponding simulator.
static CSimulatorInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix)
From database JSON.
QString removeChars(const QString &s, F predicate)
Return a string with characters removed that match the given predicate.
QString & append(QChar ch)
QString arg(Args &&... args) const const
bool isEmpty() const const
QString toUpper() const const
QString trimmed() const const
QVariant fromValue(T &&value)
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.