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 "matchingform.h"
#include "guiutility.h"
#include <QPushButton>
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
@@ -24,6 +25,8 @@ namespace BlackGui
ui(new Ui::CMatchingForm)
{
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()
@@ -43,6 +46,9 @@ namespace BlackGui
ui->rb_ScoreBased->setEnabled(enabled);
ui->rb_ByIcaoDataAircraft1st->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
@@ -62,26 +68,22 @@ namespace BlackGui
ui->cb_ByFamily->setChecked(mode.testFlag(CAircraftMatcherSetup::ByFamily));
ui->cb_ScoreIgnoreZeros->setChecked(mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros));
ui->cb_ScorePreferColorLiveries->setChecked(mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries));
this->setMatchingAlgorithm(setup);
this->setPickStrategy(setup);
if (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased)
{
ui->rb_ScoreBased->setChecked(true);
}
else
{
ui->rb_Reduction->setChecked(true);
}
const bool scoring = (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased);
ui->gb_Scoring->setEnabled(scoring);
}
CAircraftMatcherSetup CMatchingForm::value() const
{
const CAircraftMatcherSetup setup(algorithm(), matchingMode());
const CAircraftMatcherSetup setup(algorithm(), matchingMode(), pickStrategy());
return setup;
}
void CMatchingForm::clear()
{
CAircraftMatcherSetup s;
const CAircraftMatcherSetup s(algorithm());
this->setValue(s);
}
@@ -101,5 +103,43 @@ namespace BlackGui
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

View File

@@ -55,6 +55,18 @@ namespace BlackGui
//! Mode
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;
};
} // ns

View File

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