14 namespace swift::misc::aviation
47 if (levels.isEmpty()) {
return {}; }
48 return levels.values().join(separator);
55 QList<int> ll = levels;
64 QList<int> ll = levels;
76 if (highestLevels.contains(fl))
78 if (highestLevels[fl].isHigherLevel(category)) { highestLevels[fl] = category; }
80 else { highestLevels[fl] = category; }
101 if (level.isEmpty()) {
return categories; }
102 const int ls = level.
size();
105 if (noRootNode && ls == category.
getDepth()) {
continue; }
113 if (level.size() != 3) {
return {}; }
116 if (category.
isLevel(level[0], level[1], level[2])) {
return category; }
128 QList<int> levels = category.
getLevel();
136 categories.
remove(category);
142 if (category.
isNull() || this->isEmpty()) {
return {}; }
144 const bool isL2 = category.
getDepth() == 2;
146 if (loopLevels.isEmpty()) {
return {}; }
148 QList<int> level = category.
getLevel();
150 for (
int l = loopLevels.front(); loopLevels.back() >= l; ++l)
152 level[isL2 ? 0 : 1] = l;
153 if (category.
isLevel(level)) {
continue; }
162 if (level.isEmpty()) {
return 0; }
163 const int c = this->
size();
165 const int delta = c - removed.
size();
166 if (delta > 0) { *
this = removed; }
172 if (level.isEmpty()) {
return *
this; }
185 for (
const QJsonValue &value : array)
size_type size() const
Returns number of elements in the sequence.
void sortBy(K1 key1, Keys... keys)
In-place sort by some particular key(s).
CSequence findBy(Predicate p) const
Return a copy containing only those elements for which a given predicate returns true.
void push_back(const T &value)
Appends an element at the end of the sequence.
int remove(const T &object)
Remove all elements equal to the given object, if it is contained.
bool isEmpty() const
Synonym for empty.
void sort(Predicate p)
In-place sort by a given comparator predicate.
Build a QSet more efficiently when calling insert() in a for loop.
void insert(const T &value)
Add an element to the set. Runs in amortized constant time.
Value object for aircraft categories.
int getSecondLevel() const
Second level.
bool isFirstLevel() const
First level.
int getDepth() const
Depth 1, 2, 3.
const QString & getPath() const
Path.
bool isNull() const
Null category?
int compareByLevel(const CAircraftCategory &other) const
Level compare.
int getFirstLevel() const
First level.
bool isLevel(int l1, int l2, int l3) const
Is that given level?
QString getLevelString() const
Level string.
bool matchesName(const QString &name, Qt::CaseSensitivity cs) const
Matching name?
QList< int > getLevel() const
Levels depending on depth, 3.2 -> 3,2 / 1.0 -> 1 / 4.3.1 -> 4,3,1.
static CAircraftCategory fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
From our database JSON format.
bool matchesLevel(int l1, int l2=0, int l3=0) const
Is matching the level, 0 ignored.
Value object encapsulating a list of ICAO codes.
CAircraftCategoryList()
Default constructor.
CAircraftCategoryList findByLevel(const QList< int > &level, bool noRootNode=false) const
Find by levels.
QList< int > getFirstLevels() const
All levels sorted.
QString getLevelsString(const QString &separator=", ") const
Get all level strings.
int removeIfLevel(const QList< int > &level)
Remove by level.
CAircraftCategoryList findInParallelBranch(const CAircraftCategory &category) const
Find siblings.
CAircraftCategoryList findByFirstLevel(int level) const
Find by first level.
CAircraftCategoryList findFirstLevels() const
Find first levels.
void sortByLevel()
Sort by level.
static CAircraftCategoryList fromDatabaseJson(const QJsonArray &array)
From our database JSON format.
void sortByPath()
Sort by path.
CAircraftCategoryList findByName(const QString &name, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
Find by name.
CAircraftCategory findByFullLevel(const QList< int > &level) const
Find by exact levels.
QList< int > getSecondLevels() const
All levels sorted.
QSet< QString > getLevelStrings() const
Get all level strings.
CAircraftCategoryList removedLevel(const QList< int > &level) const
With removed categories.
CAircraftCategoryList findHighestLevels(const CAircraftCategoryList &categories)
Find highest (top) level of categories.
CAircraftCategoryList findSiblings(const CAircraftCategory &category) const
Find siblings.
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.