diff --git a/src/blackmisc/simulation/aircraftmatchersetup.cpp b/src/blackmisc/simulation/aircraftmatchersetup.cpp index 3127a5d41..56da9ccae 100644 --- a/src/blackmisc/simulation/aircraftmatchersetup.cpp +++ b/src/blackmisc/simulation/aircraftmatchersetup.cpp @@ -58,6 +58,13 @@ namespace BlackMisc this->setMatchingMode(m); } + void CAircraftMatcherSetup::setReverseLookup(bool useModelLookup) + { + MatchingMode m = this->getMatchingMode(); + m.setFlag(ReverseLookupModelString, useModelLookup); + this->setMatchingMode(m); + } + QString CAircraftMatcherSetup::convertToQString(bool i18n) const { Q_UNUSED(i18n); @@ -162,9 +169,11 @@ namespace BlackMisc static const QString modelFailedAdded("Replace models failed to be added"); static const QString categoryGlider("glider categories"); static const QString categoryMilitary("military categories"); + static const QString revModelString("reverse model lookup"); switch (modeFlag) { + case ReverseLookupModelString: return revModelString; case ByModelString: return ms; case ByIcaoData: return icao; case ByFamily: return family; @@ -195,6 +204,7 @@ namespace BlackMisc QString CAircraftMatcherSetup::modeToString(MatchingMode mode) { QStringList modes; + if (mode.testFlag(ReverseLookupModelString)) { modes << modeFlagToString(ReverseLookupModelString); } if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); } if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); } if (mode.testFlag(ByIcaoOrderAircraftFirst)) { modes << modeFlagToString(ByIcaoOrderAircraftFirst); } diff --git a/src/blackmisc/simulation/aircraftmatchersetup.h b/src/blackmisc/simulation/aircraftmatchersetup.h index 6827a9184..ec6003c4e 100644 --- a/src/blackmisc/simulation/aircraftmatchersetup.h +++ b/src/blackmisc/simulation/aircraftmatchersetup.h @@ -14,7 +14,6 @@ #include "blackmisc/valueobject.h" #include "blackmisc/blackmiscexport.h" - namespace BlackMisc { namespace Simulation @@ -52,16 +51,22 @@ namespace BlackMisc // --- score based matching --- ScoreIgnoreZeros = 1 << 11, //!< zero scores are ignored ScorePreferColorLiveries = 1 << 12, //!< prefer color liveries + // --- exclusion --- ExcludeNoDbData = 1 << 13, ExcludeNoExcluded = 1 << 14, ExcludeDefault = ExcludeNoExcluded | ExcludeNoDbData, + // --- model set --- ModelSetRemoveFailedModel = 1 << 15, ModelVerificationAtStartup = 1 << 16, ModelVerificationOnlyWarnError = 1 << 18, // later added, hence 18 ModelFailoverIfNoModelCanBeAdded = 1 << 17, + // --- reverse lookup --- + ReverseLookupModelString = 1 << 19, + ReverseLookupDefault = ReverseLookupModelString, + // --- others --- ModeNone = 0, ModeByFLags = ByMilitary | ByVtol, @@ -70,9 +75,9 @@ namespace BlackMisc ModeDefaultSet = ModelSetRemoveFailedModel | ModelVerificationAtStartup | ModelFailoverIfNoModelCanBeAdded, // default depending on algorithm - ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault, - ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault, - ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault, + ModeDefaultScore = ScoreIgnoreZeros | ScorePreferColorLiveries | ExcludeDefault | ReverseLookupDefault, + ModeDefaultReduce = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ByLivery | ExcludeDefault | ReverseLookupDefault, + ModeDefaultReducePlusScore = ModeByFLags | ByModelString | ByFamily | ByManufacturer | ByCombinedType | ByIcaoOrderAircraftFirst | ModeDefaultScore | ExcludeDefault | ReverseLookupDefault, }; Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag) @@ -149,14 +154,17 @@ namespace BlackMisc //! Set the strategy void setPickStrategy(PickSimilarStrategy strategy) { m_strategy = static_cast(strategy); } + //! Set reverse lookup flags + void setReverseLookup(bool useModelLookup); + //! \copydoc BlackMisc::Mixin::String::toQString QString convertToQString(bool i18n = false) const; //! \copydoc BlackMisc::Mixin::Index::propertyByIndex - BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; + CVariant propertyByIndex(const CPropertyIndex &index) const; //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex - void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant); + void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant); //! Reset void reset();