mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #793, keep network model (as reverse looked up)
This commit is contained in:
@@ -332,6 +332,11 @@ namespace BlackMisc
|
||||
return this->m_livery.hasValidAirlineDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasAircraftAndAirlineDesignator() const
|
||||
{
|
||||
return this->hasAircraftDesignator() && this->hasAirlineDesignator();
|
||||
}
|
||||
|
||||
bool CAircraftModel::isMilitary() const
|
||||
{
|
||||
return this->getAircraftIcaoCode().isMilitary() ||
|
||||
|
||||
@@ -198,7 +198,10 @@ namespace BlackMisc
|
||||
//! Airline designator?
|
||||
bool hasAirlineDesignator() const;
|
||||
|
||||
//! Military modles
|
||||
//! Designators
|
||||
bool hasAircraftAndAirlineDesignator() const;
|
||||
|
||||
//! Military model?
|
||||
bool isMilitary() const;
|
||||
|
||||
//! Get livery
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BlackMisc
|
||||
init();
|
||||
}
|
||||
|
||||
CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_model(model)
|
||||
CSimulatedAircraft::CSimulatedAircraft(const CAircraftModel &model) : m_model(model), m_networkModel(model)
|
||||
{
|
||||
this->setCallsign(model.getCallsign());
|
||||
init();
|
||||
@@ -146,7 +146,7 @@ namespace BlackMisc
|
||||
|
||||
bool CSimulatedAircraft::hasAircraftAndAirlineDesignator() const
|
||||
{
|
||||
return this->getAircraftIcaoCode().hasDesignator() && this->m_model.getLivery().hasValidAirlineDesignator();
|
||||
return this->getModel().hasAircraftAndAirlineDesignator();
|
||||
}
|
||||
|
||||
const CComSystem CSimulatedAircraft::getComSystem(CComSystem::ComUnit unit) const
|
||||
@@ -239,33 +239,34 @@ namespace BlackMisc
|
||||
return getAircraftIcaoCode().isVtol();
|
||||
}
|
||||
|
||||
QString CSimulatedAircraft::getCombinedIcaoLiveryString() const
|
||||
QString CSimulatedAircraft::getCombinedIcaoLiveryString(bool networkModel) const
|
||||
{
|
||||
if (this->hasAircraftAndAirlineDesignator())
|
||||
const CAircraftModel model(networkModel ? this->getNetworkModel() : this->getModel());
|
||||
if (model.hasAircraftAndAirlineDesignator())
|
||||
{
|
||||
if (getLivery().hasCombinedCode())
|
||||
if (model.getLivery().hasCombinedCode())
|
||||
{
|
||||
QString s("%1 (%2 %3)");
|
||||
return s.arg(getAircraftIcaoCodeDesignator()).arg(getAirlineIcaoCodeDesignator()).arg(getLivery().getCombinedCode());
|
||||
static const QString s("%1 (%2 %3)");
|
||||
return s.arg(model.getAircraftIcaoCodeDesignator(), model.getAirlineIcaoCodeDesignator(), model.getLivery().getCombinedCode());
|
||||
}
|
||||
else
|
||||
{
|
||||
QString s("%1 (%2)");
|
||||
return s.arg(getAircraftIcaoCodeDesignator()).arg(getAirlineIcaoCodeDesignator());
|
||||
static const QString s("%1 (%2)");
|
||||
return s.arg(model.getAircraftIcaoCodeDesignator(), model.getAirlineIcaoCodeDesignator());
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->hasAircraftDesignator())
|
||||
{
|
||||
return getLivery().getCombinedCode();
|
||||
return model.getLivery().getCombinedCode();
|
||||
}
|
||||
else if (this->getLivery().hasCombinedCode())
|
||||
else if (model.getLivery().hasCombinedCode())
|
||||
{
|
||||
QString s("%1 (%2)");
|
||||
return s.arg(getAircraftIcaoCodeDesignator()).arg(getLivery().getCombinedCode());
|
||||
static const QString s("%1 (%2)");
|
||||
return s.arg(model.getAircraftIcaoCodeDesignator(), model.getLivery().getCombinedCode());
|
||||
}
|
||||
|
||||
return getAircraftIcaoCode().getDesignator();
|
||||
return model.getAircraftIcaoCode().getDesignator();
|
||||
}
|
||||
|
||||
CVariant CSimulatedAircraft::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
@@ -275,7 +276,9 @@ namespace BlackMisc
|
||||
switch (i)
|
||||
{
|
||||
case IndexModel:
|
||||
return this->m_model.propertyByIndex(index.copyFrontRemoved());
|
||||
return this->getModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexNetworkModel:
|
||||
return this->getNetworkModel().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexEnabled:
|
||||
return CVariant::fromValue(this->isEnabled());
|
||||
case IndexRendered:
|
||||
@@ -307,7 +310,9 @@ namespace BlackMisc
|
||||
case IndexIsVtol:
|
||||
return CVariant::fromValue(this->isVtol());
|
||||
case IndexCombinedIcaoLiveryString:
|
||||
return CVariant::fromValue(this->getCombinedIcaoLiveryString());
|
||||
return CVariant::fromValue(this->getCombinedIcaoLiveryString(false));
|
||||
case IndexCombinedIcaoLiveryStringNetworkModel:
|
||||
return CVariant::fromValue(this->getCombinedIcaoLiveryString(true));
|
||||
default:
|
||||
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
|
||||
ICoordinateWithRelativePosition::propertyByIndex(index) :
|
||||
@@ -349,6 +354,9 @@ namespace BlackMisc
|
||||
this->m_model.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
this->setModel(this->m_model); // sync some values
|
||||
break;
|
||||
case IndexNetworkModel:
|
||||
this->m_networkModel.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexEnabled:
|
||||
this->m_enabled = variant.toBool();
|
||||
break;
|
||||
@@ -402,8 +410,8 @@ namespace BlackMisc
|
||||
return this->m_parts.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getParts());
|
||||
case IndexModel:
|
||||
return m_model.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
|
||||
case IndexEnabled:
|
||||
return Compare::compare(this->m_enabled, compareValue.isEnabled());
|
||||
case IndexNetworkModel:
|
||||
return m_networkModel.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel());
|
||||
case IndexRendered:
|
||||
return Compare::compare(this->m_rendered, compareValue.isRendered());
|
||||
case IndexPartsSynchronized:
|
||||
@@ -421,6 +429,16 @@ namespace BlackMisc
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CAircraftModel &CSimulatedAircraft::getNetworkModelOrModel() const
|
||||
{
|
||||
return this->hasNetworkModel() ? this->m_networkModel : this->m_model;
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::hasNetworkModel() const
|
||||
{
|
||||
return this->m_networkModel.hasModelString() || !this->m_networkModel.getCallsign().isEmpty();
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setModel(const CAircraftModel &model)
|
||||
{
|
||||
// sync the callsigns
|
||||
@@ -429,6 +447,11 @@ namespace BlackMisc
|
||||
this->setIcaoCodes(model.getAircraftIcaoCode(), model.getAirlineIcaoCode());
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setNetworkModel(const CAircraftModel &model)
|
||||
{
|
||||
this->m_networkModel = model;
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setModelString(const QString &modelString)
|
||||
{
|
||||
this->m_model.setModelString(modelString);
|
||||
@@ -438,6 +461,7 @@ namespace BlackMisc
|
||||
{
|
||||
this->m_callsign = callsign;
|
||||
this->m_model.setCallsign(callsign);
|
||||
this->m_networkModel.setCallsign(callsign);
|
||||
this->m_pilot.setCallsign(callsign);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,9 @@ namespace BlackMisc
|
||||
IndexParts,
|
||||
IndexIsVtol,
|
||||
IndexCombinedIcaoLiveryString,
|
||||
IndexCombinedIcaoLiveryStringNetworkModel,
|
||||
IndexModel,
|
||||
IndexNetworkModel,
|
||||
IndexEnabled,
|
||||
IndexRendered,
|
||||
IndexPartsSynchronized,
|
||||
@@ -325,7 +327,7 @@ namespace BlackMisc
|
||||
bool isVtol() const;
|
||||
|
||||
//! Combined ICAO / color string
|
||||
QString getCombinedIcaoLiveryString() const;
|
||||
QString getCombinedIcaoLiveryString(bool networkModel = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
@@ -339,17 +341,32 @@ namespace BlackMisc
|
||||
//! Get model
|
||||
const BlackMisc::Simulation::CAircraftModel &getModel() const { return m_model; }
|
||||
|
||||
//! Get network model
|
||||
const BlackMisc::Simulation::CAircraftModel &getNetworkModel() const { return m_networkModel; }
|
||||
|
||||
//! Get network model or (if not existing) model
|
||||
const BlackMisc::Simulation::CAircraftModel &getNetworkModelOrModel() const;
|
||||
|
||||
//! Has a network model been set?
|
||||
bool hasNetworkModel() const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CAircraftModel::getIconPath
|
||||
const QString &getIconPath() const { return m_model.getIconPath(); }
|
||||
|
||||
//! Get model string
|
||||
QString getModelString() const { return m_model.getModelString(); }
|
||||
const QString &getModelString() const { return m_model.getModelString(); }
|
||||
|
||||
//! Set model string
|
||||
void setModelString(const QString &modelString);
|
||||
|
||||
//! Has model string?
|
||||
bool hasModelString() const { return m_model.hasModelString(); }
|
||||
|
||||
//! Set model
|
||||
void setModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
//! Set model string
|
||||
void setModelString(const QString &modelString);
|
||||
//! Set network model
|
||||
void setNetworkModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
//! Set callsign
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
@@ -394,9 +411,10 @@ namespace BlackMisc
|
||||
BlackMisc::Aviation::CAircraftParts m_parts;
|
||||
BlackMisc::Aviation::CSelcal m_selcal;
|
||||
BlackMisc::Simulation::CAircraftModel m_model;
|
||||
BlackMisc::Simulation::CAircraftModel m_networkModel; //!< model received from network
|
||||
bool m_enabled = true; //!< to be displayed in simulator
|
||||
bool m_rendered = false; //!< really shown in simulator
|
||||
bool m_partsSynchronized = false; //!< sync.parts
|
||||
bool m_partsSynchronized = false; //!< synchronize parts
|
||||
bool m_fastPositionUpdates = false; //!< use fast position updates
|
||||
|
||||
//! Init, which syncronizes some denormalized values
|
||||
@@ -414,6 +432,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(relativeDistance),
|
||||
BLACK_METAMEMBER(relativeBearing),
|
||||
BLACK_METAMEMBER(model),
|
||||
BLACK_METAMEMBER(networkModel),
|
||||
BLACK_METAMEMBER(enabled),
|
||||
BLACK_METAMEMBER(rendered),
|
||||
BLACK_METAMEMBER(partsSynchronized),
|
||||
|
||||
Reference in New Issue
Block a user