Ref T129, formatted aircraftmodel and simulated aircraft

This commit is contained in:
Klaus Basan
2017-09-30 18:11:37 +02:00
committed by Mathew Sutcliffe
parent 9b51ec251c
commit ba8d0c1f64
4 changed files with 248 additions and 378 deletions

View File

@@ -58,11 +58,11 @@ namespace BlackMisc
QString CAircraftModel::convertToQString(bool i18n) const QString CAircraftModel::convertToQString(bool i18n) const
{ {
const QString s = const QString s =
this->m_modelString % m_modelString %
QLatin1String(" type: '") % this->getModelTypeAsString() % QLatin1String(" type: '") % this->getModelTypeAsString() %
QLatin1String("' ICAO: '") % this->getAircraftIcaoCode().toQString(i18n) % QLatin1String("' ICAO: '") % this->getAircraftIcaoCode().toQString(i18n) %
QLatin1String("' {") % this->m_livery.toQString(i18n) % QLatin1String("' {") % m_livery.toQString(i18n) %
QLatin1String("} file: '") % this->m_fileName % QLatin1String("'"); QLatin1String("} file: '") % m_fileName % QLatin1String("'");
return s; return s;
} }
@@ -73,8 +73,8 @@ namespace BlackMisc
// filename not in DB // filename not in DB
obj.insert("id", this->getDbKeyAsJsonValue()); obj.insert("id", this->getDbKeyAsJsonValue());
obj.insert("name", this->getName()); obj.insert("name", this->getName());
obj.insert("modelstring", QJsonValue(this->m_modelString)); obj.insert("modelstring", QJsonValue(m_modelString));
obj.insert("description", QJsonValue(this->m_description)); obj.insert("description", QJsonValue(m_description));
obj.insert("mode", QJsonValue(getModelModeAsString().left(1).toUpper())); // clazy:exclude=qstring-left obj.insert("mode", QJsonValue(getModelModeAsString().left(1).toUpper())); // clazy:exclude=qstring-left
// sims // sims
@@ -144,8 +144,8 @@ namespace BlackMisc
void CAircraftModel::setCallsign(const CCallsign &callsign) void CAircraftModel::setCallsign(const CCallsign &callsign)
{ {
this->m_callsign = callsign; m_callsign = callsign;
this->m_callsign.setTypeHint(CCallsign::Aircraft); m_callsign.setTypeHint(CCallsign::Aircraft);
} }
QString CAircraftModel::getModelStringAndDbKey() const QString CAircraftModel::getModelStringAndDbKey() const
@@ -176,48 +176,27 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexModelString: case IndexModelString: return CVariant(m_modelString);
return CVariant(this->m_modelString); case IndexHasQueriedModelString: return CVariant::fromValue(this->hasQueriedModelString());
case IndexHasQueriedModelString: case IndexModelType: return CVariant::fromValue(m_modelType);
return CVariant::fromValue(this->hasQueriedModelString()); case IndexModelTypeAsString: return CVariant(this->getModelTypeAsString());
case IndexModelType: case IndexModelMode: return CVariant::fromValue(m_modelMode);
return CVariant::fromValue(this->m_modelType); case IndexModelModeAsString: return CVariant::fromValue(this->getModelModeAsString());
case IndexModelTypeAsString: case IndexModelModeAsIcon: return CVariant::fromValue(this->getModelModeAsIcon());
return CVariant(this->getModelTypeAsString()); case IndexDistributor: return m_distributor.propertyByIndex(index.copyFrontRemoved());
case IndexModelMode: case IndexSimulatorInfo: return m_simulator.propertyByIndex(index.copyFrontRemoved());
return CVariant::fromValue(this->m_modelMode); case IndexSimulatorInfoAsString: return CVariant(m_simulator.toQString());
case IndexModelModeAsString: case IndexDescription: return CVariant(m_description);
return CVariant::fromValue(this->getModelModeAsString()); case IndexName: return CVariant(m_name);
case IndexModelModeAsIcon: case IndexFileName: return CVariant(m_fileName);
return CVariant::fromValue(this->getModelModeAsIcon()); case IndexFileTimestamp: return CVariant::fromValue(this->getFileTimestamp());
case IndexDistributor: case IndexFileTimestampFormattedYmdhms: return CVariant::fromValue(this->getFormattedFileTimestampYmdhms());
return m_distributor.propertyByIndex(index.copyFrontRemoved()); case IndexIconPath: return CVariant(m_iconPath);
case IndexSimulatorInfo: case IndexAircraftIcaoCode: return m_aircraftIcao.propertyByIndex(index.copyFrontRemoved());
return m_simulator.propertyByIndex(index.copyFrontRemoved()); case IndexLivery: return m_livery.propertyByIndex(index.copyFrontRemoved());
case IndexSimulatorInfoAsString: case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
return CVariant(m_simulator.toQString()); case IndexMembersDbStatus: return this->getMembersDbStatus();
case IndexDescription: default: return CValueObject::propertyByIndex(index);
return CVariant(this->m_description);
case IndexName:
return CVariant(this->m_name);
case IndexFileName:
return CVariant(this->m_fileName);
case IndexFileTimestamp:
return CVariant::fromValue(this->getFileTimestamp());
case IndexFileTimestampFormattedYmdhms:
return CVariant::fromValue(this->getFormattedFileTimestampYmdhms());
case IndexIconPath:
return CVariant(this->m_iconPath);
case IndexAircraftIcaoCode:
return m_aircraftIcao.propertyByIndex(index.copyFrontRemoved());
case IndexLivery:
return m_livery.propertyByIndex(index.copyFrontRemoved());
case IndexCallsign:
return m_callsign.propertyByIndex(index.copyFrontRemoved());
case IndexMembersDbStatus:
return getMembersDbStatus();
default:
return CValueObject::propertyByIndex(index);
} }
} }
@@ -230,33 +209,19 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexModelString: case IndexModelString: m_modelString = variant.toQString(); break;
this->m_modelString = variant.toQString(); case IndexAircraftIcaoCode: m_aircraftIcao.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
break; case IndexLivery: m_livery.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexAircraftIcaoCode: case IndexDistributor: m_distributor.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
this->m_aircraftIcao.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexDescription: m_description = variant.toQString(); break;
break; case IndexSimulatorInfo: m_simulator.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexLivery: case IndexName: m_name = variant.toQString(); break;
this->m_livery.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexIconPath: m_iconPath = variant.toQString(); break;
break; case IndexModelType: m_modelType = variant.value<ModelType>(); break;
case IndexDistributor: case IndexFileName: m_fileName = variant.toQString(); break;
this->m_distributor.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexDescription:
this->m_description = variant.toQString();
break;
case IndexSimulatorInfo:
this->m_simulator.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexName:
this->m_name = variant.toQString();
break;
case IndexCallsign: case IndexCallsign:
this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
this->m_callsign.setTypeHint(CCallsign::Aircraft); m_callsign.setTypeHint(CCallsign::Aircraft);
break;
case IndexFileName:
this->m_fileName = variant.toQString();
break; break;
case IndexFileTimestamp: case IndexFileTimestamp:
if (variant.canConvert<QDateTime>()) if (variant.canConvert<QDateTime>())
@@ -265,15 +230,9 @@ namespace BlackMisc
} }
else if (variant.canConvert<qint64>()) else if (variant.canConvert<qint64>())
{ {
this->m_fileTimestamp = variant.value<qint64>(); m_fileTimestamp = variant.value<qint64>();
} }
break; break;
case IndexIconPath:
this->m_iconPath = variant.toQString();
break;
case IndexModelType:
this->m_modelType = variant.value<ModelType>();
break;
case IndexModelMode: case IndexModelMode:
if (variant.type() == QMetaType::QString) if (variant.type() == QMetaType::QString)
{ {
@@ -281,12 +240,10 @@ namespace BlackMisc
} }
else else
{ {
this->m_modelMode = variant.value<ModelMode>(); m_modelMode = variant.value<ModelMode>();
} }
break; break;
default: default: CValueObject::setPropertyByIndex(index, variant); break;
CValueObject::setPropertyByIndex(index, variant);
break;
} }
} }
@@ -294,44 +251,29 @@ namespace BlackMisc
{ {
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);} if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue);} if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue);}
if (index.isMyself()) { return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); } if (index.isMyself()) { return m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexModelString: case IndexModelString: return m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive);
return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); case IndexAircraftIcaoCode: return m_aircraftIcao.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAircraftIcaoCode());
case IndexAircraftIcaoCode: case IndexLivery: return m_livery.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
return this->m_aircraftIcao.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAircraftIcaoCode()); case IndexDistributor: return m_distributor.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getDistributor());
case IndexLivery: case IndexDescription: return m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
return this->m_livery.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery()); case IndexName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexDistributor: case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
return this->m_distributor.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getDistributor()); case IndexFileName: return m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
case IndexDescription: case IndexIconPath: return m_iconPath.compare(compareValue.getIconPath(), Qt::CaseInsensitive);
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive); case IndexModelType: return Compare::compare(m_modelType, compareValue.getModelType());
case IndexSimulatorInfoAsString: case IndexSimulatorInfoAsString:
case IndexSimulatorInfo: case IndexSimulatorInfo: return m_simulator.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSimulator());
return this->m_simulator.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSimulator());
case IndexName:
return this->m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexCallsign:
return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
case IndexFileName:
return this->m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
case IndexFileTimestamp: case IndexFileTimestamp:
case IndexFileTimestampFormattedYmdhms: case IndexFileTimestampFormattedYmdhms: return Compare::compare(m_fileTimestamp, compareValue.m_fileTimestamp);
return Compare::compare(this->m_fileTimestamp, compareValue.m_fileTimestamp);
case IndexIconPath:
return this->m_iconPath.compare(compareValue.getIconPath(), Qt::CaseInsensitive);
case IndexModelType:
return Compare::compare(this->m_modelType, compareValue.getModelType());
case IndexModelMode: case IndexModelMode:
case IndexModelModeAsString: case IndexModelModeAsString:
case IndexModelModeAsIcon: case IndexModelModeAsIcon: return Compare::compare(m_modelMode, compareValue.getModelMode());
return Compare::compare(this->m_modelMode, compareValue.getModelMode()); case IndexMembersDbStatus: return getMembersDbStatus().compare(compareValue.getMembersDbStatus());
case IndexMembersDbStatus: default: break;
return getMembersDbStatus().compare(compareValue.getMembersDbStatus());
default:
break;
} }
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison"); Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
return 0; return 0;
@@ -339,14 +281,14 @@ namespace BlackMisc
bool CAircraftModel::setAircraftIcaoCode(const CAircraftIcaoCode &aircraftIcaoCode) bool CAircraftModel::setAircraftIcaoCode(const CAircraftIcaoCode &aircraftIcaoCode)
{ {
if (this->m_aircraftIcao == aircraftIcaoCode) { return false; } if (m_aircraftIcao == aircraftIcaoCode) { return false; }
this->m_aircraftIcao = aircraftIcaoCode; m_aircraftIcao = aircraftIcaoCode;
return true; return true;
} }
void CAircraftModel::setAircraftIcaoDesignator(const QString &designator) void CAircraftModel::setAircraftIcaoDesignator(const QString &designator)
{ {
this->m_aircraftIcao.setDesignator(designator); m_aircraftIcao.setDesignator(designator);
} }
void CAircraftModel::setAircraftIcaoCodes(const CAircraftIcaoCode &aircraftIcaoCode, const CAirlineIcaoCode &airlineIcaoCode) void CAircraftModel::setAircraftIcaoCodes(const CAircraftIcaoCode &aircraftIcaoCode, const CAirlineIcaoCode &airlineIcaoCode)
@@ -357,22 +299,22 @@ namespace BlackMisc
bool CAircraftModel::hasValidAircraftAndAirlineDesignator() const bool CAircraftModel::hasValidAircraftAndAirlineDesignator() const
{ {
return this->hasKnownAircraftDesignator() && this->m_livery.hasValidAirlineDesignator(); return this->hasKnownAircraftDesignator() && m_livery.hasValidAirlineDesignator();
} }
bool CAircraftModel::hasAircraftDesignator() const bool CAircraftModel::hasAircraftDesignator() const
{ {
return this->m_aircraftIcao.hasDesignator(); return m_aircraftIcao.hasDesignator();
} }
bool CAircraftModel::hasKnownAircraftDesignator() const bool CAircraftModel::hasKnownAircraftDesignator() const
{ {
return this->m_aircraftIcao.hasKnownDesignator(); return m_aircraftIcao.hasKnownDesignator();
} }
bool CAircraftModel::hasAirlineDesignator() const bool CAircraftModel::hasAirlineDesignator() const
{ {
return this->m_livery.hasValidAirlineDesignator(); return m_livery.hasValidAirlineDesignator();
} }
bool CAircraftModel::hasAircraftAndAirlineDesignator() const bool CAircraftModel::hasAircraftAndAirlineDesignator() const
@@ -389,8 +331,8 @@ namespace BlackMisc
bool CAircraftModel::setDistributorOrder(int order) bool CAircraftModel::setDistributorOrder(int order)
{ {
if (order < 0) { return false; } if (order < 0) { return false; }
if (!this->m_distributor.isLoadedFromDb()) { return false; } if (!m_distributor.isLoadedFromDb()) { return false; }
this->m_distributor.setOrder(order); m_distributor.setOrder(order);
return true; return true;
} }
@@ -401,64 +343,61 @@ namespace BlackMisc
const int noDistributorOrder = distributors.size(); const int noDistributorOrder = distributors.size();
if (this->hasDbDistributor()) if (this->hasDbDistributor())
{ {
const CDistributor d = distributors.findByKeyOrAlias(this->m_distributor.getDbKey()); const CDistributor d = distributors.findByKeyOrAlias(m_distributor.getDbKey());
if (d.hasValidDbKey()) if (d.hasValidDbKey())
{ {
this->m_distributor.setOrder(d.getOrder()); m_distributor.setOrder(d.getOrder());
found = true; found = true;
} }
else else
{ {
this->m_distributor.setOrder(noDistributorOrder); m_distributor.setOrder(noDistributorOrder);
} }
} }
else else
{ {
this->m_distributor.setOrder(noDistributorOrder); m_distributor.setOrder(noDistributorOrder);
} }
return found; return found;
} }
bool CAircraftModel::hasDbDistributor() const bool CAircraftModel::hasDbDistributor() const
{ {
return this->m_distributor.isLoadedFromDb(); return m_distributor.isLoadedFromDb();
} }
bool CAircraftModel::hasDistributor() const bool CAircraftModel::hasDistributor() const
{ {
return this->m_distributor.hasValidDbKey(); // key is valid, but not guaranteed from DB return m_distributor.hasValidDbKey(); // key is valid, but not guaranteed from DB
} }
bool CAircraftModel::matchesDbDistributor(const CDistributor &distributor) const bool CAircraftModel::matchesDbDistributor(const CDistributor &distributor) const
{ {
if (!distributor.isLoadedFromDb()) { return false; } if (!distributor.isLoadedFromDb()) { return false; }
if (!this->hasDbDistributor()) { return false; } if (!this->hasDbDistributor()) { return false; }
return this->m_distributor.getDbKey() == distributor.getDbKey(); return m_distributor.getDbKey() == distributor.getDbKey();
} }
bool CAircraftModel::matchesAnyDbDistributor(const CDistributorList &distributors) const bool CAircraftModel::matchesAnyDbDistributor(const CDistributorList &distributors) const
{ {
if (distributors.isEmpty()) { return false; } if (distributors.isEmpty()) { return false; }
if (!this->hasDbDistributor()) { return false; } if (!this->hasDbDistributor()) { return false; }
return distributors.matchesAnyKeyOrAlias(this->m_distributor.getDbKey()); return distributors.matchesAnyKeyOrAlias(m_distributor.getDbKey());
} }
bool CAircraftModel::matchesMode(ModelModeFilter mode) const bool CAircraftModel::matchesMode(ModelModeFilter mode) const
{ {
if (mode == All) { return true; } if (mode == All) { return true; }
return (mode & this->m_modelMode) > 0; return (mode & m_modelMode) > 0;
} }
const CIcon &CAircraftModel::getModelModeAsIcon() const const CIcon &CAircraftModel::getModelModeAsIcon() const
{ {
switch (this->getModelMode()) switch (this->getModelMode())
{ {
case Include: case Include: return CIcon::iconByIndex(CIcons::ModelInclude);
return CIcon::iconByIndex(CIcons::ModelInclude); case Exclude: return CIcon::iconByIndex(CIcons::ModelExclude);
case Exclude: case Undefined: return CIcon::iconByIndex(CIcons::StandardIconUnknown16);
return CIcon::iconByIndex(CIcons::ModelExclude);
case Undefined:
return CIcon::iconByIndex(CIcons::StandardIconUnknown16);
default: default:
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong mode"); Q_ASSERT_X(false, Q_FUNC_INFO, "wrong mode");
break; break;
@@ -483,7 +422,7 @@ namespace BlackMisc
QDateTime CAircraftModel::getFileTimestamp() const QDateTime CAircraftModel::getFileTimestamp() const
{ {
return this->hasValidFileTimestamp() ? QDateTime::fromMSecsSinceEpoch(this->m_fileTimestamp, Qt::UTC) : QDateTime(); return this->hasValidFileTimestamp() ? QDateTime::fromMSecsSinceEpoch(m_fileTimestamp, Qt::UTC) : QDateTime();
} }
QString CAircraftModel::getFormattedFileTimestampYmdhms() const QString CAircraftModel::getFormattedFileTimestampYmdhms() const
@@ -495,26 +434,26 @@ namespace BlackMisc
bool CAircraftModel::hasValidFileTimestamp() const bool CAircraftModel::hasValidFileTimestamp() const
{ {
return this->m_fileTimestamp >= 0; return m_fileTimestamp >= 0;
} }
void CAircraftModel::setFileTimestamp(const QDateTime &timestampUtc) void CAircraftModel::setFileTimestamp(const QDateTime &timestampUtc)
{ {
this->m_fileTimestamp = timestampUtc.toMSecsSinceEpoch(); m_fileTimestamp = timestampUtc.toMSecsSinceEpoch();
} }
void CAircraftModel::setFileTimestamp(qint64 timestamp) void CAircraftModel::setFileTimestamp(qint64 timestamp)
{ {
this->m_fileTimestamp = timestamp; m_fileTimestamp = timestamp;
} }
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
{ {
static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon"); static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon");
if (this->m_iconPath.isEmpty()) { success = noIcon; return CPixmap(); } if (m_iconPath.isEmpty()) { success = noIcon; return CPixmap(); }
// load from file // load from file
const CPixmap pm(CPixmap::loadFromFile(this->m_iconPath, success)); const CPixmap pm(CPixmap::loadFromFile(m_iconPath, success));
return pm; return pm;
} }
@@ -542,37 +481,37 @@ namespace BlackMisc
this->updateLocalFileNames(otherModel); this->updateLocalFileNames(otherModel);
if (this->hasValidDbKey() && otherModel.hasValidDbKey()) { return; } // both are DB data, treat as being the same except for filename maybe if (this->hasValidDbKey() && otherModel.hasValidDbKey()) { return; } // both are DB data, treat as being the same except for filename maybe
if (this->m_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); } if (m_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); }
if (this->m_modelString.isEmpty()) { this->setModelString(otherModel.getModelString()); } if (m_modelString.isEmpty()) { this->setModelString(otherModel.getModelString()); }
if (this->m_name.isEmpty()) { this->setName(otherModel.getName()); } if (m_name.isEmpty()) { this->setName(otherModel.getName()); }
if (this->m_modelType == TypeUnknown) { this->m_modelType = otherModel.getModelType(); } if (m_modelType == TypeUnknown) { m_modelType = otherModel.getModelType(); }
if (this->m_modelMode == Undefined) { this->m_modelType = otherModel.getModelType(); } if (m_modelMode == Undefined) { m_modelType = otherModel.getModelType(); }
if (this->m_fileTimestamp < 0) { this->setFileTimestamp(otherModel.getFileTimestamp()); } if (m_fileTimestamp < 0) { this->setFileTimestamp(otherModel.getFileTimestamp()); }
if (this->m_description.isEmpty() || this->m_description.startsWith(CAircraftModel::autoGenerated(), Qt::CaseInsensitive)) { this->setDescription(otherModel.getDescription()); } if (m_description.isEmpty() || m_description.startsWith(CAircraftModel::autoGenerated(), Qt::CaseInsensitive)) { this->setDescription(otherModel.getDescription()); }
if (this->getSimulator().isUnspecified()) if (this->getSimulator().isUnspecified())
{ {
// simulator can only be overridden as simulators can also be removed // simulator can only be overridden as simulators can also be removed
this->setSimulator(otherModel.getSimulator()); this->setSimulator(otherModel.getSimulator());
} }
this->m_livery.updateMissingParts(otherModel.getLivery()); m_livery.updateMissingParts(otherModel.getLivery());
this->m_aircraftIcao.updateMissingParts(otherModel.getAircraftIcaoCode()); m_aircraftIcao.updateMissingParts(otherModel.getAircraftIcaoCode());
this->m_distributor.updateMissingParts(otherModel.getDistributor()); m_distributor.updateMissingParts(otherModel.getDistributor());
} }
bool CAircraftModel::hasQueriedModelString() const bool CAircraftModel::hasQueriedModelString() const
{ {
return this->m_modelType == TypeQueriedFromNetwork && this->hasModelString(); return m_modelType == TypeQueriedFromNetwork && this->hasModelString();
} }
bool CAircraftModel::hasManuallySetString() const bool CAircraftModel::hasManuallySetString() const
{ {
return this->m_modelType == TypeManuallySet && this->hasModelString(); return m_modelType == TypeManuallySet && this->hasModelString();
} }
bool CAircraftModel::hasDescription(bool ignoreAutoGenerated) const bool CAircraftModel::hasDescription(bool ignoreAutoGenerated) const
{ {
if (this->m_description.isEmpty()) { return false; } if (m_description.isEmpty()) { return false; }
if (!ignoreAutoGenerated) { return true; } if (!ignoreAutoGenerated) { return true; }
return (!this->getDescription().startsWith(autoGenerated(), Qt::CaseInsensitive)); return (!this->getDescription().startsWith(autoGenerated(), Qt::CaseInsensitive));
} }
@@ -601,7 +540,7 @@ namespace BlackMisc
void CAircraftModel::normalizeFileNameForDb() void CAircraftModel::normalizeFileNameForDb()
{ {
this->m_fileName = CAircraftModel::normalizeFileNameForDb(this->m_fileName); m_fileName = CAircraftModel::normalizeFileNameForDb(m_fileName);
} }
void CAircraftModel::updateLocalFileNames(const CAircraftModel &model) void CAircraftModel::updateLocalFileNames(const CAircraftModel &model)
@@ -621,14 +560,14 @@ namespace BlackMisc
} }
// both not local, override empty values // both not local, override empty values
if (this->m_fileName.isEmpty()) { this->setFileName(model.getFileName()); } if (m_fileName.isEmpty()) { this->setFileName(model.getFileName()); }
if (this->m_iconPath.isEmpty()) { this->setIconPath(model.getIconPath()); } if (m_iconPath.isEmpty()) { this->setIconPath(model.getIconPath()); }
} }
bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
{ {
return this->m_modelString.length() == modelString.length() && return m_modelString.length() == modelString.length() &&
this->m_modelString.startsWith(modelString, sensitivity); m_modelString.startsWith(modelString, sensitivity);
} }
int CAircraftModel::calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries) const int CAircraftModel::calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries) const

