Ref T298, matching form added new ttributes

This commit is contained in:
Klaus Basan
2018-08-15 01:07:39 +02:00
parent f2b6b093e4
commit ef32ec266e
3 changed files with 84 additions and 41 deletions

View File

@@ -25,7 +25,10 @@ namespace BlackGui
ui(new Ui::CMatchingForm)
{
ui->setupUi(this);
connect(ui->rb_Reduction, &QRadioButton::toggled, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
connect(ui->rb_Reduction, &QRadioButton::released, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
connect(ui->rb_ScoreAndReduction, &QRadioButton::released, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
connect(ui->rb_ScoreOnly, &QRadioButton::released, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
connect(ui->pb_Reset, &QPushButton::released, this, &CMatchingForm::clear, Qt::QueuedConnection);
}
@@ -38,12 +41,15 @@ namespace BlackGui
CGuiUtility::checkBoxReadOnly(ui->cb_ByFamily, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByLivery, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByCombinedCode, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByVtol, readonly);
CGuiUtility::checkBoxReadOnly(ui->cb_ByMilitary, 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);
ui->rb_ScoreAndReduction->setEnabled(enabled);
ui->rb_ScoreOnly->setEnabled(enabled);
ui->rb_ByIcaoDataAircraft1st->setEnabled(enabled);
ui->rb_ByIcaoDataAirline1st->setEnabled(enabled);
ui->rb_PickFirst->setEnabled(enabled);
@@ -66,13 +72,13 @@ namespace BlackGui
ui->rb_ByIcaoDataAirline1st->setChecked(mode.testFlag(CAircraftMatcherSetup::ByIcaoOrderAirlineFirst));
ui->cb_ByLivery->setChecked(mode.testFlag(CAircraftMatcherSetup::ByLivery));
ui->cb_ByFamily->setChecked(mode.testFlag(CAircraftMatcherSetup::ByFamily));
ui->cb_ByMilitary->setChecked(mode.testFlag(CAircraftMatcherSetup::ByMilitary));
ui->cb_ByVtol->setChecked(mode.testFlag(CAircraftMatcherSetup::ByVtol));
ui->cb_ScoreIgnoreZeros->setChecked(mode.testFlag(CAircraftMatcherSetup::ScoreIgnoreZeros));
ui->cb_ScorePreferColorLiveries->setChecked(mode.testFlag(CAircraftMatcherSetup::ScorePreferColorLiveries));
this->setMatchingAlgorithm(setup);
this->setPickStrategy(setup);
const bool scoring = (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased);
ui->gb_Scoring->setEnabled(scoring);
}
CAircraftMatcherSetup CMatchingForm::value() const
@@ -90,7 +96,8 @@ namespace BlackGui
CAircraftMatcherSetup::MatchingAlgorithm CMatchingForm::algorithm() const
{
if (ui->rb_Reduction->isChecked()) { return CAircraftMatcherSetup::MatchingStepwiseReduce; }
return CAircraftMatcherSetup::MatchingScoreBased;
if (ui->rb_ScoreOnly->isChecked()) { return CAircraftMatcherSetup::MatchingScoreBased; }
return CAircraftMatcherSetup::MatchingStepwiseReducePlusScoreBased;
}
CAircraftMatcherSetup::MatchingMode CMatchingForm::matchingMode() const
@@ -100,6 +107,7 @@ namespace BlackGui
ui->rb_ByIcaoDataAircraft1st->isChecked(), ui->rb_ByIcaoDataAirline1st->isChecked(),
ui->cb_ByFamily->isChecked(), ui->cb_ByLivery->isChecked(),
ui->cb_ByCombinedCode->isChecked(),
ui->cb_ByMilitary->isChecked(), ui->cb_ByVtol->isChecked(),
ui->cb_ScoreIgnoreZeros->isChecked(), ui->cb_ScorePreferColorLiveries->isChecked()
);
}
@@ -125,19 +133,29 @@ namespace BlackGui
void CMatchingForm::setMatchingAlgorithm(const CAircraftMatcherSetup &setup)
{
if (setup.getMatchingAlgorithm() == CAircraftMatcherSetup::MatchingScoreBased)
{
ui->rb_ScoreBased->setChecked(true);
}
else
switch (setup.getMatchingAlgorithm())
{
case CAircraftMatcherSetup::MatchingStepwiseReduce:
ui->rb_Reduction->setChecked(true);
ui->gb_Reduction->setEnabled(true);
ui->gb_Scoring->setEnabled(false);
break;
case CAircraftMatcherSetup::MatchingScoreBased:
ui->rb_ScoreOnly->setChecked(true);
ui->gb_Reduction->setEnabled(false);
ui->gb_Scoring->setEnabled(true);
break;
case CAircraftMatcherSetup::MatchingStepwiseReducePlusScoreBased:
default:
ui->rb_ScoreAndReduction->setChecked(true);
ui->gb_Reduction->setEnabled(true);
ui->gb_Scoring->setEnabled(true);
break;
}
}
void CMatchingForm::onAlgorithmChanged(bool checked)
void CMatchingForm::onAlgorithmChanged()
{
Q_UNUSED(checked);
const CAircraftMatcherSetup setup = this->value();
this->setValue(setup);
}

View File

@@ -65,7 +65,7 @@ namespace BlackGui
void setMatchingAlgorithm(const BlackMisc::Simulation::CAircraftMatcherSetup &setup);
//! Algorithm has been toggled
void onAlgorithmChanged(bool checked);
void onAlgorithmChanged();
QScopedPointer<Ui::CMatchingForm> ui;
};

