refactor: Remove vPilot flight plan import

vPilot 3.8.0 removed the flight plan dialog. For simplification, we also stop supporting the vPilot flight plan format.
This commit is contained in:
Lars Toenning
2024-04-22 22:43:36 +02:00
parent b39e8c3a7e
commit 178a110343
3 changed files with 1 additions and 59 deletions

View File

@@ -547,7 +547,7 @@ namespace BlackGui::Components
void CFlightPlanComponent::loadFromDisk() void CFlightPlanComponent::loadFromDisk()
{ {
CStatusMessageList msgs; CStatusMessageList msgs;
const QString fileName = QFileDialog::getOpenFileName(this, tr("Load flight plan"), this->getDefaultFilename(true), "Flight plans (*.json *.sfp *.vfp *.xml);;swift (*.json *.txt);;SimBrief (*.xml);;vPilot (*.vfp);;SB4 (*.sfp)"); const QString fileName = QFileDialog::getOpenFileName(this, tr("Load flight plan"), this->getDefaultFilename(true), "Flight plans (*.json *.sfp *.xml);;swift (*.json *.txt);;SimBrief (*.xml);;SB4 (*.sfp)");
if (fileName.isEmpty()) { return; } if (fileName.isEmpty()) { return; }
CFlightPlan fp = CFlightPlan::loadFromMultipleFormats(fileName, &msgs); CFlightPlan fp = CFlightPlan::loadFromMultipleFormats(fileName, &msgs);
if (!fp.hasCallsign()) { fp.setCallsign(ui->le_Callsign->text()); } // set callsign if it wasn't set if (!fp.hasCallsign()) { fp.setCallsign(ui->le_Callsign->text()); } // set callsign if it wasn't set

View File

@@ -330,59 +330,6 @@ namespace BlackMisc::Aviation
return s; return s;
} }
CFlightPlan CFlightPlan::fromVPilotFormat(const QString &vPilotData)
{
if (vPilotData.isEmpty()) { return CFlightPlan(); }
QDomDocument doc;
doc.setContent(vPilotData);
const QDomElement fpDom = doc.firstChildElement();
const QString type = fpDom.attribute("FlightType");
CFlightPlan fp;
fp.setFlightRule(CFlightPlan::stringToFlightRules(type));
const int airspeedKts = fpDom.attribute("CruiseSpeed").toInt();
const CSpeed airspeed(airspeedKts, CSpeedUnit::kts());
fp.setCruiseTrueAirspeed(airspeed);
fp.setOriginAirportIcao(fpDom.attribute("DepartureAirport"));
fp.setDestinationAirportIcao(fpDom.attribute("DestinationAirport"));
fp.setAlternateAirportIcao(fpDom.attribute("AlternateAirport"));
fp.setRemarks(fpDom.attribute("Remarks"));
fp.setRoute(fpDom.attribute("Route"));
const QString voice = fpDom.attribute("VoiceType");
fp.setVoiceCapabilities(voice);
// Ignoring equipment prefix, suffix and IsHeavy flag
const int fuelMins = fpDom.attribute("FuelMinutes").toInt() + 60 * fpDom.attribute("FuelHours").toInt();
const CTime fuelTime(fuelMins, CTimeUnit::min());
const int enrouteMins = fpDom.attribute("EnrouteMinutes").toInt() + 60 * fpDom.attribute("EnrouteHours").toInt();
const CTime enrouteTime(enrouteMins, CTimeUnit::min());
const QString altStr = fpDom.attribute("CruiseAltitude");
CAltitude alt(altStr.length() < 4 ? "FL" + altStr : altStr + "ft");
alt.toFlightLevel();
fp.setCruiseAltitude(alt);
fp.setFuelTime(fuelTime);
fp.setEnrouteTime(enrouteTime);
const QString departureTime = fpDom.attribute("DepartureTime");
if (departureTime.length() == 4)
{
CTime depTime;
if (depTime.parseFromString_hhmm(departureTime))
{
fp.setTakeoffTimePlanned(depTime.toQDateTime());
}
}
return fp;
}
CFlightPlan CFlightPlan::fromSB4Format(const QString &sbData) CFlightPlan CFlightPlan::fromSB4Format(const QString &sbData)
{ {
if (sbData.isEmpty()) { return CFlightPlan(); } if (sbData.isEmpty()) { return CFlightPlan(); }
@@ -554,7 +501,6 @@ namespace BlackMisc::Aviation
} }
if (data.contains("[SBFlightPlan]", Qt::CaseInsensitive)) { return CFlightPlan::fromSB4Format(data); } if (data.contains("[SBFlightPlan]", Qt::CaseInsensitive)) { return CFlightPlan::fromSB4Format(data); }
if (data.contains("<FlightPlan", Qt::CaseInsensitive) && data.contains("<?xml", Qt::CaseInsensitive)) { return CFlightPlan::fromVPilotFormat(data); }
return CFlightPlan::fromJson(data); return CFlightPlan::fromJson(data);
} }
@@ -600,7 +546,6 @@ namespace BlackMisc::Aviation
} }
if (fileName.endsWith(".sfp", Qt::CaseInsensitive)) { return CFlightPlan::fromSB4Format(data); } if (fileName.endsWith(".sfp", Qt::CaseInsensitive)) { return CFlightPlan::fromSB4Format(data); }
if (fileName.endsWith(".vfp", Qt::CaseInsensitive)) { return CFlightPlan::fromVPilotFormat(data); }
if (fileName.endsWith(".json", Qt::CaseInsensitive)) if (fileName.endsWith(".json", Qt::CaseInsensitive))
{ {
do do

View File

@@ -375,9 +375,6 @@ namespace BlackMisc::Aviation
//! As HTML //! As HTML
QString asHTML(bool i18n = false) const; QString asHTML(bool i18n = false) const;
//! From vPilot data
static CFlightPlan fromVPilotFormat(const QString &vPilotData);
//! From SB4 data //! From SB4 data
static CFlightPlan fromSB4Format(const QString &sbData); static CFlightPlan fromSB4Format(const QString &sbData);