Ref T298, added algorithm and score values to matching setup

This commit is contained in:
Klaus Basan
2018-08-07 19:54:47 +02:00
parent bd8d11d9d6
commit 8b6bdf2276
9 changed files with 276 additions and 53 deletions

View File

@@ -9,10 +9,10 @@
#include "settingsmatchingcomponent.h" #include "settingsmatchingcomponent.h"
#include "ui_settingsmatchingcomponent.h" #include "ui_settingsmatchingcomponent.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackcore/context/contextsimulator.h" #include "blackcore/context/contextsimulator.h"
#include "blackmisc/simulation/aircraftmatchersetup.h" #include "blackmisc/simulation/aircraftmatchersetup.h"
#include <QPointer>
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
using namespace BlackCore::Context; using namespace BlackCore::Context;
@@ -28,6 +28,7 @@ namespace BlackGui
ui->setupUi(this); ui->setupUi(this);
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed); connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed); connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
this->deferredReload(5000);
} }
CSettingsMatchingComponent::~CSettingsMatchingComponent() CSettingsMatchingComponent::~CSettingsMatchingComponent()
@@ -43,10 +44,27 @@ namespace BlackGui
void CSettingsMatchingComponent::onReloadPressed() void CSettingsMatchingComponent::onReloadPressed()
{ {
IContextSimulator *simContext = simulatorContext(); this->deferredReload(0);
if (!simContext) { return; } }
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
ui->editor_MatchingForm->setValue(setup); void CSettingsMatchingComponent::deferredReload(int deferMs)
{
if (deferMs < 1)
{
IContextSimulator *simContext = simulatorContext();
if (!simContext) { return; }
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
ui->editor_MatchingForm->setValue(setup);
}
else
{
QPointer<CSettingsMatchingComponent> myself(this);
QTimer::singleShot(deferMs, this, [ = ]
{
if (!myself) { return; }
this->deferredReload(0);
});
}
} }
IContextSimulator *CSettingsMatchingComponent::simulatorContext() IContextSimulator *CSettingsMatchingComponent::simulatorContext()

View File

@@ -42,6 +42,9 @@ namespace BlackGui
//! Reload pressed //! Reload pressed
void onReloadPressed(); void onReloadPressed();
//! Deferred reload
void deferredReload(int deferMs);
//! Network context //! Network context
static BlackCore::Context::IContextSimulator *simulatorContext(); static BlackCore::Context::IContextSimulator *simulatorContext();
}; };

View File

