Ref T298, new attributes for matching setup in editor

This commit is contained in:
Klaus Basan
2018-08-11 00:44:24 +02:00
parent 3aadef458d
commit c4bd1536f2
3 changed files with 134 additions and 34 deletions

View File

@@ -10,6 +10,7 @@
#include "ui_matchingform.h" #include "ui_matchingform.h"
#include "matchingform.h" #include "matchingform.h"
#include "guiutility.h" #include "guiutility.h"
#include <QPushButton>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
@@ -24,6 +25,8 @@ namespace BlackGui
ui(new Ui::CMatchingForm) ui(new Ui::CMatchingForm)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->rb_Reduction, &QRadioButton::toggled, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
connect(ui->pb_Reset, &QPushButton::released, this, &CMatchingForm::clear, Qt::QueuedConnection);
} }
CMatchingForm::~CMatchingForm() CMatchingForm::~CMatchingForm()
@@ -43,6 +46,9 @@ namespace BlackGui
ui->rb_ScoreBased->setEnabled(enabled); ui->rb_ScoreBased->setEnabled(enabled);
ui->rb_ByIcaoDataAircraft1st->setEnabled(enabled); ui->rb_ByIcaoDataAircraft1st->setEnabled(enabled);
ui->rb_ByIcaoDataAirline1st->setEnabled(enabled); ui->rb_ByIcaoDataAirline1st->setEnabled(enabled);
ui->rb_PickFirst->setEnabled(enabled);
ui->rb_PickByOrder->setEnabled(enabled);
ui->rb_PickRandom->setEnabled(enabled);
} }
CStatusMessageList CMatchingForm::validate(bool withNestedForms) const CStatusMessageList CMatchingForm::validate(bool withNestedForms) const
@@ -62,26 +68,22 @@ namespace BlackGui
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_ScoreIgnoreZeros->setChecked(mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros));
ui->cb_ScorePreferColorLiveries->setChecked(mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries)); ui->cb_ScorePreferColorLiveries->setChecked(mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries));
this->setMatchingAlgorithm(setup);
this->setPickStrategy(setup);
if (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased) const bool scoring = (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased);
{ ui->gb_Scoring->setEnabled(scoring);
ui->rb_ScoreBased->setChecked(true);
}
else
{
ui->rb_Reduction->setChecked(true);
}
} }
CAircraftMatcherSetup CMatchingForm::value() const CAircraftMatcherSetup CMatchingForm::value() const
{ {
const CAircraftMatcherSetup setup(algorithm(), matchingMode()); const CAircraftMatcherSetup setup(algorithm(), matchingMode(), pickStrategy());
return setup; return setup;
} }
void CMatchingForm::clear() void CMatchingForm::clear()
{ {
CAircraftMatcherSetup s; const CAircraftMatcherSetup s(algorithm());
this->setValue(s); this->setValue(s);
} }
@@ -101,5 +103,43 @@ namespace BlackGui
ui->cb_ScoreIgnoreZeros->isChecked(), ui->cb_ScorePreferColorLiveries->isChecked() ui->cb_ScoreIgnoreZeros->isChecked(), ui->cb_ScorePreferColorLiveries->isChecked()
); );
} }
CAircraftMatcherSetup::PickSimilarStrategy CMatchingForm::pickStrategy() const
{
if (ui->rb_PickRandom->isChecked()) { return CAircraftMatcherSetup::PickRandom; }
if (ui->rb_PickByOrder->isChecked()) { return CAircraftMatcherSetup::PickByOrder; }
return CAircraftMatcherSetup::PickFirst;
}
void CMatchingForm::setPickStrategy(const CAircraftMatcherSetup &setup)
{
switch (setup.getPickStrategy())
{
case CAircraftMatcherSetup::PickByOrder: ui->rb_PickByOrder->setChecked(true); break;
case CAircraftMatcherSetup::PickRandom: ui->rb_PickRandom->setChecked(true); break;
case CAircraftMatcherSetup::PickFirst:
default:
ui->rb_PickFirst->setChecked(true); break;
}
}
void CMatchingForm::setMatchingAlgorithm(const CAircraftMatcherSetup &setup)
{
if (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased)
{
ui->rb_ScoreBased->setChecked(true);
}
else
{
ui->rb_Reduction->setChecked(true);
}
}
void CMatchingForm::onAlgorithmChanged(bool checked)
{
Q_UNUSED(checked);
const CAircraftMatcherSetup setup = this->value();
this->setValue(setup);
}
} // ns } // ns
} // ns } // ns

View File

