mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #576, fixed livery filtering and editing
* fixed selector by stripping extra info before selecting * correct reset of filter UI * return livery object directly from form if already valid DB object
This commit is contained in:
@@ -91,9 +91,19 @@ namespace BlackGui
|
||||
CLivery CDbLiverySelectorComponent::getLivery() const
|
||||
{
|
||||
if (!hasProvider()) { return CLivery(); }
|
||||
QString liveryCode(this->ui->le_Livery->text().trimmed().toUpper());
|
||||
CLivery d(getLiveries().findByCombinedCode(liveryCode));
|
||||
return d;
|
||||
const QString liveryCode(
|
||||
this->stripExtraInfo(this->ui->le_Livery->text())
|
||||
);
|
||||
const CLivery liv(getLiveries().findByCombinedCode(liveryCode));
|
||||
if (liv.hasCompleteData() && liv.hasValidDbKey())
|
||||
{
|
||||
// full data fetched
|
||||
return liv;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->m_currentLivery;
|
||||
}
|
||||
}
|
||||
|
||||
void CDbLiverySelectorComponent::setReadOnly(bool readOnly)
|
||||
@@ -183,10 +193,12 @@ namespace BlackGui
|
||||
void CDbLiverySelectorComponent::ps_dataChanged()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
QString code(this->ui->le_Livery->text().trimmed().toUpper());
|
||||
const QString code(
|
||||
this->stripExtraInfo(this->ui->le_Livery->text())
|
||||
);
|
||||
if (code.isEmpty()) { return; }
|
||||
CLivery d(this->getLiveries().findByCombinedCode(code));
|
||||
this->setLivery(d);
|
||||
const CLivery livery(this->getLiveries().findByCombinedCode(code));
|
||||
this->setLivery(livery);
|
||||
}
|
||||
|
||||
void CDbLiverySelectorComponent::ps_completerActivated(const QString &liveryCode)
|
||||
@@ -194,5 +206,16 @@ namespace BlackGui
|
||||
this->setlivery(liveryCode);
|
||||
}
|
||||
|
||||
QString CDbLiverySelectorComponent::stripExtraInfo(const QString &liveryCode) const
|
||||
{
|
||||
if (liveryCode.isEmpty()) { return ""; }
|
||||
const QString l(liveryCode.trimmed().toUpper());
|
||||
int is = l.indexOf(' ');
|
||||
int ib = l.indexOf('(');
|
||||
int i = qMin(is, ib);
|
||||
if (i < 0) { return l; }
|
||||
return l.left(i);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace BlackGui
|
||||
void ps_completerActivated(const QString &liveryCode);
|
||||
|
||||
private:
|
||||
//! Strip extra info from livery code
|
||||
QString stripExtraInfo(const QString &liveryCode) const;
|
||||
|
||||
QScopedPointer<Ui::CDbLiverySelectorComponent> ui;
|
||||
QScopedPointer<QCompleter> m_completerLiveries;
|
||||
QMetaObject::Connection m_signalConnection;
|
||||
|
||||
@@ -53,6 +53,12 @@ namespace BlackGui
|
||||
CLivery CLiveryForm::getValue() const
|
||||
{
|
||||
CLivery livery(this->ui->livery_Selector->getLivery());
|
||||
if (livery.hasCompleteData() && livery.hasValidDbKey())
|
||||
{
|
||||
// already complete data from selector
|
||||
return livery;
|
||||
}
|
||||
|
||||
CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue());
|
||||
livery.setAirlineIcaoCode(airline);
|
||||
livery.setDescription(this->ui->le_Description->text());
|
||||
|
||||
@@ -96,6 +96,8 @@ namespace BlackGui
|
||||
ui->color_Fuselage->clear();
|
||||
ui->color_Tail->clear();
|
||||
ui->hs_ColorDistance->setValue(0.25 * 100.0);
|
||||
ui->cb_Airlines->setChecked(true);
|
||||
ui->cb_Colors->setChecked(true);
|
||||
}
|
||||
|
||||
void CLiveryFilterBar::ps_colorChanged(const BlackMisc::CRgbColor &color)
|
||||
|
||||
@@ -175,8 +175,15 @@ namespace BlackMisc
|
||||
bool CLivery::isValidCombinedCode(const QString &candidate)
|
||||
{
|
||||
if (candidate.isEmpty()) { return false; }
|
||||
if (candidate.count('.') != 1) { return false; }
|
||||
return candidate.length() > 2;
|
||||
if (candidate.startsWith(colorLiveryMarker()))
|
||||
{
|
||||
return candidate.length() > colorLiveryMarker().length() + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (candidate.count('.') != 1) { return false; }
|
||||
return candidate.length() > 2;
|
||||
}
|
||||
}
|
||||
|
||||
const QString &CLivery::standardLiveryMarker()
|
||||
|
||||
Reference in New Issue
Block a user