mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 12:45:40 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -18,101 +18,98 @@ using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
namespace BlackGui
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
namespace Components
|
||||
CSettingsMatchingComponent::CSettingsMatchingComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsMatchingComponent)
|
||||
{
|
||||
CSettingsMatchingComponent::CSettingsMatchingComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsMatchingComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
|
||||
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
||||
connect(ui->pb_MatchingAgain, &QPushButton::released, this, &CSettingsMatchingComponent::onMatchingsAgainPressed);
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
|
||||
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
||||
connect(ui->pb_MatchingAgain, &QPushButton::released, this, &CSettingsMatchingComponent::onMatchingsAgainPressed);
|
||||
|
||||
// also used in mapping tool, must also work without contexts
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (simContext)
|
||||
{
|
||||
connect(simContext, &IContextSimulator::matchingSetupChanged, this, &CSettingsMatchingComponent::onSetupChanged, Qt::QueuedConnection);
|
||||
this->deferredReload(5000);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->showButtons(false);
|
||||
}
|
||||
// also used in mapping tool, must also work without contexts
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (simContext)
|
||||
{
|
||||
connect(simContext, &IContextSimulator::matchingSetupChanged, this, &CSettingsMatchingComponent::onSetupChanged, Qt::QueuedConnection);
|
||||
this->deferredReload(5000);
|
||||
}
|
||||
|
||||
CSettingsMatchingComponent::~CSettingsMatchingComponent()
|
||||
{ }
|
||||
|
||||
CAircraftMatcherSetup CSettingsMatchingComponent::getMatchingSetup() const
|
||||
else
|
||||
{
|
||||
return ui->form_Matching->value();
|
||||
this->showButtons(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::setMatchingSetup(const CAircraftMatcherSetup &setup)
|
||||
CSettingsMatchingComponent::~CSettingsMatchingComponent()
|
||||
{ }
|
||||
|
||||
CAircraftMatcherSetup CSettingsMatchingComponent::getMatchingSetup() const
|
||||
{
|
||||
return ui->form_Matching->value();
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::setMatchingSetup(const CAircraftMatcherSetup &setup)
|
||||
{
|
||||
ui->form_Matching->setValue(setup);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::showButtons(bool show)
|
||||
{
|
||||
ui->fr_Buttons->setVisible(show);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onSavePressed() const
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
const CAircraftMatcherSetup setup = ui->form_Matching->value();
|
||||
simContext->setMatchingSetup(setup);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onReloadPressed()
|
||||
{
|
||||
this->deferredReload(0);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onMatchingsAgainPressed()
|
||||
{
|
||||
if (!sGui || !sGui->getISimulator() || !sGui->getISimulator()->isConnected()) { return; }
|
||||
const int reMatchedNo = sGui->getIContextSimulator()->doMatchingsAgain();
|
||||
CLogMessage(this).info(u"Triggered re-apping of %1 aircraft") << reMatchedNo;
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onSetupChanged()
|
||||
{
|
||||
const IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
this->deferredReload(0);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::deferredReload(int deferMs)
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
if (deferMs < 1)
|
||||
{
|
||||
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
||||
ui->form_Matching->setValue(setup);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::showButtons(bool show)
|
||||
else
|
||||
{
|
||||
ui->fr_Buttons->setVisible(show);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onSavePressed() const
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
const CAircraftMatcherSetup setup = ui->form_Matching->value();
|
||||
simContext->setMatchingSetup(setup);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onReloadPressed()
|
||||
{
|
||||
this->deferredReload(0);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onMatchingsAgainPressed()
|
||||
{
|
||||
if (!sGui || !sGui->getISimulator() || !sGui->getISimulator()->isConnected()) { return; }
|
||||
const int reMatchedNo = sGui->getIContextSimulator()->doMatchingsAgain();
|
||||
CLogMessage(this).info(u"Triggered re-apping of %1 aircraft") << reMatchedNo;
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onSetupChanged()
|
||||
{
|
||||
const IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
this->deferredReload(0);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::deferredReload(int deferMs)
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
if (deferMs < 1)
|
||||
QPointer<CSettingsMatchingComponent> myself(this);
|
||||
QTimer::singleShot(deferMs, this, [ = ]
|
||||
{
|
||||
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
||||
ui->form_Matching->setValue(setup);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPointer<CSettingsMatchingComponent> myself(this);
|
||||
QTimer::singleShot(deferMs, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->deferredReload(0);
|
||||
});
|
||||
}
|
||||
if (!myself) { return; }
|
||||
this->deferredReload(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
IContextSimulator *CSettingsMatchingComponent::simulatorContext()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return nullptr; }
|
||||
return sGui->getIContextSimulator();
|
||||
}
|
||||
} // ns
|
||||
IContextSimulator *CSettingsMatchingComponent::simulatorContext()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return nullptr; }
|
||||
return sGui->getIContextSimulator();
|
||||
}
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user