mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 22:29:13 +08:00
refs #577, better data consolidation/auto find by also using IATA/family
also refs #586, refs #580, refs #576
This commit is contained in:
@@ -225,10 +225,13 @@ namespace BlackGui
|
|||||||
void CDbStashComponent::ps_onPublishPressed()
|
void CDbStashComponent::ps_onPublishPressed()
|
||||||
{
|
{
|
||||||
if (this->ui->tvp_StashAircraftModels->isEmpty()) {return; }
|
if (this->ui->tvp_StashAircraftModels->isEmpty()) {return; }
|
||||||
if (!this->validateAndDisplay()) { return; }
|
|
||||||
|
// get models right here, because later steps might affect selection
|
||||||
CAircraftModelList models(getSelectedOrAllModels());
|
CAircraftModelList models(getSelectedOrAllModels());
|
||||||
if (models.isEmpty()) { return; }
|
if (models.isEmpty()) { return; }
|
||||||
|
|
||||||
|
// validate
|
||||||
|
if (!this->validateAndDisplay()) { return; }
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
if (models.size() > MaxModelPublished)
|
if (models.size() > MaxModelPublished)
|
||||||
{
|
{
|
||||||
@@ -339,7 +342,7 @@ namespace BlackGui
|
|||||||
CAircraftModelList CDbStashComponent::getSelectedOrAllModels() const
|
CAircraftModelList CDbStashComponent::getSelectedOrAllModels() const
|
||||||
{
|
{
|
||||||
bool selectedOnly = ui->cb_SelectedOnly->isChecked();
|
bool selectedOnly = ui->cb_SelectedOnly->isChecked();
|
||||||
const CAircraftModelList models(selectedOnly ? this->ui->tvp_StashAircraftModels->selectedObjects() : this->ui->tvp_StashAircraftModels->container());
|
const CAircraftModelList models(selectedOnly ? this->ui->tvp_StashAircraftModels->selectedObjects() : this->ui->tvp_StashAircraftModels->containerOrFilteredContainer());
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,13 +354,11 @@ namespace BlackGui
|
|||||||
// we try to best update by DB data here
|
// we try to best update by DB data here
|
||||||
if (!dbModel.hasValidDbKey())
|
if (!dbModel.hasValidDbKey())
|
||||||
{
|
{
|
||||||
// we have no(!) DB model, so we update ecach of it subobjects
|
// we have no(!) DB model, so we update each of it subobjects
|
||||||
CAircraftModel consolidatedModel(model); // copy over
|
CAircraftModel consolidatedModel(model); // copy over
|
||||||
if (!consolidatedModel.getLivery().hasValidDbKey() && consolidatedModel.hasAirlineDesignator())
|
if (!consolidatedModel.getLivery().hasValidDbKey())
|
||||||
{
|
{
|
||||||
// we try to find a DB livery for the airline
|
const CLivery dbLivery(this->smartLiverySelector(consolidatedModel.getLivery()));
|
||||||
// maybe slow because all liveries always copied over
|
|
||||||
CLivery dbLivery(this->getLiveries().findStdLiveryByAirlineIcaoDesignator(model.getAirlineIcaoCode()));
|
|
||||||
if (dbLivery.hasValidDbKey())
|
if (dbLivery.hasValidDbKey())
|
||||||
{
|
{
|
||||||
consolidatedModel.setLivery(dbLivery);
|
consolidatedModel.setLivery(dbLivery);
|
||||||
@@ -366,7 +367,7 @@ namespace BlackGui
|
|||||||
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
|
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
|
||||||
{
|
{
|
||||||
// try to find DB aircraft ICAO here
|
// try to find DB aircraft ICAO here
|
||||||
CAircraftIcaoCode dbIcao(this->getAircraftIcaoCodeForDesignator(consolidatedModel.getAircraftIcaoCode().getDesignator()));
|
const CAircraftIcaoCode dbIcao(this->smartAircraftIcaoSelector(consolidatedModel.getAircraftIcaoCode()));
|
||||||
if (dbIcao.hasValidDbKey())
|
if (dbIcao.hasValidDbKey())
|
||||||
{
|
{
|
||||||
consolidatedModel.setAircraftIcaoCode(dbIcao);
|
consolidatedModel.setAircraftIcaoCode(dbIcao);
|
||||||
@@ -407,12 +408,7 @@ namespace BlackGui
|
|||||||
CAircraftModel CDbStashComponent::consolidateModel(const CAircraftModel &model) const
|
CAircraftModel CDbStashComponent::consolidateModel(const CAircraftModel &model) const
|
||||||
{
|
{
|
||||||
CAircraftModel stashModel(model);
|
CAircraftModel stashModel(model);
|
||||||
|
bool ownModel = stashModel.getModelType() == CAircraftModel::TypeOwnSimulatorModel;
|
||||||
// merge with own models if any
|
|
||||||
if (stashModel.getModelType() != CAircraftModel::TypeOwnSimulatorModel)
|
|
||||||
{
|
|
||||||
stashModel = this->consolidateWithOwnModels(stashModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge with DB data if any
|
// merge with DB data if any
|
||||||
if (!stashModel.hasValidDbKey())
|
if (!stashModel.hasValidDbKey())
|
||||||
@@ -420,6 +416,12 @@ namespace BlackGui
|
|||||||
stashModel = this->consolidateWithDbData(stashModel);
|
stashModel = this->consolidateWithDbData(stashModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// merge with own models if any
|
||||||
|
if (!ownModel)
|
||||||
|
{
|
||||||
|
stashModel = this->consolidateWithOwnModels(stashModel);
|
||||||
|
}
|
||||||
|
|
||||||
return stashModel;
|
return stashModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,29 +135,40 @@ namespace BlackMisc
|
|||||||
if (c.hasCompleteData()) { return c; }
|
if (c.hasCompleteData()) { return c; }
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftIcaoCodeList codes(*this); // copy and reduce
|
CAircraftIcaoCodeList codes;
|
||||||
if (icaoPattern.hasKnownDesignator())
|
if (icaoPattern.hasKnownDesignator())
|
||||||
{
|
{
|
||||||
const QString d(icaoPattern.getDesignator());
|
const QString d(icaoPattern.getDesignator());
|
||||||
codes = codes.findByDesignator(d);
|
codes = this->findByDesignator(d);
|
||||||
|
|
||||||
// we have an exact match
|
// we have one exact match
|
||||||
if (codes.size() == 1) { return codes.front(); }
|
if (codes.size() == 1) { return codes.front(); }
|
||||||
|
|
||||||
if (codes.isEmpty())
|
if (codes.isEmpty())
|
||||||
{
|
{
|
||||||
// now we search if the ICAO designator is
|
// now we search if the ICAO designator is
|
||||||
// actually an IATA code
|
// actually an IATA code
|
||||||
codes = codes.findByIataCode(d);
|
codes = this->findByIataCode(d);
|
||||||
|
|
||||||
|
// we have one exact match
|
||||||
|
if (codes.size() == 1) { return codes.front(); }
|
||||||
|
|
||||||
if (codes.isEmpty())
|
if (codes.isEmpty())
|
||||||
{
|
{
|
||||||
// still empty, bye
|
// still empty, try to find by family
|
||||||
return icaoPattern;
|
codes = this->findByFamily(d);
|
||||||
|
|
||||||
|
// we have one exact match
|
||||||
|
if (codes.size() == 1) { return codes.front(); }
|
||||||
|
|
||||||
|
// still empty, hopeless
|
||||||
|
if (codes.isEmpty()) { return icaoPattern; }
|
||||||
|
|
||||||
|
// continue here, we have more than one code and
|
||||||
|
// will try to further reduce
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codes.sortByRank();
|
codes.sortByRank();
|
||||||
|
|
||||||
// intentionally continue here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// further reduce by manufacturer
|
// further reduce by manufacturer
|
||||||
@@ -166,7 +177,6 @@ namespace BlackMisc
|
|||||||
const QString m(icaoPattern.getManufacturer());
|
const QString m(icaoPattern.getManufacturer());
|
||||||
codes = codes.findByManufacturer(m);
|
codes = codes.findByManufacturer(m);
|
||||||
if (codes.size() == 1) { return codes.front(); }
|
if (codes.size() == 1) { return codes.front(); }
|
||||||
if (codes.isEmpty()) { return icaoPattern; }
|
|
||||||
|
|
||||||
// intentionally continue here
|
// intentionally continue here
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace BlackMisc
|
|||||||
//! Find by designator, then best match by rank
|
//! Find by designator, then best match by rank
|
||||||
CAircraftIcaoCode findFirstByDesignatorAndRank(const QString &designator) const;
|
CAircraftIcaoCode findFirstByDesignatorAndRank(const QString &designator) const;
|
||||||
|
|
||||||
//! Best selection by given pattern
|
//! Best selection by given pattern, also searches IATA and family information
|
||||||
CAircraftIcaoCode smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const;
|
CAircraftIcaoCode smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const;
|
||||||
|
|
||||||
//! Sort by rank
|
//! Sort by rank
|
||||||
|
|||||||
Reference in New Issue
Block a user