mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
refs #576, no airline validation with color liveries and no exclusion of special designators
This commit is contained in:
@@ -58,7 +58,11 @@ namespace BlackGui
|
|||||||
void CDbLiverySelectorComponent::setLivery(const CLivery &livery)
|
void CDbLiverySelectorComponent::setLivery(const CLivery &livery)
|
||||||
{
|
{
|
||||||
QString code(livery.getCombinedCode());
|
QString code(livery.getCombinedCode());
|
||||||
if (code.isEmpty()) { return; }
|
if (code.isEmpty())
|
||||||
|
{
|
||||||
|
this->ui->le_Livery->clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (livery != m_currentLivery)
|
if (livery != m_currentLivery)
|
||||||
{
|
{
|
||||||
this->ui->le_Livery->setText(code);
|
this->ui->le_Livery->setText(code);
|
||||||
|
|||||||
@@ -79,17 +79,27 @@ namespace BlackGui
|
|||||||
this->ui->color_Fuselage->setColor(livery.getColorFuselage());
|
this->ui->color_Fuselage->setColor(livery.getColorFuselage());
|
||||||
this->ui->color_Tail->setColor(livery.getColorTail());
|
this->ui->color_Tail->setColor(livery.getColorTail());
|
||||||
|
|
||||||
|
if (livery.isColorLivery())
|
||||||
|
{
|
||||||
|
this->ui->editor_AirlineIcao->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
|
this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CStatusMessageList CLiveryForm::validate(bool withNestedForms) const
|
CStatusMessageList CLiveryForm::validate(bool withNestedForms) const
|
||||||
{
|
{
|
||||||
CLivery livery(getValue());
|
CLivery livery(getValue());
|
||||||
CStatusMessageList msgs(livery.validate());
|
CStatusMessageList msgs(livery.validate());
|
||||||
if (withNestedForms && (livery.hasValidDbKey() || !livery.getAirlineIcaoCodeDesignator().isEmpty()))
|
if (withNestedForms)
|
||||||
|
{
|
||||||
|
if (!livery.isColorLivery())
|
||||||
{
|
{
|
||||||
msgs.push_back(this->ui->editor_AirlineIcao->validate());
|
msgs.push_back(this->ui->editor_AirlineIcao->validate());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (this->isReadOnly())
|
if (this->isReadOnly())
|
||||||
{
|
{
|
||||||
// in readonly I cannot change the data anyway, so skip warnings
|
// in readonly I cannot change the data anyway, so skip warnings
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ namespace BlackMisc
|
|||||||
return (this->hasValidDesignator() && this->getDesignator() != getUnassignedDesignator());
|
return (this->hasValidDesignator() && this->getDesignator() != getUnassignedDesignator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAircraftIcaoCode::hasSpecialDesignator() const
|
||||||
|
{
|
||||||
|
if (!this->hasDesignator()) { return false; }
|
||||||
|
return getSpecialDesignators().contains(this->getDesignator());
|
||||||
|
}
|
||||||
|
|
||||||
bool CAircraftIcaoCode::isIataSameAsDesignator() const
|
bool CAircraftIcaoCode::isIataSameAsDesignator() const
|
||||||
{
|
{
|
||||||
return hasDesignator() && hasIataCode() && m_iataCode == m_designator;
|
return hasDesignator() && hasIataCode() && m_iataCode == m_designator;
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ namespace BlackMisc
|
|||||||
//! Has designator and designator is not "ZZZZ"
|
//! Has designator and designator is not "ZZZZ"
|
||||||
bool hasKnownDesignator() const;
|
bool hasKnownDesignator() const;
|
||||||
|
|
||||||
|
//! Special designator
|
||||||
|
bool hasSpecialDesignator() const;
|
||||||
|
|
||||||
//! IATA code
|
//! IATA code
|
||||||
const QString &getIataCode() const { return m_iataCode; }
|
const QString &getIataCode() const { return m_iataCode; }
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace BlackMisc
|
|||||||
for (const QJsonValue &value : array)
|
for (const QJsonValue &value : array)
|
||||||
{
|
{
|
||||||
CAircraftIcaoCode icao(CAircraftIcaoCode::fromDatabaseJson(value.toObject()));
|
CAircraftIcaoCode icao(CAircraftIcaoCode::fromDatabaseJson(value.toObject()));
|
||||||
if (ignoreIncomplete && !icao.hasCompleteData()) { continue; }
|
if (ignoreIncomplete && !icao.hasSpecialDesignator() && !icao.hasCompleteData()) { continue; }
|
||||||
codes.push_back(icao);
|
codes.push_back(icao);
|
||||||
}
|
}
|
||||||
return codes;
|
return codes;
|
||||||
|
|||||||
@@ -115,7 +115,18 @@ namespace BlackMisc
|
|||||||
if (!hasCombinedCode()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Livery: missing livery code")); }
|
if (!hasCombinedCode()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Livery: missing livery code")); }
|
||||||
if (!hasColorFuselage()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, "Livery: no fuselage color")); }
|
if (!hasColorFuselage()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, "Livery: no fuselage color")); }
|
||||||
if (!hasColorTail()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, "Livery: no tail color")); }
|
if (!hasColorTail()) { msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, "Livery: no tail color")); }
|
||||||
if (!getAirlineIcaoCodeDesignator().isEmpty()) { msg.push_back(m_airline.validate()); }
|
if (this->isColorLivery())
|
||||||
|
{
|
||||||
|
if (!this->getAirlineIcaoCodeDesignator().isEmpty())
|
||||||
|
{
|
||||||
|
// color livery, supposed to have empty airline
|
||||||
|
msg.push_back(CStatusMessage(cats, CStatusMessage::SeverityWarning, "Livery: color livery, but airline looks odd"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.push_back(m_airline.validate());
|
||||||
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,11 @@ namespace BlackMisc
|
|||||||
if (!model.getDistributor().hasValidDbKey()) { subMsgs << "No distributor from DB"; }
|
if (!model.getDistributor().hasValidDbKey()) { subMsgs << "No distributor from DB"; }
|
||||||
if (!model.getAircraftIcaoCode().hasValidDbKey()) { subMsgs << "No aircraft ICAO from DB"; }
|
if (!model.getAircraftIcaoCode().hasValidDbKey()) { subMsgs << "No aircraft ICAO from DB"; }
|
||||||
if (!model.getLivery().hasValidDbKey()) { subMsgs << "No livery from DB"; }
|
if (!model.getLivery().hasValidDbKey()) { subMsgs << "No livery from DB"; }
|
||||||
|
if (model.getLivery().isAirlineLivery())
|
||||||
|
{
|
||||||
|
// for color codes we do not need to check
|
||||||
if (!model.getLivery().getAirlineIcaoCode().hasValidDbKey()) { subMsgs << "No airline ICAO from DB"; }
|
if (!model.getLivery().getAirlineIcaoCode().hasValidDbKey()) { subMsgs << "No airline ICAO from DB"; }
|
||||||
|
}
|
||||||
CStatusMessage msgDb(CStatusMessage::SeverityError, subMsgs.join(", "));
|
CStatusMessage msgDb(CStatusMessage::SeverityError, subMsgs.join(", "));
|
||||||
|
|
||||||
CStatusMessage singleMsg(CStatusMessageList({msgModel, msgDb}).toSingleMessage());
|
CStatusMessage singleMsg(CStatusMessageList({msgModel, msgDb}).toSingleMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user