mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T417, FP UI allow SimBrief download
This commit is contained in:
committed by
Mat Sutcliffe
parent
179cdb1b6d
commit
f827cfc5cd
@@ -8,8 +8,9 @@
|
||||
|
||||
#include "flightplancomponent.h"
|
||||
#include "altitudedialog.h"
|
||||
#include "selcalcodeselector.h"
|
||||
#include "stringlistdialog.h"
|
||||
#include "simbriefdownloaddialog.h"
|
||||
#include "selcalcodeselector.h"
|
||||
#include "blackgui/uppercasevalidator.h"
|
||||
#include "blackgui/eventfilter.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
@@ -120,8 +121,9 @@ namespace BlackGui
|
||||
connect(ui->pb_Load, &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->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);
|
||||
@@ -929,6 +931,52 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::loadFromSimBrief()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!m_simBriefDialog)
|
||||
{
|
||||
m_simBriefDialog = new CSimBriefDownloadDialog(this);
|
||||
}
|
||||
const int rv = m_simBriefDialog->exec();
|
||||
if (rv != QDialog::Accepted) { return; }
|
||||
|
||||
const CUrl url = m_simBriefDialog->getSimBriefData().getUrlAndUsername();
|
||||
sApp->getFromNetwork(url.toNetworkRequest(), { this, &CFlightPlanComponent::handleSimBriefResponse });
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::handleSimBriefResponse(QNetworkReply *nwReplyPtr)
|
||||
{
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
const QUrl url(nwReply->url());
|
||||
const QString urlString(url.toString());
|
||||
|
||||
if (nwReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
// const qint64 lastModified = CNetworkUtils::lastModifiedMsSinceEpoch(nwReply.data());
|
||||
const QString simBriefFP(nwReplyPtr->readAll());
|
||||
nwReplyPtr->close();
|
||||
if (simBriefFP.isEmpty())
|
||||
{
|
||||
this->showOverlayHTMLMessage("No SimBrief data from " % urlString);
|
||||
}
|
||||
else
|
||||
{
|
||||
CFlightPlan fp = CFlightPlan::fromSimBriefFormat(simBriefFP);
|
||||
this->fillWithFlightPlanData(fp);
|
||||
}
|
||||
} // no error
|
||||
else
|
||||
{
|
||||
// network error, try next URL
|
||||
nwReply->abort();
|
||||
}
|
||||
}
|
||||
|
||||
bool CFlightPlanComponent::consolidateRemarks(QStringList &remarks, const QString &newRemarks)
|
||||
{
|
||||
if (newRemarks.isEmpty()) { return false; }
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QTabWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QFileDialog>
|
||||
#include <QNetworkReply>
|
||||
|
||||
namespace Ui { class CFlightPlanComponent; }
|
||||
namespace BlackGui
|
||||
@@ -62,6 +63,7 @@ namespace BlackGui
|
||||
|
||||
class CStringListDialog;
|
||||
class CAltitudeDialog;
|
||||
class CSimBriefDownloadDialog;
|
||||
|
||||
//! Flight plan widget
|
||||
class BLACKGUI_EXPORT CFlightPlanComponent : public COverlayMessagesTabWidget
|
||||
@@ -90,9 +92,10 @@ namespace BlackGui
|
||||
private:
|
||||
static constexpr int OverlayTimeoutMs = 5000;
|
||||
QScopedPointer<Ui::CFlightPlanComponent> ui;
|
||||
CAltitudeDialog *m_altitudeDialog = nullptr;
|
||||
CStringListDialog *m_fpRemarksDialog = nullptr;
|
||||
BlackMisc::Aviation::CFlightPlan m_sentFlightPlan; //!< My flight plan
|
||||
CAltitudeDialog *m_altitudeDialog = nullptr;
|
||||
CStringListDialog *m_fpRemarksDialog = nullptr;
|
||||
CSimBriefDownloadDialog *m_simBriefDialog = nullptr;
|
||||
BlackMisc::Aviation::CFlightPlan m_sentFlightPlan; //!< my flight plan
|
||||
BlackMisc::Simulation::CAircraftModel m_model; //!< currently used model
|
||||
BlackMisc::CIdentifier m_identifier { "FlightPlanComponent", this }; //!< Flightplan identifier
|
||||
BlackMisc::CSetting<BlackMisc::Settings::TDirectorySettings> m_directories { this }; //!< the swift directories
|
||||
@@ -221,6 +224,12 @@ namespace BlackGui
|
||||
//! Update the remarks histories
|
||||
void updateRemarksHistories();
|
||||
|
||||
//! Load from SimBrief
|
||||
void loadFromSimBrief();
|
||||
|
||||
//! Response from SimBrief
|
||||
void handleSimBriefResponse(QNetworkReply *nwReplyPtr);
|
||||
|
||||
//! Consolidate the new remarks list, latest on front
|
||||
static bool consolidateRemarks(QStringList &remarks, const QString &newRemarks);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -488,7 +488,21 @@ namespace BlackMisc
|
||||
const QString flightNumber = general.firstChildElement("flight_number").text();
|
||||
fp.setCallsign(CCallsign(airline + flightNumber, CCallsign::Aircraft));
|
||||
const QString cruiseAlt = general.firstChildElement("initial_altitude").text();
|
||||
fp.setCruiseAltitudeString(cruiseAlt);
|
||||
const int cruiseAltFt = cruiseAlt.toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
CAltitude ca(cruiseAltFt, CAltitude::MeanSeaLevel, CLengthUnit::ft());
|
||||
if (cruiseAlt.endsWith("00") && cruiseAltFt > 5000)
|
||||
{
|
||||
ca.toFlightLevel();
|
||||
}
|
||||
fp.setCruiseAltitude(ca);
|
||||
if (cruiseAltFt >= 10000) { fp.setFlightRule(CFlightPlan::IFR); } // good guess
|
||||
}
|
||||
else
|
||||
{
|
||||
fp.setCruiseAltitudeString(cruiseAlt);
|
||||
}
|
||||
const QString tas = general.firstChildElement("cruise_tas").text();
|
||||
const int tasKts = tas.toInt(&ok);
|
||||
if (ok) { fp.setCruiseTrueAirspeed(CSpeed(tasKts, CSpeedUnit::kts())); }
|
||||
@@ -863,5 +877,6 @@ namespace BlackMisc
|
||||
{
|
||||
return CIcon::iconByIndex(CIcons::StandardIconAppFlightPlan16);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "callsign.h"
|
||||
#include "selcal.h"
|
||||
#include "blackmisc/network/voicecapabilities.h"
|
||||
#include "blackmisc/network/url.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
|
||||
Reference in New Issue
Block a user