swift
Loading...
Searching...
No Matches
airlineicaocode.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <algorithm>
7#include <ranges>
8
9#include <QDir>
10#include <QStringBuilder>
11#include <Qt>
12#include <QtGlobal>
13
17#include "misc/icons.h"
18#include "misc/logcategories.h"
20#include "misc/setbuilder.h"
21#include "misc/statusmessage.h"
22#include "misc/stringutils.h"
24#include "misc/verify.h"
25
26using namespace swift::misc;
27using namespace swift::misc::db;
28
29SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::aviation, CAirlineIcaoCode)
30
31namespace swift::misc::aviation
32{
34 : m_designator(airlineDesignator.trimmed().toUpper())
35 {
36 if (m_designator.length() == 4)
37 {
38 this->setDesignator(m_designator);
39 }
40 }
41
42 CAirlineIcaoCode::CAirlineIcaoCode(const QString &airlineDesignator, const QString &airlineName,
43 const CCountry &country, const QString &telephony, bool virtualAirline,
44 bool operating)
45 : m_designator(airlineDesignator.trimmed().toUpper()), m_name(airlineName), m_telephonyDesignator(telephony),
46 m_country(country), m_isVa(virtualAirline), m_isOperating(operating)
47 {
48 if (m_designator.length() == 4)
49 {
50 this->setDesignator(m_designator);
51 }
52 }
53
55 {
56 if (!this->isVirtualAirline())
57 {
58 return m_designator;
59 }
60 return u'V' % m_designator;
61 }
62
64 {
65 return this->isLoadedFromDb() ? this->getVDesignator() % this->getDbKeyAsStringInParentheses(" ") :
66 this->getVDesignator();
67 }
68
69 void CAirlineIcaoCode::setDesignator(const QString &icaoDesignator)
70 {
71 m_designator = icaoDesignator.trimmed().toUpper();
72 if (m_designator.length() == 4 && m_designator.startsWith("V"))
73 {
74 // a virtual designator was provided
75 this->setVirtualAirline(true);
76 m_designator = m_designator.right(3);
77 }
78 }
79
81 {
82 return (this->isLoadedFromDb()) ?
83 this->getDesignator() % QStringLiteral(" ") % this->getDbKeyAsStringInParentheses() :
84 this->getDesignator();
85 }
86
88 {
89 return this->getDesignator() % (this->hasName() ? (u' ' % this->getName()) : QString()) %
90 (this->hasValidCountry() ? (u' ' % this->getCountryIso()) : QString());
91 }
92
94
95 bool CAirlineIcaoCode::hasValidCountry() const { return m_country.isValid(); }
96
98
99 bool CAirlineIcaoCode::hasIataCode() const { return !m_iataCode.isEmpty(); }
100
101 bool CAirlineIcaoCode::matchesDesignator(const QString &designator) const
102 {
103 if (designator.isEmpty() || m_designator.isEmpty())
104 {
105 return false;
106 }
107 return caseInsensitiveStringCompare(m_designator, designator.trimmed());
108 }
109
110 bool CAirlineIcaoCode::matchesVDesignator(const QString &designator) const
111 {
112 if (designator.isEmpty() || m_designator.isEmpty())
113 {
114 return false;
115 }
116 return caseInsensitiveStringCompare(this->getVDesignator(), designator.trimmed());
117 }
118
120 {
121 if (iata.isEmpty() || m_iataCode.isEmpty())
122 {
123 return false;
124 }
125 return caseInsensitiveStringCompare(m_iataCode, iata.trimmed());
126 }
127
129 {
130 if (candidate.isEmpty())
131 {
132 return false;
133 }
134 return this->matchesDesignator(candidate) || this->matchesIataCode(candidate);
135 }
136
138 {
139 if (candidate.isEmpty())
140 {
141 return false;
142 }
143 return this->matchesVDesignator(candidate) || this->matchesIataCode(candidate);
144 }
145
147 {
148 if (candidate.isEmpty() || m_telephonyDesignator.isEmpty())
149 {
150 return false;
151 }
152 return caseInsensitiveStringCompare(m_telephonyDesignator, candidate.trimmed());
153 }
154
156 {
157 const QString cand(candidate.toUpper().trimmed());
158 if (this->getName().contains(cand, Qt::CaseInsensitive) ||
159 this->getTelephonyDesignator().contains(cand, Qt::CaseInsensitive))
160 {
161 return true;
162 }
163 return this->isContainedInSimplifiedName(candidate);
164 }
165
167 {
168 if (candidate.isEmpty() || !this->hasName())
169 {
170 return false;
171 }
172 auto simplifiedName = getName() | std::views::filter([](QChar c) { return c.isLetter(); });
173 const auto match =
174 std::ranges::search(simplifiedName, candidate, [](QChar a, QChar b) { return a.toUpper() == b.toUpper(); });
175 return !match.empty();
176 }
177
178 bool CAirlineIcaoCode::hasSimplifiedName() const { return this->hasName() && !this->getSimplifiedName().isEmpty(); }
179
181 {
182 return this->hasValidDesignator() && this->hasValidCountry() && this->hasName();
183 }
184
186 {
187 // if (this->hasValidDbKey() && CAirlineIcaoCode::iconIds().contains(this->getDbKey()))
188 //{
189 // static const QString p("airlines/%1_%2.png");
190 // const QString n(p.arg(this->getDbKey(), 5, 10, QChar('0')).arg(this->getDesignator()));
191 // return CIcon(n, this->convertToQString());
192 // }
193 return CIcons::StandardIconEmpty;
194 }
195
197 {
198 Q_UNUSED(i18n);
199 const QString s = this->getDesignatorDbKey() % (this->hasName() ? u' ' % m_name : QString()) % u" Op: " %
200 boolToYesNo(this->isOperating()) % u" VA: " % boolToYesNo(this->isVirtualAirline()) %
201 u" Mil: " % boolToYesNo(this->isMilitary());
202 return s.trimmed();
203 }
204
206 {
207 if (index.isMyself())
208 {
209 return QVariant::fromValue(*this);
210 }
212 {
214 }
215 const auto i = index.frontCasted<ColumnIndex>();
216 switch (i)
217 {
218 case IndexAirlineDesignator: return QVariant::fromValue(m_designator);
219 case IndexIataCode: return QVariant::fromValue(m_iataCode);
220 case IndexAirlineCountryIso: return QVariant::fromValue(this->getCountryIso());
221 case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
222 case IndexAirlineName: return QVariant::fromValue(m_name);
223 case IndexTelephonyDesignator: return QVariant::fromValue(m_telephonyDesignator);
224 case IndexIsVirtualAirline: return QVariant::fromValue(m_isVa);
225 case IndexIsOperating: return QVariant::fromValue(m_isOperating);
226 case IndexIsMilitary: return QVariant::fromValue(m_isMilitary);
227 case IndexDesignatorNameCountry: return QVariant::fromValue(this->getDesignatorNameCountry());
228 case IndexGroupDesignator: return QVariant::fromValue(this->getGroupDesignator());
229 case IndexGroupName: return QVariant::fromValue(this->getGroupName());
230 case IndexGroupId: return QVariant::fromValue(this->getGroupId());
231 default: return CValueObject::propertyByIndex(index);
232 }
233 }
234
236 {
237 if (index.isMyself())
238 {
239 (*this) = variant.value<CAirlineIcaoCode>();
240 return;
241 }
243 {
245 return;
246 }
247 const auto i = index.frontCasted<ColumnIndex>();
248 switch (i)
249 {
250 case IndexAirlineDesignator: this->setDesignator(variant.value<QString>()); break;
251 case IndexIataCode: this->setIataCode(variant.value<QString>()); break;
252 case IndexAirlineCountry: this->setCountry(variant.value<CCountry>()); break;
253 case IndexAirlineName: this->setName(variant.value<QString>()); break;
254 case IndexTelephonyDesignator: this->setTelephonyDesignator(variant.value<QString>()); break;
255 case IndexIsVirtualAirline: this->setVirtualAirline(variant.toBool()); break;
256 case IndexIsOperating: this->setOperating(variant.toBool()); break;
257 case IndexIsMilitary: this->setMilitary(variant.toBool()); break;
258 case IndexGroupDesignator: this->setGroupDesignator(variant.toString()); break;
259 case IndexGroupName: this->setGroupName(variant.toString()); break;
260 case IndexGroupId: this->setGroupId(variant.toInt()); break;
261 default: CValueObject::setPropertyByIndex(index, variant); break;
262 }
263 }
264
266 {
267 if (index.isMyself())
268 {
269 return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive);
270 }
272 {
274 }
275 const auto i = index.frontCasted<ColumnIndex>();
276 switch (i)
277 {
278 case IndexAirlineDesignator: return m_designator.compare(compareValue.getDesignator());
279 case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode());
280 case IndexAirlineCountry:
281 return m_country.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCountry());
282 case IndexDesignatorNameCountry:
283 return m_country.getName().compare(compareValue.getCountry().getName(), Qt::CaseInsensitive);
284 case IndexAirlineName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
285 case IndexTelephonyDesignator:
286 return m_telephonyDesignator.compare(compareValue.getTelephonyDesignator(), Qt::CaseInsensitive);
287 case IndexIsVirtualAirline: return Compare::compare(this->isVirtualAirline(), compareValue.isVirtualAirline());
288 case IndexIsOperating: return Compare::compare(this->isOperating(), compareValue.isOperating());
289 case IndexIsMilitary: return Compare::compare(this->isMilitary(), compareValue.isMilitary());
290 case IndexGroupDesignator:
291 return m_groupDesignator.compare(compareValue.getGroupDesignator(), Qt::CaseInsensitive);
292 case IndexGroupName: return m_groupName.compare(compareValue.getGroupName(), Qt::CaseInsensitive);
293 case IndexGroupId: return Compare::compare(m_groupId, compareValue.getGroupId());
294 default: break;
295 }
296 Q_ASSERT_X(false, Q_FUNC_INFO, "No compare function");
297 return 0;
298 }
299
301 {
302 static const CLogCategoryList cats(CLogCategoryList(this).withValidation());
304 if (!hasValidDesignator())
305 {
306 msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing designator"));
307 }
308 if (!hasValidCountry())
309 {
310 msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: missing country"));
311 }
312 if (!hasName())
313 {
314 msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"Airline: no name"));
315 }
316 return msgs;
317 }
318
320 {
321 // allow 2 chars for special codes like "VV"
322 if (airline.length() < 2 || airline.length() > 5)
323 {
324 return false;
325 }
326 const auto chars = makeRange(airline.begin(), airline.end());
327 return !chars.containsBy([](QChar c) { return !c.isUpper() && !c.isDigit(); });
328 }
329
331 {
332 if (iataCode.length() != 2)
333 {
334 return false;
335 }
336 return isValidAirlineDesignator(iataCode); // allow some chars as in IACO
337 }
338
340 {
341 static const QSet<QString> valid({ "VV", "VM" });
342 return valid;
343 }
344
346 {
347 QString n(candidate.trimmed().toUpper());
348 n = n.left(indexOfChar(n, [](QChar c) { return c.isSpace(); }));
349 return removeChars(n, [](QChar c) { return !c.isLetterOrNumber(); });
350 }
351
353 const QStringList &extraCategories, CStatusMessage::StatusSeverity s)
354 {
355 static const CLogCategoryList cats({ CLogCategories::aviation() });
356 const CStatusMessage m(cats.with(CLogCategoryList::fromQStringList(extraCategories)), s,
357 icaoCode.hasValidDesignator() ?
358 icaoCode.getVDesignatorDbKey() + ": " + message.trimmed() :
359 message.trimmed());
360 return m;
361 }
362
364 const QString &message, const QStringList &extraCategories,
366 {
367 if (!log)
368 {
369 return;
370 }
371 if (message.isEmpty())
372 {
373 return;
374 }
375 log->push_back(logMessage(icao, message, extraCategories, s));
376 }
377
379 {
380 return (this->hasValidDesignator() ? this->getVDesignator() : QString()) %
381 (this->hasName() ? u' ' % m_name : QString()) % this->getDbKeyAsStringInParentheses(" ");
382 }
383
385 {
386 if (this->hasValidDbKey())
387 {
388 return *this;
389 }
390 if (callsign.isEmpty())
391 {
392 return *this;
393 }
394 const QString callsignAirline = callsign.getAirlinePrefix();
395 if (callsignAirline.isEmpty())
396 {
397 return *this;
398 }
399 if (callsignAirline == m_designator)
400 {
401 return *this;
402 }
403
404 const CAirlineIcaoCode callsignIcao(callsignAirline);
405 if (m_designator.isEmpty())
406 {
407 return callsignIcao;
408 }
409
410 // here we have 2 possible codes
411 if (callsignIcao.isVirtualAirline())
412 {
413
414 if (callsignIcao.getDesignator().endsWith(m_designator))
415 {
416 // callsign ICAO is virtual airline of myself, this is more accurate
417 return callsignIcao;
418 }
419 }
420 return *this;
421 }
422
424 {
425 if (!this->hasValidDbKey())
426 {
427 return this->getName();
428 }
429 return this->hasName() ? QString(this->getName()).append(" ").append(this->getDbKeyAsStringInParentheses()) :
431 }
432
434 {
435 if (!this->hasValidDbKey() && otherIcaoCode.hasValidDbKey())
436 {
437 // we have no DB data, but the other one has
438 // so we change roles. We take the DB object as base, and update our parts
439 CAirlineIcaoCode copy(otherIcaoCode);
440 copy.updateMissingParts(*this);
441 *this = copy;
442 return;
443 }
444
445 if (!this->hasValidDesignator())
446 {
447 this->setDesignator(otherIcaoCode.getDesignator());
448 }
449 if (!this->hasValidCountry())
450 {
451 this->setCountry(otherIcaoCode.getCountry());
452 }
453 if (!this->hasName())
454 {
455 this->setName(otherIcaoCode.getName());
456 }
457 if (!this->hasTelephonyDesignator())
458 {
459 this->setTelephonyDesignator(otherIcaoCode.getTelephonyDesignator());
460 }
461 if (!this->hasValidDbKey())
462 {
463 this->setDbKey(otherIcaoCode.getDbKey());
464 this->setUtcTimestamp(otherIcaoCode.getUtcTimestamp());
465 }
466 }
467
469
471 {
472 if (this->isDbEqual(otherCode))
473 {
474 addLogDetailsToList(log, *this, QStringLiteral("DB equal score: 100"));
475 return 100;
476 }
477 const bool bothFromDb = this->isLoadedFromDb() && otherCode.isLoadedFromDb();
478 int score = 0;
479 if (otherCode.hasValidDesignator() && this->getDesignator() == otherCode.getDesignator())
480 {
481 score += 60;
482 addLogDetailsToList(log, *this, QStringLiteral("Same designator: %1").arg(score));
483 }
484
485 // only for DB values we check VA
486 if (bothFromDb && this->isVirtualAirline() == otherCode.isVirtualAirline())
487 {
488 score += 20;
489 addLogDetailsToList(log, *this, QStringLiteral("VA equality: %1").arg(score));
490 }
491
492 // consider the various names
493 if (this->hasName() && this->getName() == otherCode.getName())
494 {
495 score += 20;
496 addLogDetailsToList(log, *this, QStringLiteral("Same name '%1': %2").arg(this->getName()).arg(score));
497 }
498 else if (this->hasTelephonyDesignator() && this->getTelephonyDesignator() == otherCode.getTelephonyDesignator())
499 {
500 score += 15;
502 log, *this, QStringLiteral("Same telephony '%1': %2").arg(this->getTelephonyDesignator()).arg(score));
503 }
504 else if (this->hasSimplifiedName() && this->getSimplifiedName() == otherCode.getSimplifiedName())
505 {
506 score += 10;
508 log, *this, QStringLiteral("Same simplified name '%1': %2").arg(this->getSimplifiedName()).arg(score));
509 }
510 return score;
511 }
512
514 {
515 return m_designator.isNull() && m_iataCode.isNull() && m_telephonyDesignator.isNull();
516 }
517
519 {
520 static const CAirlineIcaoCode null;
521 return null;
522 }
523
525 {
526 if (!existsKey(json, prefix))
527 {
528 // when using relationship, this can be null (e.g. for color liveries)
529 return {};
530 }
531
532 QString designator(json.value(prefix % u"designator").toString());
534 {
535 designator = CAirlineIcaoCode::normalizeDesignator(designator);
536 }
537
538 const QString iata(json.value(prefix % u"iata").toString());
539 const QString telephony(json.value(prefix % u"callsign").toString());
540 const QString name(json.value(prefix % u"name").toString());
541 const QString countryIso(json.value(prefix % u"country").toString());
542 const QString countryName(json.value(prefix % u"countryname").toString());
543 const QString groupName(json.value(prefix % u"groupname").toString());
544 const QString groupDesignator(json.value(prefix % u"groupdesignator").toString());
545 const int groupId(json.value(prefix % u"groupid").toInt(-1));
546 const bool va = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % u"va").toString());
547 const bool operating = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % u"operating").toString());
548 const bool military = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % u"military").toString());
549
550 CAirlineIcaoCode code(designator, name, CCountry(countryIso, countryName), telephony, va, operating);
551 code.setIataCode(iata);
552 code.setMilitary(military);
553 code.setGroupDesignator(groupDesignator);
554 code.setGroupId(groupId);
555 code.setGroupName(groupName);
557 return code;
558 }
559} // namespace swift::misc::aviation
const QString & getName() const
Country name.
Definition country.h:73
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Definition icons.h:32
static const QString & aviation()
Aviation specific.
A sequence of log categories.
static CLogCategoryList fromQStringList(const QStringList &stringList)
Convert a string list, such as that returned by toQStringList(), into a CLogCategoryList.
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.
Definition sequence.h:308
Streamable status message, e.g.
static constexpr auto SeverityError
Status severities.
swift::misc::StatusSeverity StatusSeverity
Status severities.
Status messages, e.g. from Core -> GUI.
QDateTime getUtcTimestamp() const
Get timestamp.
void setUtcTimestamp(const QDateTime &timestamp)
Set timestamp.
QString getCombinedStringWithKey() const
Comined string with key.
void setMilitary(bool military)
Military, air force or such?
bool isVirtualAirline() const
Virtual airline.
static bool isValidAirlineDesignator(const QString &airline)
Valid designator?
static QSet< QString > specialValidDesignators()
Some special valid designator which do not fit standard rule (e.g. 3-letter code).
void setTelephonyDesignator(const QString &telephony)
Telephony designator such as "Speedbird".
void setOperating(bool operating)
Operating airline?
CAirlineIcaoCode()=default
Default constructor.
bool isContainedInSimplifiedName(const QString &candidate) const
Does simplified name contain the candidate.
QString getVDesignatorDbKey() const
Get VDesignator plus key.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool matchesDesignator(const QString &designator) const
Matches designator string?
bool isMilitary() const
Military, air force or such?
static const CAirlineIcaoCode & null()
NULL object.
QString getSimplifiedName() const
Get a simplified upper case name for searching by removing all characters except A-Z.
const QString & getIataCode() const
IATA code.
QString getDesignatorDbKey() const
Designator and DB key.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
const CCountry & getCountry() const
Get country, e.g. "FRANCE".
const QString & getTelephonyDesignator() const
Telephony designator such as "Speedbird".
QString convertToQString(bool i18n=false) const
Cast as QString.
void setVirtualAirline(bool va)
Virtual airline.
CStatusMessageList validate() const
Validate data.
static QString normalizeDesignator(const QString &candidate)
Normalize string as airline designator.
bool hasTelephonyDesignator() const
Telephony designator?
void setIataCode(const QString &iataCode)
Set IATA code.
bool hasCompleteData() const
Complete data.
bool hasValidDesignator() const
Airline designator available?
static CAirlineIcaoCode fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
From our DB JSON.
void updateMissingParts(const CAirlineIcaoCode &otherIcaoCode)
Update missing parts.
void setName(const QString &name)
Set name.
bool matchesTelephonyDesignator(const QString &candidate) const
Matches telephony designator (aka callsign, not to be confused with CCallsign).
void setCountry(const CCountry &country)
Set country.
QString asHtmlSummary() const
As a brief HTML summary (e.g. used in tooltips).
bool matchesVDesignator(const QString &designator) const
Matches v-designator string?
const QString & getGroupName() const
Group name.
CIcons::IconIndex toIcon() const
As icon, not implemented by all classes.
void setGroupDesignator(const QString &designator)
Group designator.
int calculateScore(const CAirlineIcaoCode &otherCode, CStatusMessageList *log=nullptr) const
Score against other code 0..100.
static bool isValidIataCode(const QString &iataCode)
Valid IATA code?
bool matchesNamesOrTelephonyDesignator(const QString &candidate) const
Relaxed check by name or telephony designator (aka callsign, not to be confused with CCallsign).
bool matchesVDesignatorOrIataCode(const QString &candidate) const
Matches IATA code or v-designator?
bool matchesDesignatorOrIataCode(const QString &candidate) const
Matches IATA code or designator?
void setDesignator(const QString &icaoDesignator)
Set airline, e.g. "DLH".
bool matchesIataCode(const QString &iata) const
Matches IATA code?
static CStatusMessage logMessage(const CAirlineIcaoCode &icaoCode, const QString &message, const QStringList &extraCategories={}, CStatusMessage::StatusSeverity s=CStatusMessage::SeverityInfo)
Specialized log message for matching / reverse lookup.
const QString & getGroupDesignator() const
Group designator.
static void addLogDetailsToList(CStatusMessageList *log, const CAirlineIcaoCode &icao, const QString &message, const QStringList &extraCategories={}, CStatusMessage::StatusSeverity s=CStatusMessage::SeverityInfo)
Specialized log for matching / reverse lookup.
int comparePropertyByIndex(CPropertyIndexRef index, const CAirlineIcaoCode &compareValue) const
Compare for index.
void setGroupName(const QString &name)
Group name.
QString getDesignatorNameCountry() const
Combined string designator, name, country.
QString getVDesignator() const
Get airline, e.g. "DLH", but "VMVA" for virtual airlines.
CAirlineIcaoCode thisOrCallsignCode(const CCallsign &callsign) const
What is better, the callsign airline code or this code. Return the better one.
QString getNameWithKey() const
Name plus key, e.g. "Lufthansa (3421)".
const QString & getDesignator() const
Get airline, e.g. "DLH".
bool hasSimplifiedName() const
Has simplified airline name?
const QString & getName() const
Get name, e.g. "Lufthansa".
const QString & getCountryIso() const
Get country, e.g. "FR".
bool hasName() const
Has (airline) name?
Value object encapsulating information of a callsign.
Definition callsign.h:30
bool isEmpty() const
Is empty?
Definition callsign.h:63
QString getAirlinePrefix() const
Airline suffix (e.g. DLH1234 -> DLH) if applicable.
Definition callsign.cpp:348
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.
Definition datastore.cpp:58
static bool existsKey(const QJsonObject &json, const QString &prefix=QString())
Is a key available?
static bool canHandleIndex(swift::misc::CPropertyIndexRef index)
Can given index be handled?
void setDbKey(int key)
Set the DB key.
Definition datastore.h:96
bool isDbEqual(const IDatastoreObjectWithIntegerKey &other) const
Same DB key and hence equal.
Definition datastore.h:105
QString getDbKeyAsStringInParentheses(const QString &prefix={}) const
Db key in parentheses, e.g. "(3)".
Definition datastore.cpp:42
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.
bool hasValidDbKey() const
Has valid DB key.
Definition datastore.h:102
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition mixinindex.h:167
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition mixinindex.h:180
int compare(T a, T b)
Compare arithmetic values.
Free functions in swift::misc.
SWIFT_MISC_EXPORT QString simplifyNameForSearch(const QString &name)
Get a simplified upper case name for searching by removing all characters except A-Z.
QString removeChars(const QString &s, F predicate)
Return a string with characters removed that match the given predicate.
Definition stringutils.h:34
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
auto makeRange(I begin, I2 end) -> CRange< I >
Returns a CRange constructed from begin and end iterators of deduced types.
Definition range.h:328
SWIFT_MISC_EXPORT bool caseInsensitiveStringCompare(const QString &c1, const QString &c2)
Case insensitive string compare.
int indexOfChar(const QString &s, F predicate)
Index of first character in the string matching the given predicate, or -1 if not found.
Definition stringutils.h:77
bool isDigit(char32_t ucs4)
bool isLetter(char32_t ucs4)
bool isLetterOrNumber(char32_t ucs4)
bool isSpace(char32_t ucs4)
bool isUpper(char32_t ucs4)
char32_t toUpper(char32_t ucs4)
QString & append(QChar ch)
QString::iterator begin()
QString::iterator end()
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) &&
qsizetype length() const const
QString toUpper() const const
QString trimmed() const const
CaseInsensitive
QVariant fromValue(T &&value)
bool toBool() const const
int toInt(bool *ok) const const
QString toString() const const
T value() const &const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition valueobject.h:67