mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
Ref T129, formatted aircraftmodel and simulated aircraft
This commit is contained in:
committed by
Mathew Sutcliffe
parent
9b51ec251c
commit
ba8d0c1f64
@@ -58,11 +58,11 @@ namespace BlackMisc
|
||||
QString CAircraftModel::convertToQString(bool i18n) const
|
||||
{
|
||||
const QString s =
|
||||
this->m_modelString %
|
||||
m_modelString %
|
||||
QLatin1String(" type: '") % this->getModelTypeAsString() %
|
||||
QLatin1String("' ICAO: '") % this->getAircraftIcaoCode().toQString(i18n) %
|
||||
QLatin1String("' {") % this->m_livery.toQString(i18n) %
|
||||
QLatin1String("} file: '") % this->m_fileName % QLatin1String("'");
|
||||
QLatin1String("' {") % m_livery.toQString(i18n) %
|
||||
QLatin1String("} file: '") % m_fileName % QLatin1String("'");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace BlackMisc
|
||||
// filename not in DB
|
||||
obj.insert("id", this->getDbKeyAsJsonValue());
|
||||
obj.insert("name", this->getName());
|
||||
obj.insert("modelstring", QJsonValue(this->m_modelString));
|
||||
obj.insert("description", QJsonValue(this->m_description));
|
||||
obj.insert("modelstring", QJsonValue(m_modelString));
|
||||
obj.insert("description", QJsonValue(m_description));
|
||||
obj.insert("mode", QJsonValue(getModelModeAsString().left(1).toUpper())); // clazy:exclude=qstring-left
|
||||
|
||||
// sims
|
||||
@@ -144,8 +144,8 @@ namespace BlackMisc
|
||||
|
||||
void CAircraftModel::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
this->m_callsign = callsign;
|
||||
this->m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
m_callsign = callsign;
|
||||
m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
}
|
||||
|
||||
QString CAircraftModel::getModelStringAndDbKey() const
|
||||
@@ -176,48 +176,27 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
return CVariant(this->m_modelString);
|
||||
case IndexHasQueriedModelString:
|
||||
return CVariant::fromValue(this->hasQueriedModelString());
|
||||
case IndexModelType:
|
||||
return CVariant::fromValue(this->m_modelType);
|
||||
case IndexModelTypeAsString:
|
||||
return CVariant(this->getModelTypeAsString());
|
||||
case IndexModelMode:
|
||||
return CVariant::fromValue(this->m_modelMode);
|
||||
case IndexModelModeAsString:
|
||||
return CVariant::fromValue(this->getModelModeAsString());
|
||||
case IndexModelModeAsIcon:
|
||||
return CVariant::fromValue(this->getModelModeAsIcon());
|
||||
case IndexDistributor:
|
||||
return m_distributor.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSimulatorInfo:
|
||||
return m_simulator.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSimulatorInfoAsString:
|
||||
return CVariant(m_simulator.toQString());
|
||||
case IndexDescription:
|
||||
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);
|
||||
case IndexModelString: return CVariant(m_modelString);
|
||||
case IndexHasQueriedModelString: return CVariant::fromValue(this->hasQueriedModelString());
|
||||
case IndexModelType: return CVariant::fromValue(m_modelType);
|
||||
case IndexModelTypeAsString: return CVariant(this->getModelTypeAsString());
|
||||
case IndexModelMode: return CVariant::fromValue(m_modelMode);
|
||||
case IndexModelModeAsString: return CVariant::fromValue(this->getModelModeAsString());
|
||||
case IndexModelModeAsIcon: return CVariant::fromValue(this->getModelModeAsIcon());
|
||||
case IndexDistributor: return m_distributor.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSimulatorInfo: return m_simulator.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSimulatorInfoAsString: return CVariant(m_simulator.toQString());
|
||||
case IndexDescription: return CVariant(m_description);
|
||||
case IndexName: return CVariant(m_name);
|
||||
case IndexFileName: return CVariant(m_fileName);
|
||||
case IndexFileTimestamp: return CVariant::fromValue(this->getFileTimestamp());
|
||||
case IndexFileTimestampFormattedYmdhms: return CVariant::fromValue(this->getFormattedFileTimestampYmdhms());
|
||||
case IndexIconPath: return CVariant(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 this->getMembersDbStatus();
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,33 +209,19 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
this->m_modelString = variant.toQString();
|
||||
break;
|
||||
case IndexAircraftIcaoCode:
|
||||
this->m_aircraftIcao.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexLivery:
|
||||
this->m_livery.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexDistributor:
|
||||
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 IndexModelString: m_modelString = variant.toQString(); break;
|
||||
case IndexAircraftIcaoCode: m_aircraftIcao.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexLivery: m_livery.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexDistributor: m_distributor.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexDescription: m_description = variant.toQString(); break;
|
||||
case IndexSimulatorInfo: m_simulator.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexName: m_name = variant.toQString(); break;
|
||||
case IndexIconPath: m_iconPath = variant.toQString(); break;
|
||||
case IndexModelType: m_modelType = variant.value<ModelType>(); break;
|
||||
case IndexFileName: m_fileName = variant.toQString(); break;
|
||||
case IndexCallsign:
|
||||
this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
this->m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
break;
|
||||
case IndexFileName:
|
||||
this->m_fileName = variant.toQString();
|
||||
m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
break;
|
||||
case IndexFileTimestamp:
|
||||
if (variant.canConvert<QDateTime>())
|
||||
@@ -265,15 +230,9 @@ namespace BlackMisc
|
||||
}
|
||||
else if (variant.canConvert<qint64>())
|
||||
{
|
||||
this->m_fileTimestamp = variant.value<qint64>();
|
||||
m_fileTimestamp = variant.value<qint64>();
|
||||
}
|
||||
break;
|
||||
case IndexIconPath:
|
||||
this->m_iconPath = variant.toQString();
|
||||
break;
|
||||
case IndexModelType:
|
||||
this->m_modelType = variant.value<ModelType>();
|
||||
break;
|
||||
case IndexModelMode:
|
||||
if (variant.type() == QMetaType::QString)
|
||||
{
|
||||
@@ -281,12 +240,10 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_modelMode = variant.value<ModelMode>();
|
||||
m_modelMode = variant.value<ModelMode>();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,44 +251,29 @@ namespace BlackMisc
|
||||
{
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
|
||||
if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue);}
|
||||
if (index.isMyself()) { return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
if (index.isMyself()) { return m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive);
|
||||
case IndexAircraftIcaoCode:
|
||||
return this->m_aircraftIcao.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAircraftIcaoCode());
|
||||
case IndexLivery:
|
||||
return this->m_livery.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
|
||||
case IndexDistributor:
|
||||
return this->m_distributor.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getDistributor());
|
||||
case IndexDescription:
|
||||
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexModelString: return m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive);
|
||||
case IndexAircraftIcaoCode: return m_aircraftIcao.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAircraftIcaoCode());
|
||||
case IndexLivery: return m_livery.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
|
||||
case IndexDistributor: return m_distributor.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getDistributor());
|
||||
case IndexDescription: return m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexFileName: return m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
|
||||
case IndexIconPath: return m_iconPath.compare(compareValue.getIconPath(), Qt::CaseInsensitive);
|
||||
case IndexModelType: return Compare::compare(m_modelType, compareValue.getModelType());
|
||||
case IndexSimulatorInfoAsString:
|
||||
case IndexSimulatorInfo:
|
||||
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 IndexSimulatorInfo: return m_simulator.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSimulator());
|
||||
case IndexFileTimestamp:
|
||||
case IndexFileTimestampFormattedYmdhms:
|
||||
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 IndexFileTimestampFormattedYmdhms: return Compare::compare(m_fileTimestamp, compareValue.m_fileTimestamp);
|
||||
case IndexModelMode:
|
||||
case IndexModelModeAsString:
|
||||
case IndexModelModeAsIcon:
|
||||
return Compare::compare(this->m_modelMode, compareValue.getModelMode());
|
||||
case IndexMembersDbStatus:
|
||||
return getMembersDbStatus().compare(compareValue.getMembersDbStatus());
|
||||
default:
|
||||
break;
|
||||
case IndexModelModeAsIcon: return Compare::compare(m_modelMode, compareValue.getModelMode());
|
||||
case IndexMembersDbStatus: return getMembersDbStatus().compare(compareValue.getMembersDbStatus());
|
||||
default: break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
@@ -339,14 +281,14 @@ namespace BlackMisc
|
||||
|
||||
bool CAircraftModel::setAircraftIcaoCode(const CAircraftIcaoCode &aircraftIcaoCode)
|
||||
{
|
||||
if (this->m_aircraftIcao == aircraftIcaoCode) { return false; }
|
||||
this->m_aircraftIcao = aircraftIcaoCode;
|
||||
if (m_aircraftIcao == aircraftIcaoCode) { return false; }
|
||||
m_aircraftIcao = aircraftIcaoCode;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAircraftModel::setAircraftIcaoDesignator(const QString &designator)
|
||||
{
|
||||
this->m_aircraftIcao.setDesignator(designator);
|
||||
m_aircraftIcao.setDesignator(designator);
|
||||
}
|
||||
|
||||
void CAircraftModel::setAircraftIcaoCodes(const CAircraftIcaoCode &aircraftIcaoCode, const CAirlineIcaoCode &airlineIcaoCode)
|
||||
@@ -357,22 +299,22 @@ namespace BlackMisc
|
||||
|
||||
bool CAircraftModel::hasValidAircraftAndAirlineDesignator() const
|
||||
{
|
||||
return this->hasKnownAircraftDesignator() && this->m_livery.hasValidAirlineDesignator();
|
||||
return this->hasKnownAircraftDesignator() && m_livery.hasValidAirlineDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasAircraftDesignator() const
|
||||
{
|
||||
return this->m_aircraftIcao.hasDesignator();
|
||||
return m_aircraftIcao.hasDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasKnownAircraftDesignator() const
|
||||
{
|
||||
return this->m_aircraftIcao.hasKnownDesignator();
|
||||
return m_aircraftIcao.hasKnownDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasAirlineDesignator() const
|
||||
{
|
||||
return this->m_livery.hasValidAirlineDesignator();
|
||||
return m_livery.hasValidAirlineDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasAircraftAndAirlineDesignator() const
|
||||
@@ -389,8 +331,8 @@ namespace BlackMisc
|
||||
bool CAircraftModel::setDistributorOrder(int order)
|
||||
{
|
||||
if (order < 0) { return false; }
|
||||
if (!this->m_distributor.isLoadedFromDb()) { return false; }
|
||||
this->m_distributor.setOrder(order);
|
||||
if (!m_distributor.isLoadedFromDb()) { return false; }
|
||||
m_distributor.setOrder(order);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,64 +343,61 @@ namespace BlackMisc
|
||||
const int noDistributorOrder = distributors.size();
|
||||
if (this->hasDbDistributor())
|
||||
{
|
||||
const CDistributor d = distributors.findByKeyOrAlias(this->m_distributor.getDbKey());
|
||||
const CDistributor d = distributors.findByKeyOrAlias(m_distributor.getDbKey());
|
||||
if (d.hasValidDbKey())
|
||||
{
|
||||
this->m_distributor.setOrder(d.getOrder());
|
||||
m_distributor.setOrder(d.getOrder());
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_distributor.setOrder(noDistributorOrder);
|
||||
m_distributor.setOrder(noDistributorOrder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_distributor.setOrder(noDistributorOrder);
|
||||
m_distributor.setOrder(noDistributorOrder);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasDbDistributor() const
|
||||
{
|
||||
return this->m_distributor.isLoadedFromDb();
|
||||
return m_distributor.isLoadedFromDb();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (!distributor.isLoadedFromDb()) { 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
|
||||
{
|
||||
if (distributors.isEmpty()) { 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
|
||||
{
|
||||
if (mode == All) { return true; }
|
||||
return (mode & this->m_modelMode) > 0;
|
||||
return (mode & m_modelMode) > 0;
|
||||
}
|
||||
|
||||
const CIcon &CAircraftModel::getModelModeAsIcon() const
|
||||
{
|
||||
switch (this->getModelMode())
|
||||
{
|
||||
case Include:
|
||||
return CIcon::iconByIndex(CIcons::ModelInclude);
|
||||
case Exclude:
|
||||
return CIcon::iconByIndex(CIcons::ModelExclude);
|
||||
case Undefined:
|
||||
return CIcon::iconByIndex(CIcons::StandardIconUnknown16);
|
||||
case Include: return CIcon::iconByIndex(CIcons::ModelInclude);
|
||||
case Exclude: return CIcon::iconByIndex(CIcons::ModelExclude);
|
||||
case Undefined: return CIcon::iconByIndex(CIcons::StandardIconUnknown16);
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong mode");
|
||||
break;
|
||||
@@ -483,7 +422,7 @@ namespace BlackMisc
|
||||
|
||||
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
|
||||
@@ -495,26 +434,26 @@ namespace BlackMisc
|
||||
|
||||
bool CAircraftModel::hasValidFileTimestamp() const
|
||||
{
|
||||
return this->m_fileTimestamp >= 0;
|
||||
return m_fileTimestamp >= 0;
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileTimestamp(const QDateTime ×tampUtc)
|
||||
{
|
||||
this->m_fileTimestamp = timestampUtc.toMSecsSinceEpoch();
|
||||
m_fileTimestamp = timestampUtc.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileTimestamp(qint64 timestamp)
|
||||
{
|
||||
this->m_fileTimestamp = timestamp;
|
||||
m_fileTimestamp = timestamp;
|
||||
}
|
||||
|
||||
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
||||
{
|
||||
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
|
||||
const CPixmap pm(CPixmap::loadFromFile(this->m_iconPath, success));
|
||||
const CPixmap pm(CPixmap::loadFromFile(m_iconPath, success));
|
||||
return pm;
|
||||
}
|
||||
|
||||
@@ -542,37 +481,37 @@ namespace BlackMisc
|
||||
this->updateLocalFileNames(otherModel);
|
||||
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 (this->m_modelString.isEmpty()) { this->setModelString(otherModel.getModelString()); }
|
||||
if (this->m_name.isEmpty()) { this->setName(otherModel.getName()); }
|
||||
if (this->m_modelType == TypeUnknown) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_modelMode == Undefined) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->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_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); }
|
||||
if (m_modelString.isEmpty()) { this->setModelString(otherModel.getModelString()); }
|
||||
if (m_name.isEmpty()) { this->setName(otherModel.getName()); }
|
||||
if (m_modelType == TypeUnknown) { m_modelType = otherModel.getModelType(); }
|
||||
if (m_modelMode == Undefined) { m_modelType = otherModel.getModelType(); }
|
||||
if (m_fileTimestamp < 0) { this->setFileTimestamp(otherModel.getFileTimestamp()); }
|
||||
if (m_description.isEmpty() || m_description.startsWith(CAircraftModel::autoGenerated(), Qt::CaseInsensitive)) { this->setDescription(otherModel.getDescription()); }
|
||||
if (this->getSimulator().isUnspecified())
|
||||
{
|
||||
// simulator can only be overridden as simulators can also be removed
|
||||
this->setSimulator(otherModel.getSimulator());
|
||||
}
|
||||
|
||||
this->m_livery.updateMissingParts(otherModel.getLivery());
|
||||
this->m_aircraftIcao.updateMissingParts(otherModel.getAircraftIcaoCode());
|
||||
this->m_distributor.updateMissingParts(otherModel.getDistributor());
|
||||
m_livery.updateMissingParts(otherModel.getLivery());
|
||||
m_aircraftIcao.updateMissingParts(otherModel.getAircraftIcaoCode());
|
||||
m_distributor.updateMissingParts(otherModel.getDistributor());
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasQueriedModelString() const
|
||||
{
|
||||
return this->m_modelType == TypeQueriedFromNetwork && this->hasModelString();
|
||||
return m_modelType == TypeQueriedFromNetwork && this->hasModelString();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasManuallySetString() const
|
||||
{
|
||||
return this->m_modelType == TypeManuallySet && this->hasModelString();
|
||||
return m_modelType == TypeManuallySet && this->hasModelString();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasDescription(bool ignoreAutoGenerated) const
|
||||
{
|
||||
if (this->m_description.isEmpty()) { return false; }
|
||||
if (m_description.isEmpty()) { return false; }
|
||||
if (!ignoreAutoGenerated) { return true; }
|
||||
return (!this->getDescription().startsWith(autoGenerated(), Qt::CaseInsensitive));
|
||||
}
|
||||
@@ -601,7 +540,7 @@ namespace BlackMisc
|
||||
|
||||
void CAircraftModel::normalizeFileNameForDb()
|
||||
{
|
||||
this->m_fileName = CAircraftModel::normalizeFileNameForDb(this->m_fileName);
|
||||
m_fileName = CAircraftModel::normalizeFileNameForDb(m_fileName);
|
||||
}
|
||||
|
||||
void CAircraftModel::updateLocalFileNames(const CAircraftModel &model)
|
||||
@@ -621,14 +560,14 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
// both not local, override empty values
|
||||
if (this->m_fileName.isEmpty()) { this->setFileName(model.getFileName()); }
|
||||
if (this->m_iconPath.isEmpty()) { this->setIconPath(model.getIconPath()); }
|
||||
if (m_fileName.isEmpty()) { this->setFileName(model.getFileName()); }
|
||||
if (m_iconPath.isEmpty()) { this->setIconPath(model.getIconPath()); }
|
||||
}
|
||||
|
||||
bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||
{
|
||||
return this->m_modelString.length() == modelString.length() &&
|
||||
this->m_modelString.startsWith(modelString, sensitivity);
|
||||
return m_modelString.length() == modelString.length() &&
|
||||
m_modelString.startsWith(modelString, sensitivity);
|
||||
}
|
||||
|
||||
int CAircraftModel::calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries) const
|
||||
|
||||
@@ -143,49 +143,49 @@ namespace BlackMisc
|
||||
bool canInitializeFromFsd() const;
|
||||
|
||||
//! 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
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { this->m_callsign = callsign; }
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! 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
|
||||
const QString &getModelString() const { return this->m_modelString; }
|
||||
const QString &getModelString() const { return m_modelString; }
|
||||
|
||||
//! Model string and DB key (if available)
|
||||
QString getModelStringAndDbKey() const;
|
||||
|
||||
//! 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
|
||||
const QString &getDescription() const { return this->m_description; }
|
||||
const QString &getDescription() const { return m_description; }
|
||||
|
||||
//! 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
|
||||
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
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return this->m_aircraftIcao; }
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return m_aircraftIcao; }
|
||||
|
||||
//! Aircraft ICAO code designator
|
||||
const QString &getAircraftIcaoCodeDesignator() const { return this->m_aircraftIcao.getDesignator(); }
|
||||
const QString &getAircraftIcaoCodeDesignator() const { return m_aircraftIcao.getDesignator(); }
|
||||
|
||||
//! VTOL aircraft?
|
||||
bool isVtol() const;
|
||||
|
||||
//! 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
|
||||
const QString &getAirlineIcaoCodeDesignator() const { return this->m_livery.getAirlineIcaoCode().getDesignator(); }
|
||||
const QString &getAirlineIcaoCodeDesignator() const { return m_livery.getAirlineIcaoCode().getDesignator(); }
|
||||
|
||||
//! 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
|
||||
bool setAircraftIcaoCode(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode);
|
||||
@@ -218,7 +218,7 @@ namespace BlackMisc
|
||||
const BlackMisc::Aviation::CLivery &getLivery() const { return m_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?
|
||||
bool hasLivery() const { return m_livery.hasCompleteData();}
|
||||
@@ -251,10 +251,10 @@ namespace BlackMisc
|
||||
bool matchesAnyDbDistributor(const CDistributorList &distributors) const;
|
||||
|
||||
//! Name
|
||||
const QString &getName() const { return this->m_name; }
|
||||
const QString &getName() const { return m_name; }
|
||||
|
||||
//! Name
|
||||
void setName(const QString &name) { this->m_name = name.trimmed(); }
|
||||
void setName(const QString &name) { m_name = name.trimmed(); }
|
||||
|
||||
//! Model type
|
||||
ModelType getModelType() const { return m_modelType; }
|
||||
@@ -263,7 +263,7 @@ namespace BlackMisc
|
||||
QString getModelTypeAsString() const { return modelTypeToString(getModelType()); }
|
||||
|
||||
//! Set type
|
||||
void setModelType(ModelType type) { this->m_modelType = type; }
|
||||
void setModelType(ModelType type) { m_modelType = type; }
|
||||
|
||||
//! Model mode
|
||||
ModelMode getModelMode() const { return m_modelMode; }
|
||||
@@ -284,10 +284,10 @@ namespace BlackMisc
|
||||
void setModelModeAsString(const QString &mode);
|
||||
|
||||
//! Simulator info
|
||||
CSimulatorInfo getSimulator() const { return this->m_simulator; }
|
||||
CSimulatorInfo getSimulator() const { return m_simulator; }
|
||||
|
||||
//! Set simulator info
|
||||
void setSimulator(const CSimulatorInfo &simulator) { this->m_simulator = simulator; }
|
||||
void setSimulator(const CSimulatorInfo &simulator) { m_simulator = simulator; }
|
||||
|
||||
//! Matches given simulator?
|
||||
bool matchesSimulator(const CSimulatorInfo &simulator) const;
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace BlackMisc
|
||||
{
|
||||
this->setCom1System(com1);
|
||||
this->setCom2System(com2);
|
||||
this->m_transponder.setTransponderCode(transponderCode);
|
||||
this->m_transponder.setTransponderMode(transponderMode);
|
||||
m_transponder.setTransponderCode(transponderCode);
|
||||
m_transponder.setTransponderMode(transponderMode);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const
|
||||
@@ -89,8 +89,8 @@ namespace BlackMisc
|
||||
|
||||
bool CSimulatedAircraft::isValidForLogin() const
|
||||
{
|
||||
if (this->m_callsign.asString().isEmpty()) { return false; }
|
||||
if (!this->m_pilot.isValid()) { return false; }
|
||||
if (m_callsign.asString().isEmpty()) { return false; }
|
||||
if (!m_pilot.isValid()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ namespace BlackMisc
|
||||
|
||||
void CSimulatedAircraft::setPilot(const Network::CUser &user)
|
||||
{
|
||||
this->m_pilot = user;
|
||||
this->m_pilot.setCallsign(this->m_callsign);
|
||||
m_pilot = user;
|
||||
m_pilot.setCallsign(m_callsign);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::isEnabled() const
|
||||
@@ -133,14 +133,14 @@ namespace BlackMisc
|
||||
{
|
||||
// create a dummy livery for given ICAO code
|
||||
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
|
||||
{
|
||||
return this->m_models[CurrentModel].getAirlineIcaoCode();
|
||||
return m_models[CurrentModel].getAirlineIcaoCode();
|
||||
}
|
||||
|
||||
const QString &CSimulatedAircraft::getAirlineIcaoCodeDesignator() const
|
||||
@@ -150,7 +150,7 @@ namespace BlackMisc
|
||||
|
||||
void CSimulatedAircraft::setAircraftIcaoDesignator(const QString &designator)
|
||||
{
|
||||
this->m_models[CurrentModel].setAircraftIcaoDesignator(designator);
|
||||
m_models[CurrentModel].setAircraftIcaoDesignator(designator);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::hasAircraftDesignator() const
|
||||
@@ -194,14 +194,14 @@ namespace BlackMisc
|
||||
bool CSimulatedAircraft::setCom1ActiveFrequency(const CFrequency &frequency)
|
||||
{
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
this->m_com1system.setFrequencyActive(frequency);
|
||||
m_com1system.setFrequencyActive(frequency);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::setCom2ActiveFrequency(const CFrequency &frequency)
|
||||
{
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
this->m_com2system.setFrequencyActive(frequency);
|
||||
m_com2system.setFrequencyActive(frequency);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -297,50 +297,28 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModel:
|
||||
return this->getModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNetworkModel:
|
||||
return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNetworkModelAircraftIcaoDifference:
|
||||
return this->getNetworkModelAircraftIcaoDifference();
|
||||
case IndexNetworkModelAirlineIcaoDifference:
|
||||
return this->getNetworkModelAirlineIcaoDifference();
|
||||
case IndexNetworkModelLiveryDifference:
|
||||
return this->getNetworkModelLiveryDifference();
|
||||
case IndexEnabled:
|
||||
return CVariant::fromValue(this->isEnabled());
|
||||
case IndexRendered:
|
||||
return CVariant::fromValue(this->isRendered());
|
||||
case IndexPartsSynchronized:
|
||||
return CVariant::fromValue(this->isPartsSynchronized());
|
||||
case IndexFastPositionUpdates:
|
||||
return CVariant::fromValue(this->fastPositionUpdates());
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPilot:
|
||||
return this->m_pilot.propertyByIndex(index.copyFrontRemoved());
|
||||
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));
|
||||
case IndexModel: return this->getModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNetworkModel: return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNetworkModelAircraftIcaoDifference: return this->getNetworkModelAircraftIcaoDifference();
|
||||
case IndexNetworkModelAirlineIcaoDifference: return this->getNetworkModelAirlineIcaoDifference();
|
||||
case IndexNetworkModelLiveryDifference: return this->getNetworkModelLiveryDifference();
|
||||
case IndexEnabled: return CVariant::fromValue(this->isEnabled());
|
||||
case IndexRendered: return CVariant::fromValue(this->isRendered());
|
||||
case IndexPartsSynchronized: return CVariant::fromValue(this->isPartsSynchronized());
|
||||
case IndexFastPositionUpdates: return CVariant::fromValue(this->fastPositionUpdates());
|
||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPilot: return m_pilot.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRelativeDistance: return m_relativeDistance.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCom1System: return m_com1system.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCom2System: return m_com2system.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexTransponder: return m_transponder.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSituation: return m_situation.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAircraftIcaoCode: return this->getAircraftIcaoCode().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLivery: return this->getLivery().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexParts: return 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:
|
||||
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
|
||||
ICoordinateWithRelativePosition::propertyByIndex(index) :
|
||||
@@ -351,54 +329,26 @@ namespace BlackMisc
|
||||
void CSimulatedAircraft::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CSimulatedAircraft>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign:
|
||||
this->m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexPilot:
|
||||
this->m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexRelativeDistance:
|
||||
this->m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexCom1System:
|
||||
this->m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexCom2System:
|
||||
this->m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
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 IndexCallsign: m_callsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexPilot: m_pilot.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexRelativeDistance: m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCom1System: m_com1system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCom2System: m_com2system.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexTransponder: m_transponder.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexSituation: m_situation.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexParts: m_parts.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexNetworkModel: m_models[NetworkModel].setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexEnabled: m_enabled = variant.toBool(); break;
|
||||
case IndexRendered: m_rendered = variant.toBool(); break;
|
||||
case IndexPartsSynchronized: m_partsSynchronized = variant.toBool(); break;
|
||||
case IndexFastPositionUpdates: m_fastPositionUpdates = variant.toBool(); break;
|
||||
case IndexLivery: Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported"); break;
|
||||
case IndexModel:
|
||||
this->m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
this->setModel(this->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");
|
||||
m_models[CurrentModel].setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
this->setModel(m_models[CurrentModel]); // sync some values such as callsign
|
||||
break;
|
||||
default:
|
||||
if (ICoordinateWithRelativePosition::canHandleIndex(index))
|
||||
@@ -415,48 +365,29 @@ namespace BlackMisc
|
||||
|
||||
int CSimulatedAircraft::comparePropertyByIndex(const CPropertyIndex &index, const CSimulatedAircraft &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
if (index.isMyself()) { return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexPilot:
|
||||
return this->m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot());
|
||||
case IndexSituation:
|
||||
return this->m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation());
|
||||
case IndexRelativeDistance:
|
||||
return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
||||
case IndexCom1System:
|
||||
return this->m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System());
|
||||
case IndexCom2System:
|
||||
return this->m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System());
|
||||
case IndexTransponder:
|
||||
return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode());
|
||||
case IndexLivery:
|
||||
return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
|
||||
case IndexParts:
|
||||
return this->m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
|
||||
case IndexModel:
|
||||
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));
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexPilot: return m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot());
|
||||
case IndexSituation: return m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation());
|
||||
case IndexRelativeDistance: return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
||||
case IndexCom1System: return m_com1system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System());
|
||||
case IndexCom2System: return m_com2system.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System());
|
||||
case IndexTransponder: return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode());
|
||||
case IndexLivery: return this->getLivery().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLivery());
|
||||
case IndexParts: return m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
|
||||
case IndexModel: 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(m_rendered, compareValue.isRendered());
|
||||
case IndexPartsSynchronized: return Compare::compare(m_partsSynchronized, compareValue.isPartsSynchronized());
|
||||
case IndexFastPositionUpdates: return Compare::compare(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:
|
||||
if (ICoordinateWithRelativePosition::canHandleIndex(index))
|
||||
{
|
||||
@@ -471,13 +402,13 @@ namespace BlackMisc
|
||||
const CAircraftModel &CSimulatedAircraft::getNetworkModelOrModel() const
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
@@ -514,7 +445,7 @@ namespace BlackMisc
|
||||
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
|
||||
|
||||
// sync the callsigns
|
||||
this->m_models[CurrentModel] = model;
|
||||
m_models[CurrentModel] = model;
|
||||
this->setCallsign(this->hasValidCallsign() ? this->getCallsign() : model.getCallsign());
|
||||
this->setIcaoCodes(model.getAircraftIcaoCode(), model.getAirlineIcaoCode());
|
||||
}
|
||||
@@ -522,44 +453,44 @@ namespace BlackMisc
|
||||
void CSimulatedAircraft::setNetworkModel(const CAircraftModel &model)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_ASSERT_X(m_models.size() == 2, Q_FUNC_INFO, "Wrong model size");
|
||||
this->m_callsign = callsign;
|
||||
this->m_models[CurrentModel].setCallsign(callsign);
|
||||
this->m_models[NetworkModel].setCallsign(callsign);
|
||||
this->m_pilot.setCallsign(callsign);
|
||||
m_callsign = callsign;
|
||||
m_models[CurrentModel].setCallsign(callsign);
|
||||
m_models[NetworkModel].setCallsign(callsign);
|
||||
m_pilot.setCallsign(callsign);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::isActiveFrequencyWithin8_33kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
|
||||
this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
|
||||
return m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
|
||||
m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::isActiveFrequencyWithin25kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
|
||||
this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
||||
return m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
|
||||
m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
||||
}
|
||||
|
||||
QString CSimulatedAircraft::convertToQString(bool i18n) const
|
||||
{
|
||||
const QString s = this->m_callsign.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_pilot.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_situation.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_com1system.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_com2system.toQString(i18n) %
|
||||
QLatin1Char(' ') % this->m_transponder.toQString(i18n) %
|
||||
const QString s = m_callsign.toQString(i18n) %
|
||||
QLatin1Char(' ') % m_pilot.toQString(i18n) %
|
||||
QLatin1Char(' ') % m_situation.toQString(i18n) %
|
||||
QLatin1Char(' ') % m_com1system.toQString(i18n) %
|
||||
QLatin1Char(' ') % m_com2system.toQString(i18n) %
|
||||
QLatin1Char(' ') % m_transponder.toQString(i18n) %
|
||||
QLatin1String(" enabled: ") % BlackMisc::boolToYesNo(this->isEnabled()) %
|
||||
QLatin1String(" rendered: ") % BlackMisc::boolToYesNo(this->isRendered()) %
|
||||
QLatin1Char(' ') % this->getModel().toQString(i18n);
|
||||
|
||||
@@ -153,16 +153,16 @@ namespace BlackMisc
|
||||
void setAircraftIcaoDesignator(const QString &designator);
|
||||
|
||||
//! Has valid realname?
|
||||
bool hasValidRealName() const { return this->m_pilot.hasValidRealName(); }
|
||||
bool hasValidRealName() const { return m_pilot.hasValidRealName(); }
|
||||
|
||||
//! Has valid id?
|
||||
bool hasValidId() const { return this->m_pilot.hasValidId(); }
|
||||
bool hasValidId() const { return m_pilot.hasValidId(); }
|
||||
|
||||
//! Valid designator?
|
||||
bool hasAircraftDesignator() const;
|
||||
|
||||
//! Valid airline designator
|
||||
bool hasAirlineDesignator() const { return this->m_models[CurrentModel].getLivery().hasValidAirlineDesignator(); }
|
||||
bool hasAirlineDesignator() const { return m_models[CurrentModel].getLivery().hasValidAirlineDesignator(); }
|
||||
|
||||
//! Valid designators?
|
||||
bool hasAircraftAndAirlineDesignator() const;
|
||||
@@ -174,55 +174,55 @@ namespace BlackMisc
|
||||
bool hasCallsign() const { return !getCallsign().isEmpty(); }
|
||||
|
||||
//! Get position
|
||||
BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return this->m_situation.getPosition(); }
|
||||
BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return m_situation.getPosition(); }
|
||||
|
||||
//! 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
|
||||
const BlackMisc::Aviation::CAltitude &getAltitude() const { return this->m_situation.getAltitude(); }
|
||||
const BlackMisc::Aviation::CAltitude &getAltitude() const { return m_situation.getAltitude(); }
|
||||
|
||||
//! 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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
virtual QVector3D normalVector() const override { return this->m_situation.normalVector(); }
|
||||
virtual QVector3D normalVector() const override { return m_situation.normalVector(); }
|
||||
|
||||
//! \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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return this->m_situation.getBank(); }
|
||||
const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return m_situation.getBank(); }
|
||||
|
||||
//! 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
|
||||
const BlackMisc::Aviation::CComSystem &getCom2System() const { return this->m_com2system; }
|
||||
const BlackMisc::Aviation::CComSystem &getCom2System() const { return m_com2system; }
|
||||
|
||||
//! Get COM unit
|
||||
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);
|
||||
|
||||
//! 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
|
||||
void setCom2System(const BlackMisc::Aviation::CComSystem &comSystem) { this->m_com2system = comSystem; }
|
||||
void setCom2System(const BlackMisc::Aviation::CComSystem &comSystem) { m_com2system = comSystem; }
|
||||
|
||||
//! Set COM1 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);
|
||||
|
||||
//! 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?
|
||||
bool hasValidSelcal() const { return this->m_selcal.isValid(); }
|
||||
bool hasValidSelcal() const { return m_selcal.isValid(); }
|
||||
|
||||
//! 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);
|
||||
|
||||
//! 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?
|
||||
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;
|
||||
|
||||
//! Get transponder
|
||||
const BlackMisc::Aviation::CTransponder &getTransponder() const { return this->m_transponder; }
|
||||
const BlackMisc::Aviation::CTransponder &getTransponder() const { return m_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
|
||||
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
|
||||
void setTransponderCode(int code) { this->m_transponder.setTransponderCode(code); }
|
||||
void setTransponderCode(int code) { m_transponder.setTransponderCode(code); }
|
||||
|
||||
//! Get transponder code
|
||||
QString getTransponderCodeFormatted() const { return this->m_transponder.getTransponderCodeFormatted(); }
|
||||
QString getTransponderCodeFormatted() const { return m_transponder.getTransponderCodeFormatted(); }
|
||||
|
||||
//! Get transponder code
|
||||
qint32 getTransponderCode() const { return this->m_transponder.getTransponderCode(); }
|
||||
qint32 getTransponderCode() const { return m_transponder.getTransponderCode(); }
|
||||
|
||||
//! 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?
|
||||
bool isValidForLogin() const;
|
||||
@@ -414,7 +414,7 @@ namespace BlackMisc
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
BlackMisc::CIcon toIcon() const { return m_callsign.toIcon(); }
|
||||
|
||||
private:
|
||||
static constexpr int CurrentModel = 0; //!< m_models
|
||||
|
||||
Reference in New Issue
Block a user