@@ -6,21 +6,33 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>640</width> <width>232</width>
<height>480</height> <height>197</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Frame</string> <string>Matching settings</string>
</property> </property>
<layout class="QVBoxLayout" name="vl_MatchingComponent"> <layout class="QVBoxLayout" name="vl_MatchingComponent">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item> <item>
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm"> <widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm">
<property name="frameShape"> <property name="minimumSize">
<enum>QFrame::StyledPanel</enum> <size>
</property> <width>0</width>
<property name="frameShadow"> <height>150</height>
<enum>QFrame::Raised</enum> </size>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -32,10 +32,17 @@ namespace BlackGui
void CMatchingForm::setReadOnly(bool readonly) void CMatchingForm::setReadOnly(bool readonly)
{ {
CGuiUtility::checkBoxReadOnly(ui->cb_ByModelString, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_ByModelString, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByICAOdata, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_ByIcaoDataAircraft1st, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByIcaoDataAirline1st, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByFamily, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_ByFamily, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByLivery, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_ByLivery, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByCombinedCode, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_ByCombinedCode, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ScoreIgnoreZeros, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ScorePreferColorLiveries, readonly);
const bool enabled = !readonly;
ui->rb_Reduction->setEnabled(enabled);
ui->rb_ScoreBased->setEnabled(enabled);
} }
CStatusMessageList CMatchingForm::validate(bool withNestedForms) const CStatusMessageList CMatchingForm::validate(bool withNestedForms) const
@@ -49,24 +56,49 @@ namespace BlackGui
const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode(); const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode();
ui->cb_ByModelString->setChecked(mode.testFlag(CAircraftMatcherSetup::ByModelString)); ui->cb_ByModelString->setChecked(mode.testFlag(CAircraftMatcherSetup::ByModelString));
ui->cb_ByCombinedCode->setChecked(mode.testFlag(CAircraftMatcherSetup::ByCombinedType)); ui->cb_ByCombinedCode->setChecked(mode.testFlag(CAircraftMatcherSetup::ByCombinedType));
ui->cb_ByICAOdata->setChecked(mode.testFlag(CAircraftMatcherSetup::ByIcaoData)); ui->cb_ByIcaoDataAircraft1st->setChecked(mode.testFlag(CAircraftMatcherSetup::ByIcaoOrderAircraftFirst));
ui->cb_ByIcaoDataAirline1st->setChecked(mode.testFlag(CAircraftMatcherSetup::ByIcaoOrderAirlineFirst));
ui->cb_ByLivery->setChecked(mode.testFlag(CAircraftMatcherSetup::ByLivery)); ui->cb_ByLivery->setChecked(mode.testFlag(CAircraftMatcherSetup::ByLivery));
ui->cb_ByFamily->setChecked(mode.testFlag(CAircraftMatcherSetup::ByFamily)); ui->cb_ByFamily->setChecked(mode.testFlag(CAircraftMatcherSetup::ByFamily));
ui->cb_ScoreIgnoreZeros->setChecked(mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros));
ui->cb_ScorePreferColorLiveries->setChecked(mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries));
if (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased)
{
ui->rb_ScoreBased->setChecked(true);
}
else
{
ui->rb_Reduction->setChecked(true);
}
} }
CAircraftMatcherSetup CMatchingForm::value() const CAircraftMatcherSetup CMatchingForm::value() const
{ {
CAircraftMatcherSetup setup; const CAircraftMatcherSetup setup(algorithm(), matchingMode());
setup.setMatchingMode(matchingMode());
return setup; return setup;
} }
void CMatchingForm::clear()
{
CAircraftMatcherSetup s;
this->setValue(s);
}
CAircraftMatcherSetup::MatchingAlgorithm CMatchingForm::algorithm() const
{
if (ui->rb_Reduction->isChecked()) { return CAircraftMatcherSetup::MatchingStepwiseReduce; }
return CAircraftMatcherSetup::MatchingScoreBased;
}
CAircraftMatcherSetup::MatchingMode CMatchingForm::matchingMode() const CAircraftMatcherSetup::MatchingMode CMatchingForm::matchingMode() const
{ {
return CAircraftMatcherSetup::matchingMode( return CAircraftMatcherSetup::matchingMode(
ui->cb_ByModelString->isChecked(), ui->cb_ByICAOdata->isChecked(), ui->cb_ByModelString->isChecked(),
ui->cb_ByIcaoDataAircraft1st->isChecked(), ui->cb_ByIcaoDataAirline1st->isChecked(),
ui->cb_ByFamily->isChecked(), ui->cb_ByLivery->isChecked(), ui->cb_ByFamily->isChecked(), ui->cb_ByLivery->isChecked(),
ui->cb_ByCombinedCode->isChecked() ui->cb_ByCombinedCode->isChecked(),
ui->cb_ScoreIgnoreZeros->isChecked(), ui->cb_ScorePreferColorLiveries->isChecked()
); );
} }
} // ns } // ns

View File

@@ -49,6 +49,9 @@ namespace BlackGui
void clear(); void clear();
private: private:
//! Algorithm
BlackMisc::Simulation::CAircraftMatcherSetup::MatchingAlgorithm algorithm() const;
//! Mode //! Mode
BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode matchingMode() const; BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode matchingMode() const;

View File

