mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T109, new utility functions for reverse lookup
This commit is contained in:
committed by
Mathew Sutcliffe
parent
808fd48650
commit
03a551d016
@@ -208,6 +208,30 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByFamilyWithColorLivery(const QString &family) const
|
||||
{
|
||||
if (family.isEmpty()) { return CAircraftModelList(); }
|
||||
const QString f(family.toUpper().trimmed());
|
||||
return this->findBy([ & ](const CAircraftModel & model)
|
||||
{
|
||||
if (!model.getLivery().isColorLivery()) { return false; }
|
||||
const CAircraftIcaoCode icao(model.getAircraftIcaoCode());
|
||||
if (!icao.hasFamily()) { return false; }
|
||||
return icao.getFamily() == f;
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByDesignatorOrFamilyWithColorLivery(const CAircraftIcaoCode &icao) const
|
||||
{
|
||||
return this->findBy([ & ](const CAircraftModel & model)
|
||||
{
|
||||
if (!model.getLivery().isColorLivery()) { return false; }
|
||||
const CAircraftIcaoCode modelIcao(model.getAircraftIcaoCode());
|
||||
if (modelIcao.getDesignator() == icao.getDesignator()) { return true; }
|
||||
return icao.hasFamily() && modelIcao.getFamily() == icao.getFamily();
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByCombinedType(const QString &combinedType) const
|
||||
{
|
||||
const QString cc(combinedType.trimmed().toUpper());
|
||||
@@ -219,11 +243,28 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByCombinedTypeAndWtc(const QString &combinedType, const QString &wtc) const
|
||||
{
|
||||
const CAircraftModelList ml = this->findByCombinedType(combinedType);
|
||||
if (ml.isEmpty()) { return ml; }
|
||||
const QString wtcUc(wtc.toUpper().trimmed());
|
||||
return this->findBy([ & ](const CAircraftModel & model)
|
||||
{
|
||||
const CAircraftIcaoCode icao(model.getAircraftIcaoCode());
|
||||
return icao.getWtc() == wtcUc;
|
||||
});
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByCombinedTypeWithColorLivery(const QString &combinedType) const
|
||||
{
|
||||
return this->findByCombinedType(combinedType).findColorLiveries();
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findByCombinedTypeAndWtcWithColorLivery(const QString &combinedType, const QString &wtc) const
|
||||
{
|
||||
return this->findByCombinedTypeAndWtc(combinedType, wtc).findColorLiveries();
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftModelList::findColorLiveries() const
|
||||
{
|
||||
return this->findBy([ = ](const CAircraftModel & model)
|
||||
@@ -525,6 +566,26 @@ namespace BlackMisc
|
||||
return maxSim;
|
||||
}
|
||||
|
||||
int CAircraftModelList::countModelsWithColorLivery() const
|
||||
{
|
||||
int count = 0;
|
||||
for (const CAircraftModel &model : (*this))
|
||||
{
|
||||
if (model.getLivery().isColorLivery()) { count++; }
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int CAircraftModelList::countModelsWithAirlineLivery() const
|
||||
{
|
||||
int count = 0;
|
||||
for (const CAircraftModel &model : (*this))
|
||||
{
|
||||
if (model.getLivery().isAirlineLivery()) { count++; }
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void CAircraftModelList::updateDistributor(const CDistributor &distributor)
|
||||
{
|
||||
for (CAircraftModel &model : *this)
|
||||
@@ -619,8 +680,9 @@ namespace BlackMisc
|
||||
{
|
||||
ScoredModels scoreMap;
|
||||
|
||||
// prefer colors if there is no airline
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("Prefer color liveries: %1, airline: '%2'").arg(boolToYesNo(preferColorLiveries), remoteModel.getAirlineIcaoCodeDesignator()));
|
||||
// normally prefer colors if there is no airline
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("Prefer color liveries: %1, airline: '%2', ignore zero scores: %3").arg(boolToYesNo(preferColorLiveries), remoteModel.getAirlineIcaoCodeDesignator(), boolToYesNo(ignoreZeroScores)));
|
||||
CMatchingUtils::addLogDetailsToList(log, remoteModel.getCallsign(), QString("Scoring in list with %1 models, airline liveries: %2, color liveries: %3").arg(this->size()).arg(this->countModelsWithAirlineLivery()).arg(this->countModelsWithColorLivery()));
|
||||
|
||||
for (const CAircraftModel &model : *this)
|
||||
{
|
||||
|
||||
@@ -135,12 +135,24 @@ namespace BlackMisc
|
||||
//! Models with aircraft family
|
||||
CAircraftModelList findByFamily(const QString &family) const;
|
||||
|
||||
//! Find by combined code, wildcards possible e.g. L*P, *2J
|
||||
//! Models with aircraft family and color livery
|
||||
CAircraftModelList findByFamilyWithColorLivery(const QString &family) const;
|
||||
|
||||
//! Models with aircraft family or designator and color livery
|
||||
CAircraftModelList findByDesignatorOrFamilyWithColorLivery(const Aviation::CAircraftIcaoCode &icao) const;
|
||||
|
||||
//! Find by combined code, wildcards possible, e.g. L*P, *2J
|
||||
CAircraftModelList findByCombinedType(const QString &combinedType) const;
|
||||
|
||||
//! Find aircraft with color livery by combined code, wildcards possible e.g. L*P, *2J
|
||||
//! Find by combined code and WTC, wildcards for combined code possible, e.g. L*P, *2J
|
||||
CAircraftModelList findByCombinedTypeAndWtc(const QString &combinedType, const QString &wtc) const;
|
||||
|
||||
//! \copydoc findByCombinedType
|
||||
CAircraftModelList findByCombinedTypeWithColorLivery(const QString &combinedType) const;
|
||||
|
||||
//! \copydoc findByCombinedTypeAndWtc
|
||||
CAircraftModelList findByCombinedTypeAndWtcWithColorLivery(const QString &combinedType, const QString &wtc) const;
|
||||
|
||||
//! Find models with color liveries
|
||||
CAircraftModelList findColorLiveries() const;
|
||||
|
||||
@@ -210,6 +222,12 @@ namespace BlackMisc
|
||||
//! Which simulator(s) have the most entries?
|
||||
CSimulatorInfo simulatorsWithMaxEntries() const;
|
||||
|
||||
//! Models with a color livery
|
||||
int countModelsWithColorLivery() const;
|
||||
|
||||
//! Models with an airline livery
|
||||
int countModelsWithAirlineLivery() const;
|
||||
|
||||
//! Update distributor, all models in list are set to given distributor
|
||||
void updateDistributor(const CDistributor &distributor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user