mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T658, settings for matching (dirs/UI)
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
#include "ui_matchingform.h"
|
||||
#include "matchingform.h"
|
||||
#include "guiutility.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -29,6 +31,8 @@ namespace BlackGui
|
||||
connect(ui->rb_ScoreOnly, &QRadioButton::released, this, &CMatchingForm::onAlgorithmChanged, Qt::QueuedConnection);
|
||||
connect(ui->pb_ResetAlgorithm, &QPushButton::released, this, &CMatchingForm::resetByAlgorithm, Qt::QueuedConnection);
|
||||
connect(ui->pb_ResetAll, &QPushButton::released, this, &CMatchingForm::resetAll, Qt::QueuedConnection);
|
||||
connect(ui->pb_MsNetwork, &QPushButton::released, this, &CMatchingForm::fileDialog, Qt::QueuedConnection);
|
||||
connect(ui->pb_MsMatching, &QPushButton::released, this, &CMatchingForm::fileDialog, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
CMatchingForm::~CMatchingForm()
|
||||
@@ -61,6 +65,11 @@ namespace BlackGui
|
||||
ui->rb_PickFirst->setEnabled(enabled);
|
||||
ui->rb_PickByOrder->setEnabled(enabled);
|
||||
ui->rb_PickRandom->setEnabled(enabled);
|
||||
|
||||
ui->le_MsNetwork->setEnabled(enabled);
|
||||
ui->le_MsMatching->setEnabled(enabled);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_MsNetwork, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_MsMatching, readonly);
|
||||
}
|
||||
|
||||
CStatusMessageList CMatchingForm::validate(bool withNestedForms) const
|
||||
@@ -94,11 +103,20 @@ namespace BlackGui
|
||||
|
||||
this->setMatchingAlgorithm(setup);
|
||||
this->setPickStrategy(setup);
|
||||
|
||||
ui->cb_MsNetwork->setChecked(setup.isMsNetworkEntryEnabled());
|
||||
ui->cb_MsMatching->setChecked(setup.isMsMatchingStageEnabled());
|
||||
ui->le_MsNetwork->setText(setup.getMsNetworkEntryFile());
|
||||
ui->le_MsMatching->setText(setup.getMsMatchingStageFile());
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup CMatchingForm::value() const
|
||||
{
|
||||
const CAircraftMatcherSetup setup(algorithm(), matchingMode(), pickStrategy());
|
||||
CAircraftMatcherSetup setup(algorithm(), matchingMode(), pickStrategy());
|
||||
setup.setMsNetworkEntryFile(ui->le_MsNetwork->text());
|
||||
setup.setMsMatchingStageFile(ui->le_MsMatching->text());
|
||||
setup.setMsNetworkEntryEnabled(ui->cb_MsNetwork->isChecked());
|
||||
setup.setMsMatchingStageEnabled(ui->cb_MsMatching->isChecked());
|
||||
return setup;
|
||||
}
|
||||
|
||||
@@ -119,6 +137,23 @@ namespace BlackGui
|
||||
this->setValue(s);
|
||||
}
|
||||
|
||||
void CMatchingForm::fileDialog()
|
||||
{
|
||||
const bool nw = (QObject::sender() == ui->pb_MsNetwork);
|
||||
QString fn = nw ? ui->le_MsNetwork->text() : ui->le_MsMatching->text();
|
||||
fn = QFileDialog::getOpenFileName(nullptr, tr("Matching script"), fn, "Matching script (*.js)");
|
||||
const QFileInfo fi(fn);
|
||||
if (!fi.exists()) { return; }
|
||||
if (nw)
|
||||
{
|
||||
ui->le_MsNetwork->setText(fi.absoluteFilePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->le_MsMatching->setText(fi.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup::MatchingAlgorithm CMatchingForm::algorithm() const
|
||||
{
|
||||
if (ui->rb_Reduction->isChecked()) { return CAircraftMatcherSetup::MatchingStepwiseReduce; }
|
||||
@@ -193,6 +228,5 @@ namespace BlackGui
|
||||
const CAircraftMatcherSetup setup = this->value();
|
||||
this->setValue(setup);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -71,6 +71,9 @@ namespace BlackGui
|
||||
void resetAll();
|
||||
//! }
|
||||
|
||||
//! Directory browser
|
||||
void fileDialog();
|
||||
|
||||
QScopedPointer<Ui::CMatchingForm> ui;
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>293</width>
|
||||
<height>559</height>
|
||||
<height>647</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -70,6 +70,71 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_MatchingScript">
|
||||
<property name="title">
|
||||
<string>Matching script</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_MatchingSCript" columnstretch="0,1,0,0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_MsMatching">
|
||||
<property name="text">
|
||||
<string>Matching:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pb_MsMatching">
|
||||
<property name="text">
|
||||
<string>[...]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_MsNetwork">
|
||||
<property name="placeholderText">
|
||||
<string>network entry matching script file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_MsMatching">
|
||||
<property name="placeholderText">
|
||||
<string>matching stage matching script file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pb_MsNetwork">
|
||||
<property name="text">
|
||||
<string>[...]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_MsNetwork">
|
||||
<property name="text">
|
||||
<string>Network:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="cb_MsNetwork">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_MsMatching">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_PickStrategy">
|
||||
<property name="title">
|
||||
@@ -312,9 +377,17 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>pb_ResetAll</tabstop>
|
||||
<tabstop>rb_Reduction</tabstop>
|
||||
<tabstop>rb_ScoreOnly</tabstop>
|
||||
<tabstop>rb_ScoreAndReduction</tabstop>
|
||||
<tabstop>pb_ResetAlgorithm</tabstop>
|
||||
<tabstop>le_MsNetwork</tabstop>
|
||||
<tabstop>cb_MsNetwork</tabstop>
|
||||
<tabstop>pb_MsNetwork</tabstop>
|
||||
<tabstop>le_MsMatching</tabstop>
|
||||
<tabstop>cb_MsMatching</tabstop>
|
||||
<tabstop>pb_MsMatching</tabstop>
|
||||
<tabstop>rb_PickFirst</tabstop>
|
||||
<tabstop>rb_PickRandom</tabstop>
|
||||
<tabstop>rb_PickByOrder</tabstop>
|
||||
@@ -337,8 +410,6 @@
|
||||
<tabstop>cb_ExclNoDbData</tabstop>
|
||||
<tabstop>cb_ScorePreferColorLiveries</tabstop>
|
||||
<tabstop>cb_ScoreIgnoreZeros</tabstop>
|
||||
<tabstop>pb_ResetAll</tabstop>
|
||||
<tabstop>rb_Reduction</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace BlackMisc
|
||||
return u"algorithm: '" % this->getMatchingAlgorithmAsString() %
|
||||
u"' mode: '" % this->getMatchingModeAsString() %
|
||||
u"' strategy: '" % this->getPickStrategyAsString() %
|
||||
u'\'';
|
||||
u"\' matching script: " % boolToOnOff(m_msNetworkEnabled) % u'/' % boolToOnOff(m_msMatchingEnabled);
|
||||
}
|
||||
|
||||
CVariant CAircraftMatcherSetup::propertyByIndex(const CPropertyIndex &index) const
|
||||
@@ -80,9 +80,13 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMatchingAlgorithm: return CVariant::fromValue(m_algorithm);
|
||||
case IndexMatchingMode: return CVariant::fromValue(m_mode);
|
||||
case IndexPickStrategy: return CVariant::fromValue(m_strategy);
|
||||
case IndexMatchingAlgorithm: return CVariant::fromValue(m_algorithm);
|
||||
case IndexMatchingMode: return CVariant::fromValue(m_mode);
|
||||
case IndexPickStrategy: return CVariant::fromValue(m_strategy);
|
||||
case IndexMsNetworkEntryFile: return CVariant::fromValue(m_msNetworkEntryFile);
|
||||
case IndexMsMatchingStageFile: return CVariant::fromValue(m_msMatchingStageFile);
|
||||
case IndexMsNetworkEnabled: return CVariant::fromValue(m_msNetworkEnabled);
|
||||
case IndexMsMatchingStageEnabled: return CVariant::fromValue(m_msMatchingEnabled);
|
||||
default: break;
|
||||
}
|
||||
return CValueObject::propertyByIndex(index);
|
||||
@@ -97,6 +101,10 @@ namespace BlackMisc
|
||||
case IndexMatchingAlgorithm: m_algorithm = variant.toInt(); break;
|
||||
case IndexMatchingMode: m_mode = variant.toInt(); break;
|
||||
case IndexPickStrategy: m_strategy = variant.toInt(); break;
|
||||
case IndexMsNetworkEntryFile: m_msNetworkEntryFile = variant.toQString(); break;
|
||||
case IndexMsMatchingStageFile: m_msMatchingStageFile = variant.toQString(); break;
|
||||
case IndexMsNetworkEnabled: m_msNetworkEnabled = variant.toBool(); break;
|
||||
case IndexMsMatchingStageEnabled: m_msNetworkEnabled = variant.toBool(); break;
|
||||
default: break;
|
||||
}
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
@@ -105,6 +113,10 @@ namespace BlackMisc
|
||||
void CAircraftMatcherSetup::reset()
|
||||
{
|
||||
this->reset(MatchingStepwiseReducePlusScoreBased);
|
||||
m_msNetworkEntryFile.clear();
|
||||
m_msMatchingStageFile.clear();
|
||||
m_msNetworkEnabled = false;
|
||||
m_msMatchingEnabled = false;
|
||||
}
|
||||
|
||||
void CAircraftMatcherSetup::reset(CAircraftMatcherSetup::MatchingAlgorithm algorithm)
|
||||
|
||||
@@ -94,7 +94,11 @@ namespace BlackMisc
|
||||
{
|
||||
IndexMatchingAlgorithm = CPropertyIndex::GlobalIndexCAircraftMatcherSetup,
|
||||
IndexMatchingMode,
|
||||
IndexPickStrategy
|
||||
IndexPickStrategy,
|
||||
IndexMsNetworkEntryFile,
|
||||
IndexMsMatchingStageFile,
|
||||
IndexMsNetworkEnabled,
|
||||
IndexMsMatchingStageEnabled
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
@@ -118,6 +122,26 @@ namespace BlackMisc
|
||||
//! Matching mode
|
||||
MatchingMode getMatchingMode() const { return static_cast<MatchingMode>(m_mode); }
|
||||
|
||||
//! Get matching files @{
|
||||
const QString &getMsNetworkEntryFile() const { return m_msNetworkEntryFile; }
|
||||
const QString &getMsMatchingStageFile() const { return m_msMatchingStageFile; }
|
||||
//! @}
|
||||
|
||||
//! Set matching files @{
|
||||
void setMsNetworkEntryFile(const QString &file) { m_msNetworkEntryFile = file; }
|
||||
void setMsMatchingStageFile(const QString &file) { m_msMatchingStageFile = file; }
|
||||
//! @}
|
||||
|
||||
//! Is matching script enabled @{
|
||||
bool isMsNetworkEntryEnabled() const { return m_msNetworkEnabled; }
|
||||
bool isMsMatchingStageEnabled() const { return m_msMatchingEnabled; }
|
||||
//! @}
|
||||
|
||||
//! Is matching script enabled @{
|
||||
void setMsNetworkEntryEnabled(bool enabled) { m_msNetworkEnabled = enabled; }
|
||||
void setMsMatchingStageEnabled(bool enabled) { m_msMatchingEnabled = enabled; }
|
||||
//! @}
|
||||
|
||||
//! Verification at startup?
|
||||
//! \sa ModelVerificationOnStartup
|
||||
bool doVerificationAtStartup() const { return this->getMatchingMode().testFlag(ModelVerificationAtStartup); }
|
||||
@@ -199,12 +223,20 @@ namespace BlackMisc
|
||||
int m_algorithm = static_cast<int>(MatchingStepwiseReducePlusScoreBased);
|
||||
int m_mode = static_cast<int>(ModeDefaultReducePlusScore);
|
||||
int m_strategy = static_cast<int>(PickByOrder);
|
||||
QString m_msNetworkEntryFile; //!< network entry matching script file
|
||||
QString m_msMatchingStageFile; //!< matching stage matching script file
|
||||
bool m_msNetworkEnabled = false; //!< enable network matching script
|
||||
bool m_msMatchingEnabled = false; //!< enable matching stage matching script
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAircraftMatcherSetup,
|
||||
BLACK_METAMEMBER(algorithm),
|
||||
BLACK_METAMEMBER(mode),
|
||||
BLACK_METAMEMBER(strategy)
|
||||
BLACK_METAMEMBER(strategy),
|
||||
BLACK_METAMEMBER(msNetworkEntryFile),
|
||||
BLACK_METAMEMBER(msMatchingStageFile),
|
||||
BLACK_METAMEMBER(msNetworkEnabled),
|
||||
BLACK_METAMEMBER(msMatchingEnabled)
|
||||
);
|
||||
};
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user