@@ -6,20 +6,69 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>287</width> <width>243</width>
<height>87</height> <height>239</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Frame</string> <string>Frame</string>
</property> </property>
<layout class="QVBoxLayout" name="vl_MatchingForm"> <layout class="QVBoxLayout" name="vl_MatchingForm">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item> <item>
<widget class="QGroupBox" name="gb_Mode"> <widget class="QGroupBox" name="gb_Algorithm">
<property name="title"> <property name="title">
<string>Mode</string> <string>Algorithm</string>
</property>
<layout class="QHBoxLayout" name="hl_Algorithm">
<item>
<widget class="QRadioButton" name="rb_ScoreBased">
<property name="text">
<string>reduction, then score based</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_Reduction">
<property name="text">
<string>reduction</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Reduction">
<property name="title">
<string>Reduction</string>
</property> </property>
<layout class="QGridLayout" name="gl_Mode"> <layout class="QGridLayout" name="gl_Mode">
<item row="2" column="0">
<widget class="QCheckBox" name="cb_ByFamily">
<property name="text">
<string>by family</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cb_ByCombinedCode">
<property name="text">
<string>combined code</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="cb_ByModelString"> <widget class="QCheckBox" name="cb_ByModelString">
<property name="text"> <property name="text">
@@ -27,28 +76,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="cb_ByICAOdata"> <widget class="QCheckBox" name="cb_ByIcaoDataAirline1st">
<property name="text"> <property name="text">
<string>by ICAO data</string> <string>by ICAO: airline first</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="cb_ByFamily"> <widget class="QCheckBox" name="cb_ByIcaoDataAircraft1st">
<property name="text"> <property name="text">
<string>by family</string> <string>by ICAO: aircraft first</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QCheckBox" name="cb_ByCombinedCode">
<property name="text">
<string>combined code</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="cb_ByLivery"> <widget class="QCheckBox" name="cb_ByLivery">
<property name="text"> <property name="text">
<string>by livery</string> <string>by livery</string>
@@ -58,8 +100,43 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="gb_Scoring">
<property name="title">
<string>Scoring</string>
</property>
<layout class="QHBoxLayout" name="hl_Scoring">
<item>
<widget class="QCheckBox" name="cb_ScorePreferColorLiveries">
<property name="text">
<string>prefer color liveries</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_ScoreIgnoreZeros">
<property name="text">
<string>ignore 0 (zero) scores</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops>
<tabstop>rb_ScoreBased</tabstop>
<tabstop>rb_Reduction</tabstop>
<tabstop>cb_ByModelString</tabstop>
<tabstop>cb_ByIcaoDataAircraft1st</tabstop>
<tabstop>cb_ByIcaoDataAirline1st</tabstop>
<tabstop>cb_ByFamily</tabstop>
<tabstop>cb_ByLivery</tabstop>
<tabstop>cb_ByCombinedCode</tabstop>
<tabstop>cb_ScorePreferColorLiveries</tabstop>
<tabstop>cb_ScoreIgnoreZeros</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@@ -8,15 +8,23 @@
*/ */
#include "aircraftmatchersetup.h" #include "aircraftmatchersetup.h"
#include <QStringBuilder>
namespace BlackMisc namespace BlackMisc
{ {
namespace Simulation namespace Simulation
{ {
CAircraftMatcherSetup::CAircraftMatcherSetup(CAircraftMatcherSetup::MatchingAlgorithm algorithm, MatchingMode mode)
{
this->setMatchingAlgorithm(algorithm);
this->setMatchingMode(mode);
}
QString CAircraftMatcherSetup::convertToQString(bool i18n) const QString CAircraftMatcherSetup::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n);
return modeToString(this->getMatchingMode()); return QStringLiteral("algorithm: '") % this->getMatchingAlgorithmAsString() %
QStringLiteral("' mode: ") % this->getMatchingModeAsString();
} }
CVariant CAircraftMatcherSetup::propertyByIndex(const CPropertyIndex &index) const CVariant CAircraftMatcherSetup::propertyByIndex(const CPropertyIndex &index) const
@@ -25,6 +33,7 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexMatchingAlgorithm: return CVariant::fromValue(m_algorithm);
case IndexMatchingMode: return CVariant::fromValue(m_mode); case IndexMatchingMode: return CVariant::fromValue(m_mode);
default: break; default: break;
} }
@@ -37,19 +46,37 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexMatchingAlgorithm: m_algorithm = variant.toInt(); break;
case IndexMatchingMode: m_mode = variant.toInt(); break; case IndexMatchingMode: m_mode = variant.toInt(); break;
default: break; default: break;
} }
CValueObject::setPropertyByIndex(index, variant); CValueObject::setPropertyByIndex(index, variant);
} }
const QString &CAircraftMatcherSetup::algorithmToString(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
{
static const QString s("score based");
static const QString r("stepwise reduce");
switch (algorithm)
{
case MatchingStepwiseReduce: return r;
case MatchingScoreBased:
default: break;
}
return s;
}
const QString &CAircraftMatcherSetup::modeFlagToString(MatchingModeFlag modeFlag) const QString &CAircraftMatcherSetup::modeFlagToString(MatchingModeFlag modeFlag)
{ {
static const QString ms("by model string"); static const QString ms("by model string");
static const QString icao("by ICAO"); static const QString icao("by ICAO");
static const QString icaoAircraft("by ICAO, aircraft first");
static const QString icaoAirline("by ICAO, airline first");
static const QString family("by family"); static const QString family("by family");
static const QString livery("by livery"); static const QString livery("by livery");
static const QString combined("by combined combined"); static const QString combined("by combined combined");
static const QString noZeros("scoring, ignore zero scores");
static const QString preferColorLiveries("scoring, prefer color liveries");
switch (modeFlag) switch (modeFlag)
{ {
@@ -58,6 +85,10 @@ namespace BlackMisc
case ByFamily: return family; case ByFamily: return family;
case ByLivery: return livery; case ByLivery: return livery;
case ByCombinedType: return combined; case ByCombinedType: return combined;
case ByIcaoOrderAircraftFirst: return icaoAircraft;
case ByIcaoOrderAirlineFirst: return icaoAirline;
case ScoreIgnoreZeros: return noZeros;
case ScorePreferColorLiveries: return preferColorLiveries;
default: break; default: break;
} }
@@ -67,24 +98,31 @@ namespace BlackMisc
QString CAircraftMatcherSetup::modeToString(MatchingMode mode) QString CAircraftMatcherSetup::modeToString(MatchingMode mode)
{ {
if (mode == ModeAll) { return "all"; }
QStringList modes; QStringList modes;
if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); } if (mode.testFlag(ByModelString)) { modes << modeFlagToString(ByModelString); }
if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); } if (mode.testFlag(ByIcaoData)) { modes << modeFlagToString(ByIcaoData); }
if (mode.testFlag(ByFamily)) { modes << modeFlagToString(ByFamily); } if (mode.testFlag(ByIcaoOrderAircraftFirst)) { modes << modeFlagToString(ByIcaoOrderAircraftFirst); }
if (mode.testFlag(ByLivery)) { modes << modeFlagToString(ByLivery); } if (mode.testFlag(ByIcaoOrderAirlineFirst)) { modes << modeFlagToString(ByIcaoOrderAirlineFirst); }
if (mode.testFlag(ByCombinedType)) { modes << modeFlagToString(ByCombinedType); } if (mode.testFlag(ByFamily)) { modes << modeFlagToString(ByFamily); }
if (mode.testFlag(ByLivery)) { modes << modeFlagToString(ByLivery); }
if (mode.testFlag(ByCombinedType)) { modes << modeFlagToString(ByCombinedType); }
if (mode.testFlag(ScoreIgnoreZeros)) { modes << modeFlagToString(ScoreIgnoreZeros); }
if (mode.testFlag(ScorePreferColorLiveries)) { modes << modeFlagToString(ScorePreferColorLiveries); }
return modes.join(", "); return modes.join(", ");
} }
CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(bool byModelString, bool byIcaoData, bool byFamily, bool byLivery, bool byCombinedType) CAircraftMatcherSetup::MatchingMode CAircraftMatcherSetup::matchingMode(
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
bool scoreIgnoreZeros, bool scorePreferColorLiveries)
{ {
MatchingMode mode = byModelString ? ByModelString : ModeNone; MatchingMode mode = byModelString ? ByModelString : ModeNone;
if (byIcaoData) { mode |= ByIcaoData; } if (byIcaoDataAircraft1st) { mode |= ByIcaoOrderAircraftFirst; }
if (byFamily) { mode |= ByFamily; } if (byIcaoDataAirline1st) { mode |= ByIcaoOrderAirlineFirst; }
if (byLivery) { mode |= ByLivery; } if (byFamily) { mode |= ByFamily; }
if (byCombinedType) { mode |= ByCombinedType; } if (byLivery) { mode |= ByLivery; }
if (byCombinedType) { mode |= ByCombinedType; }
if (scoreIgnoreZeros) { mode |= ScoreIgnoreZeros; }
if (scorePreferColorLiveries) { mode |= ScorePreferColorLiveries; }
return mode; return mode;
} }
} // namespace } // namespace

