mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
refs #316 Blackgui changes: using CLogMessage and removed sendStatusMessage signals.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "flightplancomponent.h"
|
||||
#include "ui_flightplancomponent.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -107,20 +108,17 @@ namespace BlackGui
|
||||
v = ui->le_Callsign->text().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_Callsign->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_Callsign->text());
|
||||
}
|
||||
|
||||
v = ui->pte_Route->toPlainText().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("Missing flight plan route");
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing flight plan route"));
|
||||
}
|
||||
else if (v.length() > CFlightPlan::MaxRouteLength)
|
||||
{
|
||||
QString m = QString("Flight plan route length exceeded (%1 chars max.)").arg(CFlightPlan::MaxRouteLength);
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength);
|
||||
}
|
||||
else
|
||||
flightPlan.setRoute(v);
|
||||
@@ -128,13 +126,11 @@ namespace BlackGui
|
||||
v = ui->pte_Remarks->toPlainText().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("No remarks, voice capabilities are mandatory");
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "No remarks, voice capabilities are mandatory"));
|
||||
}
|
||||
else if (v.length() > CFlightPlan::MaxRemarksLength)
|
||||
{
|
||||
QString m = QString("Flight plan remarks length exceeded (%1 chars max.)").arg(CFlightPlan::MaxRemarksLength);
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength);
|
||||
}
|
||||
else
|
||||
flightPlan.setRemarks(v);
|
||||
@@ -142,8 +138,7 @@ namespace BlackGui
|
||||
v = ui->le_EstimatedTimeEnroute->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_EstimatedTimeEnroute->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_EstimatedTimeEnroute->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setEnrouteTime(v);
|
||||
@@ -151,8 +146,7 @@ namespace BlackGui
|
||||
v = ui->le_FuelOnBoard->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_FuelOnBorad->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_FuelOnBorad->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setFuelTime(v);
|
||||
@@ -160,8 +154,7 @@ namespace BlackGui
|
||||
v = ui->le_TakeOffTimePlanned->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_TakeOffTimePlanned->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_TakeOffTimePlanned->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setTakeoffTimePlanned(v);
|
||||
@@ -177,8 +170,7 @@ namespace BlackGui
|
||||
CAltitude cruisingAltitude(v, CPqString::SeparatorsLocale);
|
||||
if (v.isEmpty() || cruisingAltitude.isNull())
|
||||
{
|
||||
QString m = QString("Wrong %1").arg(this->ui->lbl_CrusingAltitude->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong %1") << this->ui->lbl_CrusingAltitude->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setCruiseAltitude(cruisingAltitude);
|
||||
@@ -186,8 +178,7 @@ namespace BlackGui
|
||||
v = this->ui->le_AlternateAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_AlternateAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_AlternateAirport->text());
|
||||
flightPlan.setAlternateAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -196,8 +187,7 @@ namespace BlackGui
|
||||
v = this->ui->le_DestinationAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_DestinationAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_DestinationAirport->text());
|
||||
flightPlan.setDestinationAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -208,8 +198,7 @@ namespace BlackGui
|
||||
cruiseTAS.parseFromString(v, CPqString::SeparatorsLocale);
|
||||
if (cruiseTAS.isNull())
|
||||
{
|
||||
QString m = QString("Wrong TAS, %1").arg(this->ui->lbl_CruiseTrueAirspeed->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong TAS, %1") << this->ui->lbl_CruiseTrueAirspeed->text());
|
||||
flightPlan.setDestinationAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -218,8 +207,7 @@ namespace BlackGui
|
||||
v = this->ui->le_OriginAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_OriginAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_OriginAirport->text());
|
||||
flightPlan.setOriginAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -235,41 +223,27 @@ namespace BlackGui
|
||||
if (messages.isEmpty())
|
||||
{
|
||||
// no error, send if possible
|
||||
CStatusMessage m;
|
||||
if (this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
flightPlan.setWhenLastSentOrLoaded(QDateTime::currentDateTimeUtc());
|
||||
this->getIContextNetwork()->sendFlightPlan(flightPlan);
|
||||
this->ui->le_LastSent->setText(flightPlan.whenLastSentOrLoaded().toString());
|
||||
m = CStatusMessage::getInfoMessage("Sent flight plan", CStatusMessage::TypeTrafficNetwork);
|
||||
CLogMessage().info(this, "Sent flight plan");
|
||||
}
|
||||
else
|
||||
{
|
||||
flightPlan.setWhenLastSentOrLoaded(QDateTime()); // empty
|
||||
this->ui->le_LastSent->clear();
|
||||
m = CStatusMessage::getErrorMessage("No errors, but not connected, cannot send flight plan", CStatusMessage::TypeTrafficNetwork);
|
||||
CLogMessage().error(this, "No errors, but not connected, cannot send flight plan");
|
||||
}
|
||||
this->sendStatusMessage(m);
|
||||
this->m_flightPlan = flightPlan; // last valid FP
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessages(messages);
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::validateFlightPlan()
|
||||
{
|
||||
CFlightPlan flightPlan;
|
||||
CStatusMessageList messages = this->validateAndInitializeFlightPlan(flightPlan);
|
||||
if (messages.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("No errors", CStatusMessage::TypeTrafficNetwork));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessages(messages);
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::resetFlightPlan()
|
||||
@@ -296,12 +270,12 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextNetwork())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Cannot load flight plan, network not available", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Cannot load flight plan, network not available");
|
||||
return;
|
||||
}
|
||||
if (!this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getWarningMessage("Cannot load flight plan, network not connected", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().warning(this, "Cannot load flight plan, network not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,11 +284,11 @@ namespace BlackGui
|
||||
if (loadedPlan.wasSentOrLoaded())
|
||||
{
|
||||
this->fillWithFlightPlanData(loadedPlan);
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Updated with loaded flight plan", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Updated with loaded flight plan");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getWarningMessage("No flight plan data", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().warning(this, "No flight plan data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +368,7 @@ namespace BlackGui
|
||||
void CFlightPlanComponent::copyRemarks()
|
||||
{
|
||||
this->ui->pte_Remarks->setPlainText(this->ui->pte_RemarksGenerated->toPlainText());
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Copied remarks", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Copied remarks");
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::currentTabGenerator()
|
||||
|
||||
Reference in New Issue
Block a user