From ef32ec266e79f4819cf75dc8124a44843a46e1aa Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 15 Aug 2018 01:07:39 +0200 Subject: [PATCH] Ref T298, matching form added new ttributes --- src/blackgui/editors/matchingform.cpp | 44 ++++++++++----- src/blackgui/editors/matchingform.h | 2 +- src/blackgui/editors/matchingform.ui | 79 ++++++++++++++++++--------- 3 files changed, 84 insertions(+), 41 deletions(-) diff --git a/src/blackgui/editors/matchingform.cpp b/src/blackgui/editors/matchingform.cpp index b4884bb12..994b9cbf1 100644 --- a/src/blackgui/editors/matchingform.cpp +++ b/src/blackgui/editors/matchingform.cpp @@ -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); } diff --git a/src/blackgui/editors/matchingform.h b/src/blackgui/editors/matchingform.h index 8705eae02..9d96aa76d 100644 --- a/src/blackgui/editors/matchingform.h +++ b/src/blackgui/editors/matchingform.h @@ -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; }; diff --git a/src/blackgui/editors/matchingform.ui b/src/blackgui/editors/matchingform.ui index 33e9b8a08..f39a8c1b5 100644 --- a/src/blackgui/editors/matchingform.ui +++ b/src/blackgui/editors/matchingform.ui @@ -7,11 +7,11 @@ 0 0 247 - 304 + 348 - Frame + Matching form @@ -32,6 +32,13 @@ Algorithm + + + + reduction, then score based + + + @@ -39,14 +46,14 @@ - - + + - reduction, then score based + score only - + reset @@ -92,6 +99,13 @@ Reduction + + + + family + + + @@ -99,13 +113,6 @@ - - - - by family - - - @@ -113,17 +120,24 @@ - - - - by livery - - - - by model string + model string + + + + + + + livery + + + + + + + Qt::Horizontal @@ -134,10 +148,20 @@ - - - - Qt::Horizontal + + + + military + + + + + + + Vertical Takeoff or Landing + + + VTOL (helicopters) @@ -170,9 +194,8 @@ - rb_ScoreBased + rb_ScoreAndReduction rb_Reduction - pb_Reset rb_PickFirst rb_PickRandom rb_PickByOrder @@ -182,6 +205,8 @@ cb_ByLivery cb_ByFamily cb_ByCombinedCode + cb_ByMilitary + cb_ByVtol cb_ScorePreferColorLiveries cb_ScoreIgnoreZeros