mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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:
committed by
Mat Sutcliffe
parent
891a058f17
commit
ea7b3316c9
@@ -160,14 +160,17 @@ namespace BlackCore
|
||||
|
||||
// use cache, but not for own callsign (always reload)
|
||||
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);
|
||||
|
||||
// with this little trick we try to make an asynchronous signal / slot
|
||||
// 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)
|
||||
{
|
||||
// process some other events and hope network answer is received already
|
||||
|
||||
@@ -109,6 +109,12 @@ namespace BlackCore
|
||||
return m_ownAircraft.getTransponder();
|
||||
}
|
||||
|
||||
CCallsign CContextOwnAircraft::getOwnCallsign() const
|
||||
{
|
||||
QReadLocker l(&m_lockAircraft);
|
||||
return m_ownAircraft.getCallsign();
|
||||
}
|
||||
|
||||
CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const
|
||||
{
|
||||
QReadLocker l(&m_lockAircraft);
|
||||
|
||||
@@ -81,6 +81,10 @@ namespace BlackCore
|
||||
virtual ~CContextOwnAircraft() override;
|
||||
|
||||
// IOwnAircraftProvider overrides
|
||||
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnCallsign
|
||||
//! \ingroup ownaircraftprovider
|
||||
virtual BlackMisc::Aviation::CCallsign getOwnCallsign() const override;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftPosition
|
||||
//! \ingroup ownaircraftprovider
|
||||
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;
|
||||
|
||||
@@ -122,15 +122,15 @@ namespace BlackGui
|
||||
|
||||
// connect
|
||||
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_ValidateFlightPlan, &QPushButton::pressed, this, &CFlightPlanComponent::validateFlightPlan, Qt::QueuedConnection);
|
||||
connect(ui->tb_SyncWithSimulator, &QPushButton::released, this, &CFlightPlanComponent::syncWithSimulator, Qt::QueuedConnection);
|
||||
connect(ui->pb_Prefill, &QPushButton::pressed, this, &CFlightPlanComponent::anticipateValues, Qt::QueuedConnection);
|
||||
connect(ui->pb_SimBrief, &QPushButton::pressed, this, &CFlightPlanComponent::loadFromSimBrief, Qt::QueuedConnection);
|
||||
|
||||
connect(ui->cb_VoiceCapabilities, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::currentTextChangedToBuildRemarks, Qt::QueuedConnection);
|
||||
connect(ui->cb_VoiceCapabilities, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::syncVoiceComboBoxes, Qt::QueuedConnection);
|
||||
connect(ui->cb_VoiceCapabilities, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::currentTextChangedToBuildRemarks, Qt::QueuedConnection);
|
||||
connect(ui->cb_VoiceCapabilities, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::syncVoiceComboBoxes, Qt::QueuedConnection);
|
||||
connect(ui->cb_VoiceCapabilitiesFirstPage, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::syncVoiceComboBoxes, Qt::QueuedConnection);
|
||||
connect(ui->cb_NavigationEquipment, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::currentTextChangedToBuildRemarks, Qt::QueuedConnection);
|
||||
connect(ui->cb_PerformanceCategory, &QComboBox::currentTextChanged, this, &CFlightPlanComponent::currentTextChangedToBuildRemarks, Qt::QueuedConnection);
|
||||
@@ -273,7 +273,8 @@ namespace BlackGui
|
||||
|
||||
if (!flightPlan.getRemarks().isEmpty())
|
||||
{
|
||||
this->setRemarksUIValues(flightPlan.getRemarks());
|
||||
const QString rem = flightPlan.getRemarks();
|
||||
this->setRemarksUIValues(rem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +288,7 @@ namespace BlackGui
|
||||
{
|
||||
CStatusMessageList messages;
|
||||
const bool strict = ui->cb_StrictCheck->isChecked();
|
||||
const bool vfr = this->isVfr();
|
||||
const bool vfr = this->isVfr();
|
||||
const CStatusMessage::StatusSeverity severity = strict ? CStatusMessage::SeverityError : CStatusMessage::SeverityWarning;
|
||||
messages.push_back(CStatusMessage(this).validationInfo(strict ? QStringLiteral("Strict validation") : QStringLiteral("Lenient validation")));
|
||||
|
||||
@@ -952,7 +953,7 @@ namespace BlackGui
|
||||
else if (remarks.contains("/T"))
|
||||
{
|
||||
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"))
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-15</y>
|
||||
<y>0</y>
|
||||
<width>371</width>
|
||||
<height>504</height>
|
||||
</rect>
|
||||
@@ -696,7 +696,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pb_Load">
|
||||
<widget class="QPushButton" name="pb_Download">
|
||||
<property name="toolTip">
|
||||
<string>Load flight plan from network</string>
|
||||
</property>
|
||||
|
||||
@@ -250,11 +250,13 @@ namespace BlackGui
|
||||
if (!box) { return false; }
|
||||
if (!candidate.isEmpty())
|
||||
{
|
||||
const int ci = box->currentIndex();
|
||||
for (int i = 0; i < box->count(); i++)
|
||||
{
|
||||
const QString t(box->itemText(i));
|
||||
if (t.contains(candidate, Qt::CaseInsensitive))
|
||||
{
|
||||
if (ci == i) { return true; } // avoid signals
|
||||
box->setCurrentIndex(i);
|
||||
return true;
|
||||
}
|
||||
@@ -263,11 +265,13 @@ namespace BlackGui
|
||||
|
||||
// not found
|
||||
if (unspecified.isEmpty()) { return false; }
|
||||
const int ci = box->currentIndex();
|
||||
for (int i = 0; i < box->count(); i++)
|
||||
{
|
||||
const QString t(box->itemText(i));
|
||||
if (t.contains(unspecified, Qt::CaseInsensitive))
|
||||
{
|
||||
if (ci == i) { return true; } // avoid signals
|
||||
box->setCurrentIndex(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,12 @@ namespace BlackMisc
|
||||
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
|
||||
{
|
||||
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/aviation/selcal.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/pq/frequency.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
@@ -33,7 +34,6 @@ namespace BlackMisc
|
||||
{
|
||||
class CAircraftIcaoCode;
|
||||
class CAircraftSituation;
|
||||
class CCallsign;
|
||||
}
|
||||
|
||||
namespace Simulation
|
||||
@@ -46,6 +46,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
virtual CSimulatedAircraft getOwnAircraft() const = 0;
|
||||
|
||||
//! Own aircraft's callsign
|
||||
//! \threadsafe
|
||||
virtual Aviation::CCallsign getOwnCallsign() const = 0;
|
||||
|
||||
//! Own aircraft COM unit
|
||||
//! \threadsafe
|
||||
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const = 0;
|
||||
@@ -129,6 +133,9 @@ namespace BlackMisc
|
||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||
CSimulatedAircraft getOwnAircraft() const;
|
||||
|
||||
//! \copydoc IOwnAircraftProvider::getOwnCallsign
|
||||
Aviation::CCallsign getOwnCallsign() const;
|
||||
|
||||
//! \copydoc IOwnAircraftProvider::getOwnAircraftPosition
|
||||
BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const;
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace BlackMisc
|
||||
return m_ownAircraft;
|
||||
}
|
||||
|
||||
CCallsign COwnAircraftProviderDummy::getOwnCallsign() const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
return m_ownAircraft.getCallsign();
|
||||
}
|
||||
|
||||
CComSystem COwnAircraftProviderDummy::getOwnComSystem(CComSystem::ComUnit unit) const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace BlackMisc
|
||||
//! \copydoc IOwnAircraftProvider::getOwnAircraft
|
||||
virtual CSimulatedAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IOwnAircraftProvider::getOwnCallsign
|
||||
virtual Aviation::CCallsign getOwnCallsign() const override;
|
||||
|
||||
//! \copydoc IOwnAircraftProvider::getOwnComSystem
|
||||
virtual Aviation::CComSystem getOwnComSystem(Aviation::CComSystem::ComUnit unit) const override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user