mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
ChangedModel in ownAircraft context was not really used.
However, there are cases where the "own model" is changed via own model context, mostly in the emulated driver. * made changedModel -> ps_changedModel a "private" signal * connected it to simulator context * used identifier to avoid roundtrips So the "ownAircraftModelChanged" signal of the simulator context is to be used
This commit is contained in:
committed by
Mat Sutcliffe
parent
d12f164d26
commit
73e566a76e
@@ -104,9 +104,6 @@ namespace BlackCore
|
|||||||
//! Own pilot (aka the swift user) changed
|
//! Own pilot (aka the swift user) changed
|
||||||
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
void changedPilot(const BlackMisc::Network::CUser &pilot);
|
||||||
|
|
||||||
//! Changed aircraft model
|
|
||||||
void changedModel(const BlackMisc::Simulation::CAircraftModel &model);
|
|
||||||
|
|
||||||
//! Aircraft has been moved from one location to another (changed scenery)
|
//! Aircraft has been moved from one location to another (changed scenery)
|
||||||
void movedAircraft();
|
void movedAircraft();
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,11 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CContextOwnAircraft::updateOwnModel(const CAircraftModel &model)
|
bool CContextOwnAircraft::updateOwnModel(const CAircraftModel &model)
|
||||||
|
{
|
||||||
|
return updateOwnModel(model, this->identifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CContextOwnAircraft::updateOwnModel(const CAircraftModel &model, const CIdentifier &identifier)
|
||||||
{
|
{
|
||||||
CAircraftModel updateModel(this->reverseLookupModel(model));
|
CAircraftModel updateModel(this->reverseLookupModel(model));
|
||||||
{
|
{
|
||||||
@@ -248,7 +253,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// changed model
|
// changed model
|
||||||
emit this->changedModel(updateModel);
|
emit this->ps_changedModel(updateModel, identifier);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,9 +438,9 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model)
|
void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model, const CIdentifier &identifier)
|
||||||
{
|
{
|
||||||
this->updateOwnModel(model);
|
this->updateOwnModel(model, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextOwnAircraft::xCtxChangedSimulatorStatus(int status)
|
void CContextOwnAircraft::xCtxChangedSimulatorStatus(int status)
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ namespace BlackCore
|
|||||||
//! \copydoc BlackMisc::IProvider::asQObject
|
//! \copydoc BlackMisc::IProvider::asQObject
|
||||||
virtual QObject *asQObject() override { return this; }
|
virtual QObject *asQObject() override { return this; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! Changed aircraft model
|
||||||
|
//! \private Use ISimulatorContext::ownAircraftModelChanged
|
||||||
|
void ps_changedModel(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::CIdentifier &identifier);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
||||||
//! \ingroup ownaircraftprovider
|
//! \ingroup ownaircraftprovider
|
||||||
@@ -226,7 +231,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Simulator model has been changed
|
//! Simulator model has been changed
|
||||||
//! \ingroup crosscontextfunction
|
//! \ingroup crosscontextfunction
|
||||||
void xCtxChangedSimulatorModel(const BlackMisc::Simulation::CAircraftModel &model);
|
void xCtxChangedSimulatorModel(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::CIdentifier &identifier);
|
||||||
|
|
||||||
//! Simulator status changed
|
//! Simulator status changed
|
||||||
//! \ingroup crosscontextfunction
|
//! \ingroup crosscontextfunction
|
||||||
@@ -249,6 +254,9 @@ namespace BlackCore
|
|||||||
//! Update position history
|
//! Update position history
|
||||||
void evaluateUpdateHistory();
|
void evaluateUpdateHistory();
|
||||||
|
|
||||||
|
//! Update own model and emit signal with identifier
|
||||||
|
bool updateOwnModel(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::CIdentifier &identifier);
|
||||||
|
|
||||||
//! Reverse lookup of the model against DB data
|
//! Reverse lookup of the model against DB data
|
||||||
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ namespace BlackCore
|
|||||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||||
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
|
"changedPilot", this, SIGNAL(changedPilot(BlackMisc::Network::CUser)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
|
||||||
"changedModel", this, SIGNAL(changedModel(BlackMisc::Simulation::CAircraftModel)));
|
|
||||||
Q_ASSERT(s);
|
|
||||||
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
s = connection.connect(serviceName, IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||||
"movedAircraft", this, SIGNAL(movedAircraft()));
|
"movedAircraft", this, SIGNAL(movedAircraft()));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
|||||||
@@ -682,6 +682,14 @@ namespace BlackCore
|
|||||||
m_simulatorPlugin.second->changeRemoteAircraftModel(aircraft);
|
m_simulatorPlugin.second->changeRemoteAircraftModel(aircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextSimulator::xCtxChangedOwnAircraftModel(const CAircraftModel &aircraftModel, const CIdentifier &originator)
|
||||||
|
{
|
||||||
|
if (CIdentifiable::isMyIdentifier(originator)) { return; }
|
||||||
|
if (!this->isSimulatorAvailable()) { return; }
|
||||||
|
|
||||||
|
emit this->ownAircraftModelChanged(aircraftModel);
|
||||||
|
}
|
||||||
|
|
||||||
void CContextSimulator::xCtxChangedRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
void CContextSimulator::xCtxChangedRemoteAircraftEnabled(const CSimulatedAircraft &aircraft)
|
||||||
{
|
{
|
||||||
if (!this->isSimulatorAvailable()) { return; }
|
if (!this->isSimulatorAvailable()) { return; }
|
||||||
|
|||||||
@@ -186,6 +186,9 @@ namespace BlackCore
|
|||||||
//! Changed remote aircraft model
|
//! Changed remote aircraft model
|
||||||
void xCtxChangedRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
void xCtxChangedRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
|
//! Changed own aircraft model
|
||||||
|
void xCtxChangedOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &aircraftModel, const BlackMisc::CIdentifier &originator);
|
||||||
|
|
||||||
//! Enable / disable aircraft
|
//! Enable / disable aircraft
|
||||||
void xCtxChangedRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
void xCtxChangedRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||||
|
|
||||||
|
|||||||
@@ -237,12 +237,27 @@ namespace BlackCore
|
|||||||
c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedSelcal,
|
c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedSelcal,
|
||||||
this->getCContextSimulator(), &CContextSimulator::xCtxUpdateSimulatorSelcalFromContext);
|
this->getCContextSimulator(), &CContextSimulator::xCtxUpdateSimulatorSelcalFromContext);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
|
||||||
|
// relay changed aircraft to own aircraft provider but with identifier
|
||||||
|
// identifier is needed because own aircraft context also reports changed aircraft to xCtxChangedOwnAircraftModel
|
||||||
|
// and we avoid roundtrips
|
||||||
c = connect(this->getCContextSimulator(), &CContextSimulator::ownAircraftModelChanged,
|
c = connect(this->getCContextSimulator(), &CContextSimulator::ownAircraftModelChanged,
|
||||||
this->getCContextOwnAircraft(), &CContextOwnAircraft::xCtxChangedSimulatorModel);
|
this->getCContextOwnAircraft(), [ = ](const CAircraftModel & changedModel)
|
||||||
|
{
|
||||||
|
if (!this->getIContextOwnAircraft()) { return; }
|
||||||
|
if (!this->getCContextSimulator()) { return; }
|
||||||
|
this->getCContextOwnAircraft()->xCtxChangedSimulatorModel(changedModel, this->getCContextSimulator()->identifier());
|
||||||
|
});
|
||||||
|
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
c = connect(this->getCContextSimulator(), &CContextSimulator::simulatorStatusChanged,
|
c = connect(this->getCContextSimulator(), &CContextSimulator::simulatorStatusChanged,
|
||||||
this->getCContextOwnAircraft(), &CContextOwnAircraft::xCtxChangedSimulatorStatus);
|
this->getCContextOwnAircraft(), &CContextOwnAircraft::xCtxChangedSimulatorStatus);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
|
||||||
|
// this is used if the value in own aircraft is changed, to callback simulator
|
||||||
|
c = connect(this->getCContextOwnAircraft(), &CContextOwnAircraft::ps_changedModel,
|
||||||
|
this->getCContextSimulator(), &CContextSimulator::xCtxChangedOwnAircraftModel);
|
||||||
|
Q_ASSERT(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// times
|
// times
|
||||||
|
|||||||
Reference in New Issue
Block a user