View File

@@ -143,49 +143,49 @@ namespace BlackMisc
bool canInitializeFromFsd() const; bool canInitializeFromFsd() const;
//! Corresponding callsign if applicable //! Corresponding callsign if applicable
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_callsign; } const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_callsign; }
//! Corresponding callsign if applicable //! Corresponding callsign if applicable
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { this->m_callsign = callsign; } void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
//! Callsign empty //! Callsign empty
bool isCallsignEmpty() const { return this->m_callsign.isEmpty(); } bool isCallsignEmpty() const { return m_callsign.isEmpty(); }
//! Model key, either queried or loaded from simulator model //! Model key, either queried or loaded from simulator model
const QString &getModelString() const { return this->m_modelString; } const QString &getModelString() const { return m_modelString; }
//! Model string and DB key (if available) //! Model string and DB key (if available)
QString getModelStringAndDbKey() const; QString getModelStringAndDbKey() const;
//! Model string //! Model string
void setModelString(const QString &modelString) { this->m_modelString = modelString.trimmed().toUpper(); } void setModelString(const QString &modelString) { m_modelString = modelString.trimmed().toUpper(); }
//! Descriptive text //! Descriptive text
const QString &getDescription() const { return this->m_description; } const QString &getDescription() const { return m_description; }
//! Descriptive text //! Descriptive text
void setDescription(const QString &description) { this->m_description = description.trimmed(); } void setDescription(const QString &description) { m_description = description.trimmed(); }
//! Set queried model string //! Set queried model string
void setQueriedModelString(const QString &model) { this->m_modelString = model; this->m_modelType = TypeQueriedFromNetwork; } void setQueriedModelString(const QString &model) { m_modelString = model; m_modelType = TypeQueriedFromNetwork; }
//! Aircraft ICAO code //! Aircraft ICAO code
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return this->m_aircraftIcao; } const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return m_aircraftIcao; }
//! Aircraft ICAO code designator //! Aircraft ICAO code designator
const QString &getAircraftIcaoCodeDesignator() const { return this->m_aircraftIcao.getDesignator(); } const QString &getAircraftIcaoCodeDesignator() const { return m_aircraftIcao.getDesignator(); }
//! VTOL aircraft? //! VTOL aircraft?
bool isVtol() const; bool isVtol() const;
//! Airline ICAO code //! Airline ICAO code
const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const { return this->m_livery.getAirlineIcaoCode(); } const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const { return m_livery.getAirlineIcaoCode(); }
//! Airline ICAO code designator //! Airline ICAO code designator
const QString &getAirlineIcaoCodeDesignator() const { return this->m_livery.getAirlineIcaoCode().getDesignator(); } const QString &getAirlineIcaoCodeDesignator() const { return m_livery.getAirlineIcaoCode().getDesignator(); }
//! Airline ICAO code designator //! Airline ICAO code designator
const QString getAirlineIcaoCodeVDesignator() const { return this->m_livery.getAirlineIcaoCode().getVDesignator(); } const QString getAirlineIcaoCodeVDesignator() const { return m_livery.getAirlineIcaoCode().getVDesignator(); }
//! Set aircraft ICAO code //! Set aircraft ICAO code
bool setAircraftIcaoCode(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode); bool setAircraftIcaoCode(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode);
@@ -218,7 +218,7 @@ namespace BlackMisc
const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; } const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; }
//! Livery //! Livery
void setLivery(const BlackMisc::Aviation::CLivery &livery) { this->m_livery = livery; } void setLivery(const BlackMisc::Aviation::CLivery &livery) { m_livery = livery; }
//! Livery available? //! Livery available?
bool hasLivery() const { return m_livery.hasCompleteData();} bool hasLivery() const { return m_livery.hasCompleteData();}
@@ -251,10 +251,10 @@ namespace BlackMisc
bool matchesAnyDbDistributor(const CDistributorList &distributors) const; bool matchesAnyDbDistributor(const CDistributorList &distributors) const;
//! Name //! Name
const QString &getName() const { return this->m_name; } const QString &getName() const { return m_name; }
//! Name //! Name
void setName(const QString &name) { this->m_name = name.trimmed(); } void setName(const QString &name) { m_name = name.trimmed(); }
//! Model type //! Model type
ModelType getModelType() const { return m_modelType; } ModelType getModelType() const { return m_modelType; }
@@ -263,7 +263,7 @@ namespace BlackMisc
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); } QString getModelTypeAsString() const { return modelTypeToString(getModelType()); }
//! Set type //! Set type
void setModelType(ModelType type) { this->m_modelType = type; } void setModelType(ModelType type) { m_modelType = type; }
//! Model mode //! Model mode
ModelMode getModelMode() const { return m_modelMode; } ModelMode getModelMode() const { return m_modelMode; }
@@ -284,10 +284,10 @@ namespace BlackMisc
void setModelModeAsString(const QString &mode); void setModelModeAsString(const QString &mode);
//! Simulator info //! Simulator info
CSimulatorInfo getSimulator() const { return this->m_simulator; } CSimulatorInfo getSimulator() const { return m_simulator; }
//! Set simulator info //! Set simulator info
void setSimulator(const CSimulatorInfo &simulator) { this->m_simulator = simulator; } void setSimulator(const CSimulatorInfo &simulator) { m_simulator = simulator; }
//! Matches given simulator? //! Matches given simulator?
bool matchesSimulator(const CSimulatorInfo &simulator) const; bool matchesSimulator(const CSimulatorInfo &simulator) const;

