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