mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Ref T298, added algorithm and score values to matching setup
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "settingsmatchingcomponent.h"
|
||||
#include "ui_settingsmatchingcomponent.h"
|
||||
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Context;
|
||||
@@ -28,6 +28,7 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
|
||||
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
||||
this->deferredReload(5000);
|
||||
}
|
||||
|
||||
CSettingsMatchingComponent::~CSettingsMatchingComponent()
|
||||
@@ -43,10 +44,27 @@ namespace BlackGui
|
||||
|
||||
void CSettingsMatchingComponent::onReloadPressed()
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
||||
ui->editor_MatchingForm->setValue(setup);
|
||||
this->deferredReload(0);
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
@@ -42,6 +42,9 @@ namespace BlackGui
|
||||
//! Reload pressed
|
||||
void onReloadPressed();
|
||||
|
||||
//! Deferred reload
|
||||
void deferredReload(int deferMs);
|
||||
|
||||
//! Network context
|
||||
static BlackCore::Context::IContextSimulator *simulatorContext();
|
||||
};
|
||||
|
||||
@@ -6,21 +6,33 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
<width>232</width>
|
||||
<height>197</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
<string>Matching settings</string>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -32,10 +32,17 @@ namespace BlackGui
|
||||
void CMatchingForm::setReadOnly(bool 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_ByLivery, 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
|
||||
@@ -49,24 +56,49 @@ namespace BlackGui
|
||||
const CAircraftMatcherSetup::MatchingMode mode = setup.getMatchingMode();
|
||||
ui->cb_ByModelString->setChecked(mode.testFlag(CAircraftMatcherSetup::ByModelString));
|
||||
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_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 setup;
|
||||
setup.setMatchingMode(matchingMode());
|
||||
const CAircraftMatcherSetup setup(algorithm(), matchingMode());
|
||||
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
|
||||
{
|
||||
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_ByCombinedCode->isChecked()
|
||||
ui->cb_ByCombinedCode->isChecked(),
|
||||
ui->cb_ScoreIgnoreZeros->isChecked(), ui->cb_ScorePreferColorLiveries->isChecked()
|
||||
);
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace BlackGui
|
||||
void clear();
|
||||
|
||||
private:
|
||||
//! Algorithm
|
||||
BlackMisc::Simulation::CAircraftMatcherSetup::MatchingAlgorithm algorithm() const;
|
||||
|
||||
//! Mode
|
||||
BlackMisc::Simulation::CAircraftMatcherSetup::MatchingMode matchingMode() const;
|
||||
|
||||
|
||||
@@ -6,20 +6,69 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>287</width>
|
||||
<height>87</height>
|
||||
<width>243</width>
|
||||
<height>239</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QGroupBox" name="gb_Mode">
|
||||
<widget class="QGroupBox" name="gb_Algorithm">
|
||||
<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>
|
||||
<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">
|
||||
<widget class="QCheckBox" name="cb_ByModelString">
|
||||
<property name="text">
|
||||
@@ -27,28 +76,21 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cb_ByICAOdata">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cb_ByIcaoDataAirline1st">
|
||||
<property name="text">
|
||||
<string>by ICAO data</string>
|
||||
<string>by ICAO: airline first</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_ByFamily">
|
||||
<widget class="QCheckBox" name="cb_ByIcaoDataAircraft1st">
|
||||
<property name="text">
|
||||
<string>by family</string>
|
||||
<string>by ICAO: aircraft first</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cb_ByCombinedCode">
|
||||
<property name="text">
|
||||
<string>combined code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cb_ByLivery">
|
||||
<property name="text">
|
||||
<string>by livery</string>
|
||||
@@ -58,8 +100,43 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</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/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user