mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
refs #242, changed different classes/components to use aircraft context instead of network context
* removed own aircraft from simulator context * in GUI, also added originator for signals/ slots * flightplan / text messages
This commit is contained in:
@@ -69,9 +69,6 @@ namespace BlackCore
|
||||
//! \brief Disconnect from simulator
|
||||
virtual bool disconnectFrom() = 0;
|
||||
|
||||
//! Get user aircraft value object
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
||||
|
||||
//! Simulator info
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const = 0;
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "context_simulator_impl.h"
|
||||
#include "context_ownaircraft_impl.h"
|
||||
#include "context_runtime.h"
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QLibrary>
|
||||
#include "context_runtime.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -27,6 +29,13 @@ namespace BlackCore
|
||||
asyncConnectTo();
|
||||
}
|
||||
|
||||
void CContextSimulator::updateOwnAircraft()
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
Q_ASSERT(this->getRuntime()->getCContextOwnAircraft());
|
||||
this->getRuntime()->getCContextOwnAircraft()->updateOwnAircraft(this->m_simulator->getOwnAircraft(), IContextSimulator::InterfaceName());
|
||||
}
|
||||
|
||||
CContextSimulator::~CContextSimulator()
|
||||
{
|
||||
disconnectFrom();
|
||||
@@ -68,7 +77,7 @@ namespace BlackCore
|
||||
{
|
||||
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
if (!m_simulator || m_canConnectResult.isRunning()) return; // already checking
|
||||
m_simulator->asyncConnectTo();
|
||||
this->m_canConnectResult = QtConcurrent::run(this, &CContextSimulator::connectTo);
|
||||
}
|
||||
|
||||
bool CContextSimulator::disconnectFrom()
|
||||
@@ -78,12 +87,6 @@ namespace BlackCore
|
||||
return m_simulator->disconnectFrom();
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAircraft CContextSimulator::getOwnAircraft() const
|
||||
{
|
||||
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return m_ownAircraft;
|
||||
}
|
||||
|
||||
BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const
|
||||
{
|
||||
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
@@ -113,7 +116,7 @@ namespace BlackCore
|
||||
m_simulator = factory->create(this);
|
||||
Q_ASSERT(m_simulator);
|
||||
|
||||
connect(m_simulator, SIGNAL(statusChanged(ISimulator::Status)), this, SLOT(setConnectionStatus(ISimulator::Status)));
|
||||
connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -125,26 +128,13 @@ namespace BlackCore
|
||||
m_simulator = nullptr;
|
||||
}
|
||||
|
||||
void CContextSimulator::updateOwnAircraft()
|
||||
void CContextSimulator::setConnectionStatus(bool value)
|
||||
{
|
||||
m_ownAircraft = m_simulator->getOwnAircraft();
|
||||
getIContextNetwork()->updateOwnSituation(m_ownAircraft.getSituation());
|
||||
getIContextNetwork()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
|
||||
}
|
||||
|
||||
void CContextSimulator::setConnectionStatus(ISimulator::Status status)
|
||||
{
|
||||
if (status == ISimulator::Connected)
|
||||
{
|
||||
if (value)
|
||||
m_updateTimer->start(100);
|
||||
emit connectionChanged(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_updateTimer->stop();
|
||||
emit connectionChanged(false);
|
||||
}
|
||||
|
||||
emit connectionChanged(value);
|
||||
}
|
||||
|
||||
void CContextSimulator::findSimulatorPlugins()
|
||||
|
||||
@@ -55,9 +55,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::disconnectFrom
|
||||
virtual bool disconnectFrom() override;
|
||||
|
||||
//! \copydoc IContextSimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo()
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
|
||||
@@ -84,7 +81,7 @@ namespace BlackCore
|
||||
|
||||
private slots:
|
||||
//! \copydoc IContextSimulator::updateOwnAircraft()
|
||||
virtual void updateOwnAircraft();
|
||||
void updateOwnAircraft();
|
||||
|
||||
//! Set new connection status
|
||||
void setConnectionStatus(ISimulator::Status status);
|
||||
@@ -93,7 +90,6 @@ namespace BlackCore
|
||||
//! \brief find and catalog all simulator plugins
|
||||
void findSimulatorPlugins();
|
||||
|
||||
BlackMisc::Aviation::CAircraft m_ownAircraft;
|
||||
BlackMisc::Network::CAircraftModel m_aircraftModel;
|
||||
BlackCore::ISimulator *m_simulator;
|
||||
|
||||
|
||||
@@ -58,11 +58,6 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("disconnectFrom"));
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CAircraft CContextSimulatorProxy::getOwnAircraft() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("getOwnAircraft"));
|
||||
}
|
||||
|
||||
BlackMisc::Network::CAircraftModel CContextSimulatorProxy::getOwnAircraftModel() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Network::CAircraftModel>(QLatin1Literal("getOwnAircraftModel"));
|
||||
|
||||
@@ -54,9 +54,6 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::disconnectFrom
|
||||
virtual bool disconnectFrom() override;
|
||||
|
||||
//! \copydoc IContextSimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getAircraftModel()
|
||||
virtual BlackMisc::Network::CAircraftModel getOwnAircraftModel() const override;
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace BlackGui
|
||||
{
|
||||
if (this->getIContextNetwork())
|
||||
{
|
||||
this->prefillWithAircraftData(this->getIContextNetwork()->getOwnAircraft());
|
||||
this->prefillWithAircraftData(this->getIContextOwnAircraft()->getOwnAircraft());
|
||||
}
|
||||
this->ui->le_AircraftRegistration->clear();
|
||||
this->ui->le_AirlineOperator->clear();
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace BlackGui
|
||||
BlackMisc::Network::CTextMessage getTextMessageStubForChannel();
|
||||
|
||||
//! own aircraft
|
||||
const BlackMisc::Aviation::CAircraft getOwnAircraft() const { Q_ASSERT(this->getIContextNetwork()); return this->getIContextNetwork()->getOwnAircraft(); }
|
||||
const BlackMisc::Aviation::CAircraft getOwnAircraft() const { Q_ASSERT(this->getIContextOwnAircraft()); return this->getIContextOwnAircraft()->getOwnAircraft(); }
|
||||
|
||||
//! For this text message's recepient, is the current tab selected?
|
||||
bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const;
|
||||
|
||||
Reference in New Issue
Block a user