mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Flight plan fixes based on https://discordapp.com/channels/539048679160676382/539486309882789888/597133111272275970
* improved setting of combox value, fixed wrong text * do NOT emit signals when same index * getOwnCallsign * do NOT used cache FPs for own aircraft
This commit is contained in:
@@ -160,14 +160,17 @@ namespace BlackCore
|
|||||||
|
|
||||||
// use cache, but not for own callsign (always reload)
|
// use cache, but not for own callsign (always reload)
|
||||||
if (m_flightPlanCache.contains(callsign)) { plan = m_flightPlanCache[callsign]; }
|
if (m_flightPlanCache.contains(callsign)) { plan = m_flightPlanCache[callsign]; }
|
||||||
if (!plan.wasSentOrLoaded() || plan.timeDiffSentOrLoadedMs() > 30 * 1000)
|
const bool ownAircraft = this->getOwnCallsign() == callsign;
|
||||||
|
if (ownAircraft || !plan.wasSentOrLoaded() || plan.timeDiffSentOrLoadedMs() > 30 * 1000)
|
||||||
{
|
{
|
||||||
// outdated, or not in cache at all
|
// outdated, or not in cache at all, or NOT own aircraft
|
||||||
|
plan = CFlightPlan(); // reset
|
||||||
|
m_flightPlanCache.remove(callsign);
|
||||||
m_network->sendFlightPlanQuery(callsign);
|
m_network->sendFlightPlanQuery(callsign);
|
||||||
|
|
||||||
// with this little trick we try to make an asynchronous signal / slot
|
// with this little trick we try to make an asynchronous signal / slot
|
||||||
// based approach a synchronous return value
|
// based approach a synchronous return value
|
||||||
const QTime waitForFlightPlan = QTime::currentTime().addMSecs(1000);
|
const QTime waitForFlightPlan = QTime::currentTime().addMSecs(1500);
|
||||||
while (sApp && QTime::currentTime() < waitForFlightPlan)
|
while (sApp && QTime::currentTime() < waitForFlightPlan)
|
||||||
{
|
{
|
||||||
// process some other events and hope network answer is received already
|
// process some other events and hope network answer is received already
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ namespace BlackCore
|
|||||||
return m_ownAircraft.getTransponder();
|
return m_ownAircraft.getTransponder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCallsign CContextOwnAircraft::getOwnCallsign() const
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lockAircraft);
|
||||||
|
return m_ownAircraft.getCallsign();
|
||||||
|
}
|
||||||
|
|
||||||
CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const
|
CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lockAircraft);
|
QReadLocker l(&m_lockAircraft);
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ namespace BlackCore
|
|||||||
virtual ~CContextOwnAircraft() override;
|
virtual ~CContextOwnAircraft() override;
|
||||||
|
|
||||||
// IOwnAircraftProvider overrides
|
// IOwnAircraftProvider overrides
|
||||||
|
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnCallsign
|
||||||
|
//! \ingroup ownaircraftprovider
|
||||||
|
virtual BlackMisc::Aviation::CCallsign getOwnCallsign() const override;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftPosition
|
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftPosition
|
||||||
//! \ingroup ownaircraftprovider
|
//! \ingroup ownaircraftprovider
|
||||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
// connect
|
// connect
|
||||||
connect(ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan, Qt::QueuedConnection);
|
connect(ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan, Qt::QueuedConnection);
|
||||||
connect(ui->pb_Load, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlanFromNetwork, Qt::QueuedConnection);
|
connect(ui->pb_Download, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlanFromNetwork, Qt::QueuedConnection);
|
||||||
connect(ui->pb_Reset, &QPushButton::pressed, this, &CFlightPlanComponent::resetFlightPlan, Qt::QueuedConnection);
|
connect(ui->pb_Reset, &QPushButton::pressed, this, &CFlightPlanComponent::resetFlightPlan, Qt::QueuedConnection);
|
||||||
connect(ui->pb_ValidateFlightPlan, &QPushButton::pressed, this, &CFlightPlanComponent::validateFlightPlan, Qt::QueuedConnection);
|
connect(ui->pb_ValidateFlightPlan, &QPushButton::pressed, this, &CFlightPlanComponent::validateFlightPlan, Qt::QueuedConnection);
|
||||||
connect(ui->tb_SyncWithSimulator, &QPushButton::released, this, &CFlightPlanComponent::syncWithSimulator, Qt::QueuedConnection);
|
connect(ui->tb_SyncWithSimulator, &QPushButton::released, this, &CFlightPlanComponent::syncWithSimulator, Qt::QueuedConnection);
|
||||||
@@ -273,7 +273,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (!flightPlan.getRemarks().isEmpty())
|
if (!flightPlan.getRemarks().isEmpty())
|
||||||
{
|
{
|
||||||
this->setRemarksUIValues(flightPlan.getRemarks());
|
const QString rem = flightPlan.getRemarks();
|
||||||
|
this->setRemarksUIValues(rem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,7 +953,7 @@ namespace BlackGui
|
|||||||
else if (remarks.contains("/T"))
|
else if (remarks.contains("/T"))
|
||||||
{
|
{
|
||||||
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilitiesFirstPage, "TEXT ONLY");
|
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilitiesFirstPage, "TEXT ONLY");
|
||||||
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilities, "FULL");
|
CGuiUtility::setComboBoxValueByContainingString(ui->cb_VoiceCapabilities, "TEXT ONLY");
|
||||||
}
|
}
|
||||||
else if (remarks.contains("/R"))
|
else if (remarks.contains("/R"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-15</y>
|
<y>0</y>
|
||||||
<width>371</width>
|
<width>371</width>
|
||||||
<height>504</height>
|
<height>504</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -696,7 +696,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QPushButton" name="pb_Load">
|
<widget class="QPushButton" name="pb_Download">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Load flight plan from network</string>
|
<string>Load flight plan from network</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -250,11 +250,13 @@ namespace BlackGui
|
|||||||
if (!box) { return false; }
|
if (!box) { return false; }
|
||||||
if (!candidate.isEmpty())
|
if (!candidate.isEmpty())
|
||||||
{
|
{
|
||||||
|
const int ci = box->currentIndex();
|
||||||
for (int i = 0; i < box->count(); i++)
|
for (int i = 0; i < box->count(); i++)
|
||||||
{
|
{
|
||||||
const QString t(box->itemText(i));
|
const QString t(box->itemText(i));
|
||||||
if (t.contains(candidate, Qt::CaseInsensitive))
|
if (t.contains(candidate, Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
|
if (ci == i) { return true; } // avoid signals
|
||||||
box->setCurrentIndex(i);
|
box->setCurrentIndex(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -263,11 +265,13 @@ namespace BlackGui
|
|||||||
|
|
||||||
// not found
|
// not found
|
||||||
if (unspecified.isEmpty()) { return false; }
|
if (unspecified.isEmpty()) { return false; }
|
||||||
|
const int ci = box->currentIndex();
|
||||||
for (int i = 0; i < box->count(); i++)
|
for (int i = 0; i < box->count(); i++)
|
||||||
{
|
{
|
||||||
const QString t(box->itemText(i));
|
const QString t(box->itemText(i));
|
||||||
if (t.contains(unspecified, Qt::CaseInsensitive))
|
if (t.contains(unspecified, Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
|
if (ci == i) { return true; } // avoid signals
|
||||||
box->setCurrentIndex(i);
|
box->setCurrentIndex(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ namespace BlackMisc
|
|||||||
return this->provider()->getOwnAircraft();
|
return this->provider()->getOwnAircraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCallsign COwnAircraftAware::getOwnCallsign() const
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||||
|
return this->provider()->getOwnCallsign();
|
||||||
|
}
|
||||||
|
|
||||||
CCoordinateGeodetic COwnAircraftAware::getOwnAircraftPosition() const
|
CCoordinateGeodetic COwnAircraftAware::getOwnAircraftPosition() const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "blackmisc/aviation/airlineicaocode.h"
|
#include "blackmisc/aviation/airlineicaocode.h"
|
||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/aviation/selcal.h"
|
#include "blackmisc/aviation/selcal.h"
|
||||||
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "blackmisc/geo/coordinategeodetic.h"
|
#include "blackmisc/geo/coordinategeodetic.h"
|
||||||
#include "blackmisc/pq/frequency.h"
|
#include "blackmisc/pq/frequency.h"
|
||||||
#include "blackmisc/pq/length.h"
|
#include "blackmisc/pq/length.h"
|
||||||
@@ -33,7 +34,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
class CAircraftIcaoCode;
|
class CAircraftIcaoCode;
|
||||||
class CAircraftSituation;
|
class CAircraftSituation;
|
||||||
class CCallsign;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
@@ -46,6 +46,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual CSimulatedAircraft getOwnAircraft() const = 0;
|
virtual CSimulatedAircraft getOwnAircraft() const = 0;
|
||||||
|
|
||||||
|
//! Own aircraft's callsign
|
||||||
|
//! \threadsafe
|
||||||
|
virtual Aviation::CCallsign getOwnCallsign() const = 0;
|
||||||
|
|
||||||
//! Own aircraft COM unit
|
//! Own aircraft COM unit
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const = 0;
|
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const = 0;
|
||||||
@@ -129,6 +133,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||||
CSimulatedAircraft getOwnAircraft() const;
|
CSimulatedAircraft getOwnAircraft() const;
|
||||||
|
|
||||||
|
//! \copydoc IOwnAircraftProvider::getOwnCallsign
|
||||||
|
Aviation::CCallsign getOwnCallsign() const;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
||||||
BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const;
|
BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ namespace BlackMisc
|
|||||||
return m_ownAircraft;
|
return m_ownAircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCallsign COwnAircraftProviderDummy::getOwnCallsign() const
|
||||||
|
{
|
||||||
|
QReadLocker l(&m_lock);
|
||||||
|
return m_ownAircraft.getCallsign();
|
||||||
|
}
|
||||||
|
|
||||||
CComSystem COwnAircraftProviderDummy::getOwnComSystem(CComSystem::ComUnit unit) const
|
CComSystem COwnAircraftProviderDummy::getOwnComSystem(CComSystem::ComUnit unit) const
|
||||||
{
|
{
|
||||||
QReadLocker l(&m_lock);
|
QReadLocker l(&m_lock);
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||||
virtual CSimulatedAircraft getOwnAircraft() const override;
|
virtual CSimulatedAircraft getOwnAircraft() const override;
|
||||||
|
|
||||||
|
//! \copydoc IOwnAircraftProvider::getOwnCallsign
|
||||||
|
virtual Aviation::CCallsign getOwnCallsign() const override;
|
||||||
|
|
||||||
//! \copydoc IOwnAircraftProvider::getOwnComSystem
|
//! \copydoc IOwnAircraftProvider::getOwnComSystem
|
||||||
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const override;
|
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user