View File

@@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>247</width>
<height>304</height>
<height>348</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
<string>Matching form</string>
</property>
<layout class="QVBoxLayout" name="vl_MatchingForm">
<property name="leftMargin">
@@ -32,6 +32,13 @@
<string>Algorithm</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="rb_ScoreAndReduction">
<property name="text">
<string>reduction, then score based</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="rb_Reduction">
<property name="text">
@@ -39,14 +46,14 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="rb_ScoreBased">
<item row="2" column="0">
<widget class="QRadioButton" name="rb_ScoreOnly">
<property name="text">
<string>reduction, then score based</string>
<string>score only</string>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignRight">
<item row="0" column="1" rowspan="3" alignment="Qt::AlignLeft|Qt::AlignBottom">
<widget class="QPushButton" name="pb_Reset">
<property name="text">
<string>reset</string>
@@ -92,6 +99,13 @@
<string>Reduction</string>
</property>
<layout class="QGridLayout" name="gl_Mode">
<item row="4" column="0">
<widget class="QCheckBox" name="cb_ByFamily">
<property name="text">
<string>family</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="rb_ByIcaoDataAirline1st">
<property name="text">
@@ -99,13 +113,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="cb_ByFamily">
<property name="text">
<string>by family</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="cb_ByCombinedCode">
<property name="text">
@@ -113,17 +120,24 @@
</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>
<string>model string</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="cb_ByLivery">
<property name="text">
<string> livery</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line_Reduction">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
@@ -134,10 +148,20 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line_Reduction">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="5" column="0">
<widget class="QCheckBox" name="cb_ByMilitary">
<property name="text">
<string>military</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="cb_ByVtol">
<property name="toolTip">
<string>Vertical Takeoff or Landing</string>
</property>
<property name="text">
<string>VTOL (helicopters)</string>
</property>
</widget>
</item>
@@ -170,9 +194,8 @@
</layout>
</widget>
<tabstops>
<tabstop>rb_ScoreBased</tabstop>
<tabstop>rb_ScoreAndReduction</tabstop>
<tabstop>rb_Reduction</tabstop>
<tabstop>pb_Reset</tabstop>
<tabstop>rb_PickFirst</tabstop>
<tabstop>rb_PickRandom</tabstop>
<tabstop>rb_PickByOrder</tabstop>
@@ -182,6 +205,8 @@
<tabstop>cb_ByLivery</tabstop>
<tabstop>cb_ByFamily</tabstop>
<tabstop>cb_ByCombinedCode</tabstop>
<tabstop>cb_ByMilitary</tabstop>
<tabstop>cb_ByVtol</tabstop>
<tabstop>cb_ScorePreferColorLiveries</tabstop>
<tabstop>cb_ScoreIgnoreZeros</tabstop>
</tabstops>