@@ -55,6 +55,18 @@ namespace BlackGui
//! Mode //! Mode
BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode matchingMode() const; BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode matchingMode() const;
//! Stragey
BlackMisc::Simulation::CAircraftMatcherSetup::PickSimilarStrategy pickStrategy() const;
//! Set the pick strategy
void setPickStrategy(const BlackMisc::Simulation::CAircraftMatcherSetup &setup);
//! Set the matching mode
void setMatchingAlgorithm(const BlackMisc::Simulation::CAircraftMatcherSetup &setup);
//! Algorithm has been toggled
void onAlgorithmChanged(bool checked);
QScopedPointer<Ui::CMatchingForm> ui; QScopedPointer<Ui::CMatchingForm> ui;
}; };
} // ns } // ns

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>243</width> <width>247</width>
<height>239</height> <height>304</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -31,18 +31,55 @@
<property name="title"> <property name="title">
<string>Algorithm</string> <string>Algorithm</string>
</property> </property>
<layout class="QHBoxLayout" name="hl_Algorithm"> <layout class="QGridLayout" name="gridLayout">
<item> <item row="1" column="0">
<widget class="QRadioButton" name="rb_Reduction">
<property name="text">
<string>reduction</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="rb_ScoreBased"> <widget class="QRadioButton" name="rb_ScoreBased">
<property name="text"> <property name="text">
<string>reduction, then score based</string> <string>reduction, then score based</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1" alignment="Qt::AlignRight">
<widget class="QRadioButton" name="rb_Reduction"> <widget class="QPushButton" name="pb_Reset">
<property name="text"> <property name="text">
<string>reduction</string> <string>reset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_PickStrategy">
<property name="title">
<string>Similar results (strategy)</string>
</property>
<layout class="QHBoxLayout" name="hl_PickStrategy">
<item>
<widget class="QRadioButton" name="rb_PickFirst">
<property name="text">
<string>first</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_PickRandom">
<property name="text">
<string>random</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_PickByOrder">
<property name="text">
<string>order (higher rank first)</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -55,28 +92,35 @@
<string>Reduction</string> <string>Reduction</string>
</property> </property>
<layout class="QGridLayout" name="gl_Mode"> <layout class="QGridLayout" name="gl_Mode">
<item row="3" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="cb_ByCombinedCode"> <widget class="QRadioButton" name="rb_ByIcaoDataAirline1st">
<property name="text"> <property name="text">
<string>combined code</string> <string>by ICAO: airline first</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="cb_ByLivery">
<property name="text">
<string>by livery</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cb_ByFamily"> <widget class="QCheckBox" name="cb_ByFamily">
<property name="text"> <property name="text">
<string>by family</string> <string>by family</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="4" column="1">
<widget class="QCheckBox" name="cb_ByCombinedCode">
<property name="text">
<string>combined code</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="cb_ByLivery">
<property name="text">
<string>by livery</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cb_ByModelString"> <widget class="QCheckBox" name="cb_ByModelString">
<property name="text"> <property name="text">
<string>by model string</string> <string>by model string</string>
@@ -90,10 +134,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="rb_ByIcaoDataAirline1st"> <widget class="Line" name="line_Reduction">
<property name="text"> <property name="orientation">
<string>by ICAO: airline first</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
@@ -128,11 +172,15 @@
<tabstops> <tabstops>
<tabstop>rb_ScoreBased</tabstop> <tabstop>rb_ScoreBased</tabstop>
<tabstop>rb_Reduction</tabstop> <tabstop>rb_Reduction</tabstop>
<tabstop>pb_Reset</tabstop>
<tabstop>rb_PickFirst</tabstop>
<tabstop>rb_PickRandom</tabstop>
<tabstop>rb_PickByOrder</tabstop>
<tabstop>rb_ByIcaoDataAircraft1st</tabstop> <tabstop>rb_ByIcaoDataAircraft1st</tabstop>
<tabstop>rb_ByIcaoDataAirline1st</tabstop> <tabstop>rb_ByIcaoDataAirline1st</tabstop>
<tabstop>cb_ByModelString</tabstop> <tabstop>cb_ByModelString</tabstop>
<tabstop>cb_ByFamily</tabstop>
<tabstop>cb_ByLivery</tabstop> <tabstop>cb_ByLivery</tabstop>
<tabstop>cb_ByFamily</tabstop>
<tabstop>cb_ByCombinedCode</tabstop> <tabstop>cb_ByCombinedCode</tabstop>
<tabstop>cb_ScorePreferColorLiveries</tabstop> <tabstop>cb_ScorePreferColorLiveries</tabstop>
<tabstop>cb_ScoreIgnoreZeros</tabstop> <tabstop>cb_ScoreIgnoreZeros</tabstop>