View File

@@ -24,31 +24,61 @@ namespace BlackMisc
class BLACKMISC_EXPORT CAircraftMatcherSetup : public CValueObject<CAircraftMatcherSetup> class BLACKMISC_EXPORT CAircraftMatcherSetup : public CValueObject<CAircraftMatcherSetup>
{ {
public: public:
//! Matching algorithm
enum MatchingAlgorithm
{
MatchingScoreBased,
MatchingStepwiseReduce
};
//! Enabled matching mode flags //! Enabled matching mode flags
enum MatchingModeFlag enum MatchingModeFlag
{ {
ByModelString = 1 << 0, ByModelString = 1 << 0, //!< allow exact model string match
ByIcaoData = 1 << 1, ByIcaoData = 1 << 1,
ByFamily = 1 << 2, ByFamily = 1 << 2,
ByLivery = 1 << 3, ByLivery = 1 << 3,
ByCombinedType = 1 << 4, ByCombinedType = 1 << 4,
ModeAll = ByModelString | ByIcaoData | ByFamily | ByLivery | ByCombinedType, ByIcaoOrderAircraftFirst = (1 << 5) | ByIcaoData,
ModeNone = 0 ByIcaoOrderAirlineFirst = (1 << 6) | ByIcaoData,
// --- score based matching ---
ScoreIgnoreZeros = 1 << 7, //!< zero scores are ignored
ScorePreferColorLiveries = 1 << 8, //!< prefer color liveries
// --- others ---
ModeNone = 0,
ModeScoreDefault = ScoreIgnoreZeros | ScorePreferColorLiveries,
ModeDefault = ByModelString | ByFamily | ByLivery | ByCombinedType | ByIcaoOrderAircraftFirst | ModeScoreDefault
}; };
Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag) Q_DECLARE_FLAGS(MatchingMode, MatchingModeFlag)
//! Properties by index //! Properties by index
enum ColumnIndex enum ColumnIndex
{ {
IndexMatchingMode = CPropertyIndex::GlobalIndexCAircraftMatcherSetup IndexMatchingAlgorithm = CPropertyIndex::GlobalIndexCAircraftMatcherSetup,
IndexMatchingMode
}; };
//! Constructor //! Constructor
CAircraftMatcherSetup() {} CAircraftMatcherSetup() {}
//! Constructor
CAircraftMatcherSetup(MatchingAlgorithm algorithm, MatchingMode mode);
//! Algorithm
MatchingAlgorithm getMatchingAlgorithm() const { return static_cast<MatchingAlgorithm>(m_algorithm); }
//! Algorithm as string
const QString &getMatchingAlgorithmAsString() const { return algorithmToString(this->getMatchingAlgorithm()); }
//! Algorithm
void setMatchingAlgorithm(MatchingAlgorithm algorithm) { m_algorithm = static_cast<int>(algorithm); }
//! Matching mode //! Matching mode
MatchingMode getMatchingMode() const { return static_cast<MatchingMode>(m_mode); } MatchingMode getMatchingMode() const { return static_cast<MatchingMode>(m_mode); }
//! Matching mode as string
QString getMatchingModeAsString() const { return modeToString(this->getMatchingMode()); }
//! Dynamic offset values? //! Dynamic offset values?
void setMatchingMode(MatchingMode mode) { m_mode = static_cast<int>(mode); } void setMatchingMode(MatchingMode mode) { m_mode = static_cast<int>(mode); }
@@ -61,6 +91,9 @@ namespace BlackMisc
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant); void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
//! Algorithm to string
static const QString &algorithmToString(MatchingAlgorithm algorithm);
//! Enumeration as string //! Enumeration as string
static const QString &modeFlagToString(MatchingModeFlag modeFlag); static const QString &modeFlagToString(MatchingModeFlag modeFlag);
@@ -68,13 +101,17 @@ namespace BlackMisc
static QString modeToString(MatchingMode mode); static QString modeToString(MatchingMode mode);
//! Mode by flags //! Mode by flags
static MatchingMode matchingMode(bool byModelString, bool byIcaoData, bool byFamily, bool byLivery, bool byCombinedType); static MatchingMode matchingMode(
bool byModelString, bool byIcaoDataAircraft1st, bool byIcaoDataAirline1st, bool byFamily, bool byLivery, bool byCombinedType,
bool scoreIgnoreZeros, bool scorePreferColorLiveries);
private: private:
int m_mode = static_cast<int>(ModeAll); int m_algorithm = static_cast<int>(MatchingScoreBased);
int m_mode = static_cast<int>(ModeDefault);
BLACK_METACLASS( BLACK_METACLASS(
CAircraftMatcherSetup, CAircraftMatcherSetup,
BLACK_METAMEMBER(algorithm),
BLACK_METAMEMBER(mode) BLACK_METAMEMBER(mode)
); );
}; };
@@ -82,6 +119,7 @@ namespace BlackMisc
} // namespace } // namespace
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup) Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingAlgorithm)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode) Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode)
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingModeFlag) Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingModeFlag)
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode) Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode)

View File

@@ -49,8 +49,10 @@ namespace BlackMisc
CSwiftPluginSettings::registerMetadata(); CSwiftPluginSettings::registerMetadata();
CVPilotModelRule::registerMetadata(); CVPilotModelRule::registerMetadata();
CVPilotModelRuleSet::registerMetadata(); CVPilotModelRuleSet::registerMetadata();
qRegisterMetaType<CAircraftMatcherSetup::MatchingAlgorithm>();
qRegisterMetaType<CAircraftMatcherSetup::MatchingMode>(); qRegisterMetaType<CAircraftMatcherSetup::MatchingMode>();
qRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>(); qRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>();
qDBusRegisterMetaType<CAircraftMatcherSetup::MatchingAlgorithm>();
qDBusRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>(); qDBusRegisterMetaType<CAircraftMatcherSetup::MatchingModeFlag>();
CAircraftMatcherSetup::registerMetadata(); CAircraftMatcherSetup::registerMetadata();
} }