Allow max. length of route and remarks combined

This commit is contained in:
Klaus Basan
2019-04-23 23:12:57 +02:00
parent 72ab9e7994
commit 3294a78fc4
3 changed files with 15 additions and 5 deletions

View File

@@ -319,6 +319,7 @@ namespace BlackGui
// route // route
v = ui->pte_Route->toPlainText().trimmed(); v = ui->pte_Route->toPlainText().trimmed();
const int routeLength = v.length();
if (v.isEmpty()) if (v.isEmpty())
{ {
messages.push_back(CStatusMessage(this).validation( messages.push_back(CStatusMessage(this).validation(
@@ -326,7 +327,7 @@ namespace BlackGui
CStatusMessage::SeverityInfo : CStatusMessage::SeverityInfo :
CStatusMessage::SeverityWarning, u"Missing '%1'") << ui->lbl_Route->text()); CStatusMessage::SeverityWarning, u"Missing '%1'") << ui->lbl_Route->text());
} }
else if (v.length() > CFlightPlan::MaxRouteLength) else if (routeLength > CFlightPlan::MaxRouteLength)
{ {
messages.push_back(CStatusMessage(this).validationError(u"Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength); messages.push_back(CStatusMessage(this).validationError(u"Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength);
} }
@@ -337,11 +338,12 @@ namespace BlackGui
// remarks // remarks
v = ui->pte_Remarks->toPlainText().trimmed(); v = ui->pte_Remarks->toPlainText().trimmed();
const int remarksLength = v.length();
if (v.isEmpty()) if (v.isEmpty())
{ {
messages.push_back(CStatusMessage(this).validationError(u"No '%1', voice capabilities are mandatory") << ui->pb_Remarks->text()); messages.push_back(CStatusMessage(this).validationError(u"No '%1', voice capabilities are mandatory") << ui->pb_Remarks->text());
} }
else if (v.length() > CFlightPlan::MaxRemarksLength) else if (remarksLength > CFlightPlan::MaxRemarksLength)
{ {
messages.push_back(CStatusMessage(this).validationError(u"Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength); messages.push_back(CStatusMessage(this).validationError(u"Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength);
} }
@@ -350,6 +352,12 @@ namespace BlackGui
flightPlan.setRemarks(v); flightPlan.setRemarks(v);
} }
// Total length
if ((remarksLength + routeLength) > CFlightPlan::MaxRouteAndRemarksLength)
{
messages.push_back(CStatusMessage(this).validationError(u"Flight plan route (%1) and remarks (%2) length exceeded (%3 chars max.)") << routeLength << remarksLength << CFlightPlan::MaxRemarksLength);
}
// time enroute // time enroute
v = ui->le_EstimatedTimeEnroute->text(); v = ui->le_EstimatedTimeEnroute->text();
if (v.isEmpty() || v == defaultTime()) if (v.isEmpty() || v == defaultTime())

View File

@@ -73,7 +73,7 @@ namespace BlackGui
explicit CFlightPlanComponent(QWidget *parent = nullptr); explicit CFlightPlanComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CFlightPlanComponent(); virtual ~CFlightPlanComponent() override;
//! Login data were set //! Login data were set
void loginDataSet(); void loginDataSet();

View File

@@ -171,8 +171,10 @@ namespace BlackMisc
//! \fixme max.length of complete flight plan is 768 characters, this here is an assumption and should be part of the underlying network layers //! \fixme max.length of complete flight plan is 768 characters, this here is an assumption and should be part of the underlying network layers
// https://forums.vatsim.net/viewtopic.php?f=6&t=63416 // https://forums.vatsim.net/viewtopic.php?f=6&t=63416
static constexpr int MaxRemarksLength = 256; //!< Max.remarks length static constexpr int MaxRemarksLength = 512; //!< Max.remarks length
static constexpr int MaxRouteLength = 256; //!< Max.route length static constexpr int MaxRouteLength = 512; //!< Max.route length
static constexpr int MaxRouteAndRemarksLength = 624; //!< Max.length for Route and Remarks
//! Default constructor //! Default constructor
CFlightPlan(); CFlightPlan();