View File

@@ -73,8 +73,8 @@ namespace BlackMisc
{ {
this->setCom1System(com1); this->setCom1System(com1);
this->setCom2System(com2); this->setCom2System(com2);
this->m_transponder.setTransponderCode(transponderCode); m_transponder.setTransponderCode(transponderCode);
this->m_transponder.setTransponderMode(transponderMode); m_transponder.setTransponderMode(transponderMode);
} }
bool CSimulatedAircraft::hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const bool CSimulatedAircraft::hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const
@@ -89,8 +89,8 @@ namespace BlackMisc
bool CSimulatedAircraft::isValidForLogin() const bool CSimulatedAircraft::isValidForLogin() const
{ {
if (this->m_callsign.asString().isEmpty()) { return false; } if (m_callsign.asString().isEmpty()) { return false; }
if (!this->m_pilot.isValid()) { return false; } if (!m_pilot.isValid()) { return false; }
return true; return true;
} }
@@ -107,8 +107,8 @@ namespace BlackMisc
void CSimulatedAircraft::setPilot(const Network::CUser &user) void CSimulatedAircraft::setPilot(const Network::CUser &user)
{ {
this->m_pilot = user; m_pilot = user;
this->m_pilot.setCallsign(this->m_callsign); m_pilot.setCallsign(m_callsign);
} }
bool CSimulatedAircraft::isEnabled() const bool CSimulatedAircraft::isEnabled() const
@@ -133,14 +133,14 @@ namespace BlackMisc
{ {
// create a dummy livery for given ICAO code // create a dummy livery for given ICAO code
CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Standard auto generated"); CLivery newLivery(CLivery::getStandardCode(airlineIcaoCode), airlineIcaoCode, "Standard auto generated");
this->m_models[CurrentModel].setLivery(newLivery); m_models[CurrentModel].setLivery(newLivery);
} }
return this->m_models[CurrentModel].setAircraftIcaoCode(aircraftIcaoCode); return m_models[CurrentModel].setAircraftIcaoCode(aircraftIcaoCode);
} }
const CAirlineIcaoCode &CSimulatedAircraft::getAirlineIcaoCode() const const CAirlineIcaoCode &CSimulatedAircraft::getAirlineIcaoCode() const
{ {
return this->m_models[CurrentModel].getAirlineIcaoCode(); return m_models[CurrentModel].getAirlineIcaoCode();
} }
const QString &CSimulatedAircraft::getAirlineIcaoCodeDesignator() const const QString &CSimulatedAircraft::getAirlineIcaoCodeDesignator() const
@@ -150,7 +150,7 @@ namespace BlackMisc
void CSimulatedAircraft::setAircraftIcaoDesignator(const QString &designator) void CSimulatedAircraft::setAircraftIcaoDesignator(const QString &designator)
{ {
this->m_models[CurrentModel].setAircraftIcaoDesignator(designator); m_models[CurrentModel].setAircraftIcaoDesignator(designator);
} }
bool CSimulatedAircraft::hasAircraftDesignator() const bool CSimulatedAircraft::hasAircraftDesignator() const
@@ -194,14 +194,14 @@ namespace BlackMisc
bool CSimulatedAircraft::setCom1ActiveFrequency(const CFrequency &frequency) bool CSimulatedAircraft::setCom1ActiveFrequency(const CFrequency &frequency)
{ {
if (!CComSystem::isValidComFrequency(frequency)) { return false; } if (!CComSystem::isValidComFrequency(frequency)) { return false; }
this->m_com1system.setFrequencyActive(frequency); m_com1system.setFrequencyActive(frequency);
return true; return true;
} }
bool CSimulatedAircraft::setCom2ActiveFrequency(const CFrequency &frequency) bool CSimulatedAircraft::setCom2ActiveFrequency(const CFrequency &frequency)
{ {
if (!CComSystem::isValidComFrequency(frequency)) { return false; } if (!CComSystem::isValidComFrequency(frequency)) { return false; }
this->m_com2system.setFrequencyActive(frequency); m_com2system.setFrequencyActive(frequency);
return true; return true;
} }
@@ -297,50 +297,28 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexModel: case IndexModel: return this->getModel().propertyByIndex(index.copyFrontRemoved());
return this->getModel().propertyByIndex(index.copyFrontRemoved()); case IndexNetworkModel: return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
case IndexNetworkModel: case IndexNetworkModelAircraftIcaoDifference: return this->getNetworkModelAircraftIcaoDifference();
return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved()); case IndexNetworkModelAirlineIcaoDifference: return this->getNetworkModelAirlineIcaoDifference();
case IndexNetworkModelAircraftIcaoDifference: case IndexNetworkModelLiveryDifference: return this->getNetworkModelLiveryDifference();
return this->getNetworkModelAircraftIcaoDifference(); case IndexEnabled: return CVariant::fromValue(this->isEnabled());
case IndexNetworkModelAirlineIcaoDifference: case IndexRendered: return CVariant::fromValue(this->isRendered());
return this->getNetworkModelAirlineIcaoDifference(); case IndexPartsSynchronized: return CVariant::fromValue(this->isPartsSynchronized());
case IndexNetworkModelLiveryDifference: case IndexFastPositionUpdates: return CVariant::fromValue(this->fastPositionUpdates());
return this->getNetworkModelLiveryDifference(); case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
case IndexEnabled: case IndexPilot: return m_pilot.propertyByIndex(index.copyFrontRemoved());
return CVariant::fromValue(this->isEnabled()); case IndexRelativeDistance: return m_relativeDistance.propertyByIndex(index.copyFrontRemoved());
case IndexRendered: case IndexCom1System: return m_com1system.propertyByIndex(index.copyFrontRemoved());
return CVariant::fromValue(this->isRendered()); case IndexCom2System: return m_com2system.propertyByIndex(index.copyFrontRemoved());
case IndexPartsSynchronized: case IndexTransponder: return m_transponder.propertyByIndex(index.copyFrontRemoved());
return CVariant::fromValue(this->isPartsSynchronized()); case IndexSituation: return m_situation.propertyByIndex(index.copyFrontRemoved());
case IndexFastPositionUpdates: case IndexAircraftIcaoCode: return this->getAircraftIcaoCode().propertyByIndex(index.copyFrontRemoved());
return CVariant::fromValue(this->fastPositionUpdates()); case IndexLivery: return this->getLivery().propertyByIndex(index.copyFrontRemoved());
case IndexCallsign: case IndexParts: return m_parts.propertyByIndex(index.copyFrontRemoved());
return this->m_callsign.propertyByIndex(index.copyFrontRemoved()); case IndexIsVtol: return CVariant::fromValue(this->isVtol());
case IndexPilot: case IndexCombinedIcaoLiveryString: return CVariant::fromValue(this->getCombinedIcaoLiveryString(false));
return this->m_pilot.propertyByIndex(index.copyFrontRemoved()); case IndexCombinedIcaoLiveryStringNetworkModel: return CVariant::fromValue(this->getCombinedIcaoLiveryString(true));
case IndexRelativeDistance:
return this->m_relativeDistance.propertyByIndex(index.copyFrontRemoved());
case IndexCom1System:
return this->m_com1system.propertyByIndex(index.copyFrontRemoved());
case IndexCom2System:
return this->m_com2system.propertyByIndex(index.copyFrontRemoved());
case IndexTransponder:
return this->m_transponder.propertyByIndex(index.copyFrontRemoved());
case IndexSituation:
return this->m_situation.propertyByIndex(index.copyFrontRemoved());
case IndexAircraftIcaoCode:
return this->getAircraftIcaoCode().propertyByIndex(index.copyFrontRemoved());
case IndexLivery:
return this->getLivery().propertyByIndex(index.copyFrontRemoved());
case IndexParts:
return this->m_parts.propertyByIndex(index.copyFrontRemoved());
case IndexIsVtol:
return CVariant::fromValue(this->isVtol());
case IndexCombinedIcaoLiveryString:
return CVariant::fromValue(this->getCombinedIcaoLiveryString(false));
case IndexCombinedIcaoLiveryStringNetworkModel:
return CVariant::fromValue(this->getCombinedIcaoLiveryString(true));
default: default:
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ? return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
ICoordinateWithRelativePosition::propertyByIndex(index) : ICoordinateWithRelativePosition::propertyByIndex(index) :
@@ -351,54 +329,26 @@ namespace BlackMisc
void CSimulatedAircraft::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) void CSimulatedAircraft::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{ {
if (index.isMyself()) { (*this) = variant.to<CSimulatedAircraft>(); return; } if (index.isMyself()) { (*this) = variant.to<CSimulatedAircraft>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCallsign: case IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexPilot: m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
break; case IndexRelativeDistance: m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexPilot: case IndexCom1System: m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
this->m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexCom2System: m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
break; case IndexTransponder: m_transponder.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexRelativeDistance: case IndexSituation: m_situation.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
this->m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexParts: m_parts.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
break; case IndexNetworkModel: m_models[NetworkModel].setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexCom1System: case IndexEnabled: m_enabled = variant.toBool(); break;
this->m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexRendered: m_rendered = variant.toBool(); break;
break; case IndexPartsSynchronized: m_partsSynchronized = variant.toBool(); break;
case IndexCom2System: case IndexFastPositionUpdates: m_fastPositionUpdates = variant.toBool(); break;
this->m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant); case IndexLivery: Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported"); break;
break;
case IndexTransponder:
this->m_transponder.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexSituation:
this->m_situation.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexParts:
this->m_parts.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexModel: case IndexModel:
this->m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant); m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
this->setModel(this->m_models[CurrentModel]); // sync some values such as callsign this->setModel(m_models[CurrentModel]); // sync some values such as callsign
break;
case IndexNetworkModel:
this->m_models[NetworkModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexEnabled:
this->m_enabled = variant.toBool();
break;
case IndexRendered:
this->m_rendered = variant.toBool();
break;
case IndexPartsSynchronized:
this->m_partsSynchronized = variant.toBool();
break;
case IndexFastPositionUpdates:
this->m_fastPositionUpdates = variant.toBool();
break;
case IndexLivery:
Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported");
break; break;
default: default:
if (ICoordinateWithRelativePosition::canHandleIndex(index)) if (ICoordinateWithRelativePosition::canHandleIndex(index))
@@ -415,48 +365,29 @@ namespace BlackMisc
int CSimulatedAircraft::comparePropertyByIndex(const CPropertyIndex &index, const CSimulatedAircraft &compareValue) const int CSimulatedAircraft::comparePropertyByIndex(const CPropertyIndex &index, const CSimulatedAircraft &compareValue) const
{ {
if (index.isMyself()) { return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); } if (index.isMyself()) { return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCallsign: case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); case IndexPilot: return m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot());
case IndexPilot: case IndexSituation: return m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation());
return this->m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot()); case IndexRelativeDistance: return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
case IndexSituation: case IndexCom1System: return m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System());
return this->m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation()); case IndexCom2System: return m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System());
case IndexRelativeDistance: case IndexTransponder: return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode());
return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance()); case IndexLivery: return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
case IndexCom1System: case IndexParts: return m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
return this->m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System()); case IndexModel: return m_models[CurrentModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
case IndexCom2System: case IndexNetworkModel: return m_models[NetworkModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
return this->m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System()); case IndexNetworkModelAircraftIcaoDifference: return this->getNetworkModelAircraftIcaoDifference().compare(compareValue.getNetworkModelAircraftIcaoDifference());
case IndexTransponder: case IndexNetworkModelAirlineIcaoDifference: return this->getNetworkModelAirlineIcaoDifference().compare(compareValue.getNetworkModelAirlineIcaoDifference());
return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode()); case IndexNetworkModelLiveryDifference: return this->getNetworkModelLiveryDifference().compare(compareValue.getNetworkModelLiveryDifference());
case IndexLivery: case IndexRendered: return Compare::compare(m_rendered, compareValue.isRendered());
return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery()); case IndexPartsSynchronized: return Compare::compare(m_partsSynchronized, compareValue.isPartsSynchronized());
case IndexParts: case IndexFastPositionUpdates: return Compare::compare(m_fastPositionUpdates, compareValue.fastPositionUpdates());
return this->m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts()); case IndexCombinedIcaoLiveryString: return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false));
case IndexModel: case IndexCombinedIcaoLiveryStringNetworkModel: return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true));
return m_models[CurrentModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
case IndexNetworkModel:
return m_models[NetworkModel].comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
case IndexNetworkModelAircraftIcaoDifference:
return this->getNetworkModelAircraftIcaoDifference().compare(compareValue.getNetworkModelAircraftIcaoDifference());
case IndexNetworkModelAirlineIcaoDifference:
return this->getNetworkModelAirlineIcaoDifference().compare(compareValue.getNetworkModelAirlineIcaoDifference());
case IndexNetworkModelLiveryDifference:
return this->getNetworkModelLiveryDifference().compare(compareValue.getNetworkModelLiveryDifference());
case IndexRendered:
return Compare::compare(this->m_rendered, compareValue.isRendered());
case IndexPartsSynchronized:
return Compare::compare(this->m_partsSynchronized, compareValue.isPartsSynchronized());
case IndexFastPositionUpdates:
return Compare::compare(this->m_fastPositionUpdates, compareValue.fastPositionUpdates());
case IndexCombinedIcaoLiveryString:
return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false));
case IndexCombinedIcaoLiveryStringNetworkModel:
return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true));
default: default:
if (ICoordinateWithRelativePosition::canHandleIndex(index)) if (ICoordinateWithRelativePosition::canHandleIndex(index))
{ {
@@ -471,13 +402,13 @@ namespace BlackMisc
const CAircraftModel &CSimulatedAircraft::getNetworkModelOrModel() const const CAircraftModel &CSimulatedAircraft::getNetworkModelOrModel() const
{ {
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
return this->hasNetworkModel() ? this->m_models[NetworkModel] : this->m_models[CurrentModel]; return this->hasNetworkModel() ? m_models[NetworkModel] : m_models[CurrentModel];
} }
bool CSimulatedAircraft::hasNetworkModel() const bool CSimulatedAircraft::hasNetworkModel() const
{ {
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
return this->m_models[NetworkModel].hasModelString() || !this->m_models[NetworkModel].getCallsign().isEmpty(); return m_models[NetworkModel].hasModelString() || !m_models[NetworkModel].getCallsign().isEmpty();
} }
QString CSimulatedAircraft::getNetworkModelAircraftIcaoDifference() const QString CSimulatedAircraft::getNetworkModelAircraftIcaoDifference() const
@@ -514,7 +445,7 @@ namespace BlackMisc
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
// sync the callsigns // sync the callsigns
this->m_models[CurrentModel] = model; m_models[CurrentModel] = model;
this->setCallsign(this->hasValidCallsign() ? this->getCallsign() : model.getCallsign()); this->setCallsign(this->hasValidCallsign() ? this->getCallsign() : model.getCallsign());
this->setIcaoCodes(model.getAircraftIcaoCode(), model.getAirlineIcaoCode()); this->setIcaoCodes(model.getAircraftIcaoCode(), model.getAirlineIcaoCode());
} }
@@ -522,44 +453,44 @@ namespace BlackMisc
void CSimulatedAircraft::setNetworkModel(const CAircraftModel &model) void CSimulatedAircraft::setNetworkModel(const CAircraftModel &model)
{ {
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
this->m_models[NetworkModel] = model; m_models[NetworkModel] = model;
} }
void CSimulatedAircraft::setModelString(const QString &modelString) void CSimulatedAircraft::setModelString(const QString &modelString)
{ {
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
this->m_models[CurrentModel].setModelString(modelString); m_models[CurrentModel].setModelString(modelString);
} }
void CSimulatedAircraft::setCallsign(const CCallsign &callsign) void CSimulatedAircraft::setCallsign(const CCallsign &callsign)
{ {
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size"); Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
this->m_callsign = callsign; m_callsign = callsign;
this->m_models[CurrentModel].setCallsign(callsign); m_models[CurrentModel].setCallsign(callsign);
this->m_models[NetworkModel].setCallsign(callsign); m_models[NetworkModel].setCallsign(callsign);
this->m_pilot.setCallsign(callsign); m_pilot.setCallsign(callsign);
} }
bool CSimulatedAircraft::isActiveFrequencyWithin8_33kHzChannel(const CFrequency &comFrequency) const bool CSimulatedAircraft::isActiveFrequencyWithin8_33kHzChannel(const CFrequency &comFrequency) const
{ {
return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) || return m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency); m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
} }
bool CSimulatedAircraft::isActiveFrequencyWithin25kHzChannel(const CFrequency &comFrequency) const bool CSimulatedAircraft::isActiveFrequencyWithin25kHzChannel(const CFrequency &comFrequency) const
{ {
return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) || return m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency); m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
} }
QString CSimulatedAircraft::convertToQString(bool i18n) const QString CSimulatedAircraft::convertToQString(bool i18n) const
{ {
const QString s = this->m_callsign.toQString(i18n) % const QString s = m_callsign.toQString(i18n) %
QLatin1Char(' ') % this->m_pilot.toQString(i18n) % QLatin1Char(' ') % m_pilot.toQString(i18n) %
QLatin1Char(' ') % this->m_situation.toQString(i18n) % QLatin1Char(' ') % m_situation.toQString(i18n) %
QLatin1Char(' ') % this->m_com1system.toQString(i18n) % QLatin1Char(' ') % m_com1system.toQString(i18n) %
QLatin1Char(' ') % this->m_com2system.toQString(i18n) % QLatin1Char(' ') % m_com2system.toQString(i18n) %
QLatin1Char(' ') % this->m_transponder.toQString(i18n) % QLatin1Char(' ') % m_transponder.toQString(i18n) %
QLatin1String(" enabled: ") % BlackMisc::boolToYesNo(this->isEnabled()) % QLatin1String(" enabled: ") % BlackMisc::boolToYesNo(this->isEnabled()) %
QLatin1String(" rendered: ") % BlackMisc::boolToYesNo(this->isRendered()) % QLatin1String(" rendered: ") % BlackMisc::boolToYesNo(this->isRendered()) %
QLatin1Char(' ') % this->getModel().toQString(i18n); QLatin1Char(' ') % this->getModel().toQString(i18n);

View File

@@ -153,16 +153,16 @@ namespace BlackMisc
void setAircraftIcaoDesignator(const QString &designator); void setAircraftIcaoDesignator(const QString &designator);
//! Has valid realname? //! Has valid realname?
bool hasValidRealName() const { return this->m_pilot.hasValidRealName(); } bool hasValidRealName() const { return m_pilot.hasValidRealName(); }
//! Has valid id? //! Has valid id?
bool hasValidId() const { return this->m_pilot.hasValidId(); } bool hasValidId() const { return m_pilot.hasValidId(); }
//! Valid designator? //! Valid designator?
bool hasAircraftDesignator() const; bool hasAircraftDesignator() const;
//! Valid airline designator //! Valid airline designator
bool hasAirlineDesignator() const { return this->m_models[CurrentModel].getLivery().hasValidAirlineDesignator(); } bool hasAirlineDesignator() const { return m_models[CurrentModel].getLivery().hasValidAirlineDesignator(); }
//! Valid designators? //! Valid designators?
bool hasAircraftAndAirlineDesignator() const; bool hasAircraftAndAirlineDesignator() const;
@@ -174,55 +174,55 @@ namespace BlackMisc
bool hasCallsign() const { return !getCallsign().isEmpty(); } bool hasCallsign() const { return !getCallsign().isEmpty(); }
//! Get position //! Get position
BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return this->m_situation.getPosition(); } BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return m_situation.getPosition(); }
//! Set position //! Set position
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_situation.setPosition(position); } void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { m_situation.setPosition(position); }
//! Get altitude //! Get altitude
const BlackMisc::Aviation::CAltitude &getAltitude() const { return this->m_situation.getAltitude(); } const BlackMisc::Aviation::CAltitude &getAltitude() const { return m_situation.getAltitude(); }
//! Set altitude //! Set altitude
void setAltitude(const BlackMisc::Aviation::CAltitude &altitude) { this->m_situation.setAltitude(altitude); } void setAltitude(const BlackMisc::Aviation::CAltitude &altitude) { m_situation.setAltitude(altitude); }
//! Get groundspeed //! Get groundspeed
const BlackMisc::PhysicalQuantities::CSpeed &getGroundSpeed() const { return this->m_situation.getGroundSpeed(); } const BlackMisc::PhysicalQuantities::CSpeed &getGroundSpeed() const { return m_situation.getGroundSpeed(); }
//! \copydoc BlackMisc::Geo::ICoordinateGeodetic::latitude //! \copydoc BlackMisc::Geo::ICoordinateGeodetic::latitude
virtual BlackMisc::Geo::CLatitude latitude() const override { return this->m_situation.latitude(); } virtual BlackMisc::Geo::CLatitude latitude() const override { return m_situation.latitude(); }
//! \copydoc BlackMisc::Geo::ICoordinateGeodetic::longitude //! \copydoc BlackMisc::Geo::ICoordinateGeodetic::longitude
virtual BlackMisc::Geo::CLongitude longitude() const override { return this->m_situation.longitude(); } virtual BlackMisc::Geo::CLongitude longitude() const override { return m_situation.longitude(); }
//! \copydoc BlackMisc::Geo::ICoordinateGeodetic::geodeticHeight //! \copydoc BlackMisc::Geo::ICoordinateGeodetic::geodeticHeight
const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return this->m_situation.geodeticHeight(); } const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return m_situation.geodeticHeight(); }
//! \copydoc BlackMisc::Geo::ICoordinateGeodetic::normalVector //! \copydoc BlackMisc::Geo::ICoordinateGeodetic::normalVector
virtual QVector3D normalVector() const override { return this->m_situation.normalVector(); } virtual QVector3D normalVector() const override { return m_situation.normalVector(); }
//! \copydoc BlackMisc::Geo::ICoordinateGeodetic::normalVectorDouble //! \copydoc BlackMisc::Geo::ICoordinateGeodetic::normalVectorDouble
virtual std::array<double, 3> normalVectorDouble() const override { return this->m_situation.normalVectorDouble(); } virtual std::array<double, 3> normalVectorDouble() const override { return m_situation.normalVectorDouble(); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::getGroundElevation //! \copydoc BlackMisc::Aviation::CAircraftSituation::getGroundElevation
const BlackMisc::Aviation::CAltitude &getGroundElevation() const { return this->m_situation.getGroundElevation(); } const BlackMisc::Aviation::CAltitude &getGroundElevation() const { return m_situation.getGroundElevation(); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation //! \copydoc BlackMisc::Aviation::CAircraftSituation::setGroundElevation
void setGroundElevation(const BlackMisc::Aviation::CAltitude &elevation) { this->m_situation.setGroundElevation(elevation); } void setGroundElevation(const BlackMisc::Aviation::CAltitude &elevation) { m_situation.setGroundElevation(elevation); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::getHeading //! \copydoc BlackMisc::Aviation::CAircraftSituation::getHeading
const BlackMisc::Aviation::CHeading &getHeading() const { return this->m_situation.getHeading(); } const BlackMisc::Aviation::CHeading &getHeading() const { return m_situation.getHeading(); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::getPitch //! \copydoc BlackMisc::Aviation::CAircraftSituation::getPitch
const BlackMisc::PhysicalQuantities::CAngle &getPitch() const { return this->m_situation.getPitch(); } const BlackMisc::PhysicalQuantities::CAngle &getPitch() const { return m_situation.getPitch(); }
//! \copydoc BlackMisc::Aviation::CAircraftSituation::getBank //! \copydoc BlackMisc::Aviation::CAircraftSituation::getBank
const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return this->m_situation.getBank(); } const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return m_situation.getBank(); }
//! Get COM1 system //! Get COM1 system
const BlackMisc::Aviation::CComSystem &getCom1System() const { return this->m_com1system; } const BlackMisc::Aviation::CComSystem &getCom1System() const { return m_com1system; }
//! Get COM2 system //! Get COM2 system
const BlackMisc::Aviation::CComSystem &getCom2System() const { return this->m_com2system; } const BlackMisc::Aviation::CComSystem &getCom2System() const { return m_com2system; }
//! Get COM unit //! Get COM unit
const BlackMisc::Aviation::CComSystem getComSystem(BlackMisc::Aviation::CComSystem::ComUnit unit) const; const BlackMisc::Aviation::CComSystem getComSystem(BlackMisc::Aviation::CComSystem::ComUnit unit) const;
@@ -231,10 +231,10 @@ namespace BlackMisc
void setComSystem(const BlackMisc::Aviation::CComSystem &com, BlackMisc::Aviation::CComSystem::ComUnit unit); void setComSystem(const BlackMisc::Aviation::CComSystem &com, BlackMisc::Aviation::CComSystem::ComUnit unit);
//! Set COM1 system //! Set COM1 system
void setCom1System(const BlackMisc::Aviation::CComSystem &comSystem) { this->m_com1system = comSystem; } void setCom1System(const BlackMisc::Aviation::CComSystem &comSystem) { m_com1system = comSystem; }
//! Set COM2 system //! Set COM2 system
void setCom2System(const BlackMisc::Aviation::CComSystem &comSystem) { this->m_com2system = comSystem; } void setCom2System(const BlackMisc::Aviation::CComSystem &comSystem) { m_com2system = comSystem; }
//! Set COM1 frequency //! Set COM1 frequency
bool setCom1ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency); bool setCom1ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
@@ -246,10 +246,10 @@ namespace BlackMisc
bool setComActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit); bool setComActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
//! Given SELCAL selected? //! Given SELCAL selected?
bool isSelcalSelected(const BlackMisc::Aviation::CSelcal &selcal) const { return this->m_selcal == selcal; } bool isSelcalSelected(const BlackMisc::Aviation::CSelcal &selcal) const { return m_selcal == selcal; }
//! Valid SELCAL? //! Valid SELCAL?
bool hasValidSelcal() const { return this->m_selcal.isValid(); } bool hasValidSelcal() const { return m_selcal.isValid(); }
//! SELCAL //! SELCAL
const BlackMisc::Aviation::CSelcal getSelcal() const { return m_selcal; } const BlackMisc::Aviation::CSelcal getSelcal() const { return m_selcal; }
@@ -264,7 +264,7 @@ namespace BlackMisc
void setCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, int transponderCode, BlackMisc::Aviation::CTransponder::TransponderMode mode); void setCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, int transponderCode, BlackMisc::Aviation::CTransponder::TransponderMode mode);
//! Own SELCAL code //! Own SELCAL code
void setSelcal(const BlackMisc::Aviation::CSelcal &selcal) { this->m_selcal = selcal; } void setSelcal(const BlackMisc::Aviation::CSelcal &selcal) { m_selcal = selcal; }
//! Changed cockpit data? //! Changed cockpit data?
bool hasChangedCockpitData(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) const; bool hasChangedCockpitData(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder) const;
@@ -279,25 +279,25 @@ namespace BlackMisc
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const; bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const;
//! Get transponder //! Get transponder
const BlackMisc::Aviation::CTransponder &getTransponder() const { return this->m_transponder; } const BlackMisc::Aviation::CTransponder &getTransponder() const { return m_transponder; }
//! Set transponder //! Set transponder
void setTransponder(const BlackMisc::Aviation::CTransponder &transponder) { this->m_transponder = transponder; } void setTransponder(const BlackMisc::Aviation::CTransponder &transponder) { m_transponder = transponder; }
//! Set transponder mode //! Set transponder mode
void setTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode) { this->m_transponder.setTransponderMode(mode); } void setTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode) { m_transponder.setTransponderMode(mode); }
//! Set transponder code //! Set transponder code
void setTransponderCode(int code) { this->m_transponder.setTransponderCode(code); } void setTransponderCode(int code) { m_transponder.setTransponderCode(code); }
//! Get transponder code //! Get transponder code
QString getTransponderCodeFormatted() const { return this->m_transponder.getTransponderCodeFormatted(); } QString getTransponderCodeFormatted() const { return m_transponder.getTransponderCodeFormatted(); }
//! Get transponder code //! Get transponder code
qint32 getTransponderCode() const { return this->m_transponder.getTransponderCode(); } qint32 getTransponderCode() const { return m_transponder.getTransponderCode(); }
//! Get transponder mode //! Get transponder mode
BlackMisc::Aviation::CTransponder::TransponderMode getTransponderMode() const { return this->m_transponder.getTransponderMode(); } BlackMisc::Aviation::CTransponder::TransponderMode getTransponderMode() const { return m_transponder.getTransponderMode(); }
//! Is valid for login? //! Is valid for login?
bool isValidForLogin() const; bool isValidForLogin() const;
@@ -414,7 +414,7 @@ namespace BlackMisc
QString convertToQString(bool i18n = false) const; QString convertToQString(bool i18n = false) const;
//! \copydoc BlackMisc::Mixin::Icon::toIcon() //! \copydoc BlackMisc::Mixin::Icon::toIcon()
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); } BlackMisc::CIcon toIcon() const { return m_callsign.toIcon(); }
private: private:
static constexpr int CurrentModel = 0; //!< m_models static constexpr int CurrentModel = 0; //!< m_models