mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +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
|
CLivery CDbLiverySelectorComponent::getLivery() const
|
||||||
{
|
{
|
||||||
if (!hasProvider()) { return CLivery(); }
|
if (!hasProvider()) { return CLivery(); }
|
||||||
QString liveryCode(this->ui->le_Livery->text().trimmed().toUpper());
|
const QString liveryCode(
|
||||||
CLivery d(getLiveries().findByCombinedCode(liveryCode));
|
this->stripExtraInfo(this->ui->le_Livery->text())
|
||||||
return d;
|
);
|
||||||
|
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)
|
void CDbLiverySelectorComponent::setReadOnly(bool readOnly)
|
||||||
@@ -183,10 +193,12 @@ namespace BlackGui
|
|||||||
void CDbLiverySelectorComponent::ps_dataChanged()
|
void CDbLiverySelectorComponent::ps_dataChanged()
|
||||||
{
|
{
|
||||||
if (!hasProvider()) { return; }
|
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; }
|
if (code.isEmpty()) { return; }
|
||||||
CLivery d(this->getLiveries().findByCombinedCode(code));
|
const CLivery livery(this->getLiveries().findByCombinedCode(code));
|
||||||
this->setLivery(d);
|
this->setLivery(livery);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbLiverySelectorComponent::ps_completerActivated(const QString &liveryCode)
|
void CDbLiverySelectorComponent::ps_completerActivated(const QString &liveryCode)
|
||||||
@@ -194,5 +206,16 @@ namespace BlackGui
|
|||||||
this->setlivery(liveryCode);
|
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
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ namespace BlackGui
|
|||||||
void ps_completerActivated(const QString &liveryCode);
|
void ps_completerActivated(const QString &liveryCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Strip extra info from livery code
|
||||||
|
QString stripExtraInfo(const QString &liveryCode) const;
|
||||||
|
|
||||||
QScopedPointer<Ui::CDbLiverySelectorComponent> ui;
|
QScopedPointer<Ui::CDbLiverySelectorComponent> ui;
|
||||||
QScopedPointer<QCompleter> m_completerLiveries;
|
QScopedPointer<QCompleter> m_completerLiveries;
|
||||||
QMetaObject::Connection m_signalConnection;
|
QMetaObject::Connection m_signalConnection;
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ namespace BlackGui
|
|||||||
CLivery CLiveryForm::getValue() const
|
CLivery CLiveryForm::getValue() const
|
||||||
{
|
{
|
||||||
CLivery livery(this->ui->livery_Selector->getLivery());
|
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());
|
CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue());
|
||||||
livery.setAirlineIcaoCode(airline);
|
livery.setAirlineIcaoCode(airline);
|
||||||
livery.setDescription(this->ui->le_Description->text());
|
livery.setDescription(this->ui->le_Description->text());
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ namespace BlackGui
|
|||||||
ui->color_Fuselage->clear();
|
ui->color_Fuselage->clear();
|
||||||
ui->color_Tail->clear();
|
ui->color_Tail->clear();
|
||||||
ui->hs_ColorDistance->setValue(0.25 * 100.0);
|
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)
|
void CLiveryFilterBar::ps_colorChanged(const BlackMisc::CRgbColor &color)
|
||||||
|
|||||||
@@ -175,9 +175,16 @@ namespace BlackMisc
|
|||||||
bool CLivery::isValidCombinedCode(const QString &candidate)
|
bool CLivery::isValidCombinedCode(const QString &candidate)
|
||||||
{
|
{
|
||||||
if (candidate.isEmpty()) { return false; }
|
if (candidate.isEmpty()) { return false; }
|
||||||
|
if (candidate.startsWith(colorLiveryMarker()))
|
||||||
|
{
|
||||||
|
return candidate.length() > colorLiveryMarker().length() + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (candidate.count('.') != 1) { return false; }
|
if (candidate.count('.') != 1) { return false; }
|
||||||
return candidate.length() > 2;
|
return candidate.length() > 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const QString &CLivery::standardLiveryMarker()
|
const QString &CLivery::standardLiveryMarker()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user