6#include <QRegularExpression>
7#include <QStringBuilder>
19using namespace swift::misc::db;
23namespace swift::misc::aviation
27 : m_name(name), m_description(description), m_path(path), m_assignable(assignable)
70 if (level.
size() != 3)
74 return m_l1 == level[0] && m_l2 == level[1] && m_l3 == level[2];
83 return category.m_l1 == m_l1 && category.m_l2 == m_l2 && category.m_l3 == m_l3;
89 if (m_l1 > 0) l << m_l1;
90 if (m_l2 > 0) l << m_l2;
91 if (m_l3 > 0) l << m_l3;
103 if (m_l3 == 0 && m_l2 > 0 && m_l1 > 0)
116 return QStringLiteral(
"%1.%2.%3").
arg(m_l1).
arg(m_l2).
arg(m_l3);
148 if (l2 > 0 && l2 != m_l2)
152 if (l3 > 0 && l3 != m_l3)
165 const int l1 = level.
first();
166 const int l2 = level.
size() > 1 ? level.
at(1) : 0;
167 const int l3 = level.
size() > 2 ? level.
at(2) : 0;
234 case IndexLevelStringAndName:
235 case IndexLevelStringAndPath:
239 Q_ASSERT_X(
false, Q_FUNC_INFO,
"No comparison");
245 const QString name(json.value(prefix % u
"name").toString());
246 const QString description(json.value(prefix % u
"description").toString());
247 const QString path(json.value(prefix % u
"path").toString());
249 const int l1 = json.value(prefix % u
"l1").toInt();
250 const int l2 = json.value(prefix % u
"l2").toInt();
251 const int l3 = json.value(prefix % u
"l3").toInt();
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
bool isEmpty() const
Synonym for empty.
Status messages, e.g. from Core -> GUI.
bool isFirstLevel() const
First level.
int getDepth() const
Depth 1, 2, 3.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setAssignable(bool assignable)
Mark/set assignable.
bool isHigherLevel(const CAircraftCategory &other) const
Higher level?
int comparePropertyByIndex(CPropertyIndexRef index, const CAircraftCategory &compareValue) const
Compare for index.
void setDescription(const QString &description)
Set description.
const QString & getName() const
Get name.
bool isAssignable() const
Assignable?
ColumnIndex
Properties by index.
const QString & getPath() const
Path.
bool isNull() const
Null category?
int compareByLevel(const CAircraftCategory &other) const
Level compare.
QString getLevelAndName() const
Level and name.
CAircraftCategory()=default
Default constructor.
swift::misc::CStatusMessageList validate() const
Validate data.
bool isLevel(int l1, int l2, int l3) const
Is that given level?
const QString & getDescription() const
Description.
QString getLevelString() const
Level string.
bool matchesName(const QString &name, Qt::CaseSensitivity cs) const
Matching name?
QString getNameDbKey() const
Designator and DB key.
QList< int > getLevel() const
Levels depending on depth, 3.2 -> 3,2 / 1.0 -> 1 / 4.3.1 -> 4,3,1.
QString convertToQString(bool i18n=false) const
Cast as QString.
static CAircraftCategory fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
From our database JSON format.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString getLevelAndPath() const
Level and path.
bool matchesPath(const QString &path, Qt::CaseSensitivity cs)
Matching path?
void setLevel(int l1, int l2, int l3)
Level.
static const CAircraftCategory & null()
NULL object.
bool hasName() const
Aircraft designator?
bool matchesLevel(int l1, int l2=0, int l3=0) const
Is matching the level, 0 ignored.
void setName(const QString &name)
Set name.
static bool dbBoolStringToBool(const QString &dbBool)
DB Bool value to bool.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
bool isLoadedFromDb() const
Loaded from DB.
static bool canHandleIndex(swift::misc::CPropertyIndexRef index)
Can given index be handled?
QString getDbKeyAsStringInParentheses(const QString &prefix={}) const
Db key in parentheses, e.g. "(3)".
int comparePropertyByIndex(CPropertyIndexRef index, const IDatastoreObjectWithIntegerKey &compareValue) const
Compare for index.
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
int compare(T a, T b)
Compare arithmetic values.
Free functions in swift::misc.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
QList< T >::const_reference at(qsizetype i) const const
bool isEmpty() const const
qsizetype size() const const
QString arg(Args &&... args) const const
QVariant fromValue(T &&value)
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.