mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Matcher settings as dialog so they can be changed in mapping tool model matcher for testing
This commit is contained in:
@@ -7,18 +7,19 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackcore/webdataservices.h"
|
#include "aircraftcombinedtypeselector.h"
|
||||||
#include "blackgui/components/aircraftcombinedtypeselector.h"
|
#include "dbaircrafticaoselectorcomponent.h"
|
||||||
#include "blackgui/components/dbaircrafticaoselectorcomponent.h"
|
#include "dbairlineicaoselectorcomponent.h"
|
||||||
#include "blackgui/components/dbairlineicaoselectorcomponent.h"
|
#include "dbliveryselectorcomponent.h"
|
||||||
#include "blackgui/components/dbliveryselectorcomponent.h"
|
#include "modelmatchercomponent.h"
|
||||||
#include "blackgui/components/modelmatchercomponent.h"
|
#include "settingsmatchingdialog.h"
|
||||||
#include "blackgui/components/simulatorselector.h"
|
#include "simulatorselector.h"
|
||||||
#include "blackgui/models/statusmessagelistmodel.h"
|
#include "blackgui/models/statusmessagelistmodel.h"
|
||||||
#include "blackgui/views/statusmessageview.h"
|
#include "blackgui/views/statusmessageview.h"
|
||||||
#include "blackgui/uppercasevalidator.h"
|
#include "blackgui/uppercasevalidator.h"
|
||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/guiutility.h"
|
#include "blackgui/guiutility.h"
|
||||||
|
#include "blackcore/webdataservices.h"
|
||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||||
#include "blackmisc/aviation/airlineicaocode.h"
|
#include "blackmisc/aviation/airlineicaocode.h"
|
||||||
@@ -71,9 +72,11 @@ namespace BlackGui
|
|||||||
ui->le_Callsign->setValidator(validator);
|
ui->le_Callsign->setValidator(validator);
|
||||||
|
|
||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMatcherComponent::onSimulatorChanged);
|
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMatcherComponent::onSimulatorChanged);
|
||||||
|
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CModelMatcherComponent::onWebDataRead, Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(ui->pb_ModelMatching, &QPushButton::pressed, this, &CModelMatcherComponent::testModelMatching);
|
connect(ui->pb_ModelMatching, &QPushButton::pressed, this, &CModelMatcherComponent::testModelMatching);
|
||||||
connect(ui->pb_ReverseLookup, &QPushButton::pressed, this, &CModelMatcherComponent::reverseLookup);
|
connect(ui->pb_ReverseLookup, &QPushButton::pressed, this, &CModelMatcherComponent::reverseLookup);
|
||||||
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CModelMatcherComponent::onWebDataRead, Qt::QueuedConnection);
|
connect(ui->pb_Settings, &QPushButton::pressed, this, &CModelMatcherComponent::displaySettingsDialog);
|
||||||
|
|
||||||
this->redisplay();
|
this->redisplay();
|
||||||
}
|
}
|
||||||
@@ -146,6 +149,17 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModelMatcherComponent::displaySettingsDialog()
|
||||||
|
{
|
||||||
|
if (!m_settingsDialog) { m_settingsDialog = new CSettingsMatchingDialog(this); }
|
||||||
|
m_settingsDialog->setMatchingSetup(m_matcher.getSetup());
|
||||||
|
const QDialog::DialogCode r = static_cast<QDialog::DialogCode>(m_settingsDialog->exec());
|
||||||
|
if (r == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
m_settingsDialog->setMatchingSetup(m_settingsDialog->getMatchingSetup());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CModelMatcherComponent::redisplay()
|
void CModelMatcherComponent::redisplay()
|
||||||
{
|
{
|
||||||
const int c = this->getModelSetModelsCount();
|
const int c = this->getModelSetModelsCount();
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
class CSettingsMatchingDialog;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Model matcher testing and configuration
|
* Model matcher testing and configuration
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +57,9 @@ namespace BlackGui
|
|||||||
//! Web data have been read
|
//! Web data have been read
|
||||||
void onWebDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
void onWebDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
||||||
|
|
||||||
|
//! Display settings dialog
|
||||||
|
void displaySettingsDialog();
|
||||||
|
|
||||||
//! Run the matcher
|
//! Run the matcher
|
||||||
void testModelMatching();
|
void testModelMatching();
|
||||||
|
|
||||||
@@ -77,6 +82,7 @@ namespace BlackGui
|
|||||||
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
||||||
|
|
||||||
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
||||||
|
CSettingsMatchingDialog *m_settingsDialog = nullptr;
|
||||||
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
|
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>478</width>
|
||||||
<height>340</height>
|
<height>561</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -139,6 +139,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_Settings">
|
||||||
|
<property name="text">
|
||||||
|
<string>settings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pb_ReverseLookup">
|
<widget class="QPushButton" name="pb_ReverseLookup">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -159,7 +166,7 @@
|
|||||||
<string>use reverse lookup for model matching</string>
|
<string>use reverse lookup for model matching</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>with lookup</string>
|
<string>with reverse lookup</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@@ -32,22 +32,45 @@ namespace BlackGui
|
|||||||
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
||||||
connect(ui->pb_MatchingAgain, &QPushButton::released, this, &CSettingsMatchingComponent::onMatchingsAgainPressed);
|
connect(ui->pb_MatchingAgain, &QPushButton::released, this, &CSettingsMatchingComponent::onMatchingsAgainPressed);
|
||||||
|
|
||||||
|
// also used in mapping tool, must also work without contexts
|
||||||
IContextSimulator *simContext = simulatorContext();
|
IContextSimulator *simContext = simulatorContext();
|
||||||
if (simContext)
|
if (simContext)
|
||||||
{
|
{
|
||||||
connect(simContext, &IContextSimulator::matchingSetupChanged, this, &CSettingsMatchingComponent::onSetupChanged, Qt::QueuedConnection);
|
connect(simContext, &IContextSimulator::matchingSetupChanged, this, &CSettingsMatchingComponent::onSetupChanged, Qt::QueuedConnection);
|
||||||
|
this->deferredReload(5000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->showButtons(false);
|
||||||
}
|
}
|
||||||
this->deferredReload(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingsMatchingComponent::~CSettingsMatchingComponent()
|
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);
|
||||||
|
// ui->pb_MatchingAgain->setVisible(show);
|
||||||
|
// ui->pb_Reload->setVisible(show);
|
||||||
|
// ui->pb_Save->setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
void CSettingsMatchingComponent::onSavePressed() const
|
void CSettingsMatchingComponent::onSavePressed() const
|
||||||
{
|
{
|
||||||
IContextSimulator *simContext = simulatorContext();
|
IContextSimulator *simContext = simulatorContext();
|
||||||
if (!simContext) { return; }
|
if (!simContext) { return; }
|
||||||
const CAircraftMatcherSetup setup = ui->editor_MatchingForm->value();
|
const CAircraftMatcherSetup setup = ui->form_Matching->value();
|
||||||
simContext->setMatchingSetup(setup);
|
simContext->setMatchingSetup(setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,12 +95,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSettingsMatchingComponent::deferredReload(int deferMs)
|
void CSettingsMatchingComponent::deferredReload(int deferMs)
|
||||||
{
|
{
|
||||||
|
IContextSimulator *simContext = simulatorContext();
|
||||||
|
if (!simContext) { return; }
|
||||||
if (deferMs < 1)
|
if (deferMs < 1)
|
||||||
{
|
{
|
||||||
IContextSimulator *simContext = simulatorContext();
|
|
||||||
if (!simContext) { return; }
|
|
||||||
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
||||||
ui->editor_MatchingForm->setValue(setup);
|
ui->form_Matching->setValue(setup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
|
#ifndef BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
|
||||||
#define BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
|
#define BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
@@ -33,6 +34,15 @@ namespace BlackGui
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CSettingsMatchingComponent() override;
|
virtual ~CSettingsMatchingComponent() override;
|
||||||
|
|
||||||
|
//! Get setup
|
||||||
|
BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const;
|
||||||
|
|
||||||
|
//! Set setup
|
||||||
|
void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup);
|
||||||
|
|
||||||
|
//! Show buttons
|
||||||
|
void showButtons(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSettingsMatchingComponent> ui;
|
QScopedPointer<Ui::CSettingsMatchingComponent> ui;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm">
|
<widget class="BlackGui::Editors::CMatchingForm" name="form_Matching">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="fr_Butoons">
|
<widget class="QFrame" name="fr_Buttons">
|
||||||
<layout class="QHBoxLayout" name="hl_Buttons">
|
<layout class="QHBoxLayout" name="hl_Buttons">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="hs_Buttons">
|
<spacer name="hs_Buttons">
|
||||||
|
|||||||
39
src/blackgui/components/settingsmatchingdialog.cpp
Normal file
39
src/blackgui/components/settingsmatchingdialog.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "settingsmatchingdialog.h"
|
||||||
|
#include "ui_settingsmatchingdialog.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
CSettingsMatchingDialog::CSettingsMatchingDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::CSettingsMatchingDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettingsMatchingDialog::~CSettingsMatchingDialog()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CAircraftMatcherSetup CSettingsMatchingDialog::getMatchingSetup() const
|
||||||
|
{
|
||||||
|
return ui->comp_Settings->getMatchingSetup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsMatchingDialog::setMatchingSetup(const CAircraftMatcherSetup &setup)
|
||||||
|
{
|
||||||
|
ui->comp_Settings->setMatchingSetup(setup);
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
48
src/blackgui/components/settingsmatchingdialog.h
Normal file
48
src/blackgui/components/settingsmatchingdialog.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_COMPONENTS_SETTINGSMATCHINGDIALOG_H
|
||||||
|
#define BLACKGUI_COMPONENTS_SETTINGSMATCHINGDIALOG_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
namespace Ui { class CSettingsMatchingDialog; }
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
//! Matching settings as dialog
|
||||||
|
class CSettingsMatchingDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Matching settings as dialog
|
||||||
|
explicit CSettingsMatchingDialog(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CSettingsMatchingDialog();
|
||||||
|
|
||||||
|
//! Get setup
|
||||||
|
BlackMisc::Simulation::CAircraftMatcherSetup getMatchingSetup() const;
|
||||||
|
|
||||||
|
//! Set the setup
|
||||||
|
void setMatchingSetup(const BlackMisc::Simulation::CAircraftMatcherSetup &setup);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::CSettingsMatchingDialog> ui;
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
82
src/blackgui/components/settingsmatchingdialog.ui
Normal file
82
src/blackgui/components/settingsmatchingdialog.ui
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSettingsMatchingDialog</class>
|
||||||
|
<widget class="QDialog" name="CSettingsMatchingDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>640</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Matcher setup</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_MatchingDialog">
|
||||||
|
<item>
|
||||||
|
<widget class="BlackGui::Components::CSettingsMatchingComponent" name="comp_Settings">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="bb_SettingsMatchingDialog">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CSettingsMatchingComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/settingsmatchingcomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>bb_SettingsMatchingDialog</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>CSettingsMatchingDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>bb_SettingsMatchingDialog</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>CSettingsMatchingDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user