Matcher settings as dialog so they can be changed in mapping tool model matcher for testing

This commit is contained in:
Klaus Basan
2018-10-27 20:50:54 +02:00
parent 8c3c55afec
commit 541fd4bd61
9 changed files with 247 additions and 18 deletions

View File

@@ -7,18 +7,19 @@
* contained in the LICENSE file.
*/
#include "blackcore/webdataservices.h"
#include "blackgui/components/aircraftcombinedtypeselector.h"
#include "blackgui/components/dbaircrafticaoselectorcomponent.h"
#include "blackgui/components/dbairlineicaoselectorcomponent.h"
#include "blackgui/components/dbliveryselectorcomponent.h"
#include "blackgui/components/modelmatchercomponent.h"
#include "blackgui/components/simulatorselector.h"
#include "aircraftcombinedtypeselector.h"
#include "dbaircrafticaoselectorcomponent.h"
#include "dbairlineicaoselectorcomponent.h"
#include "dbliveryselectorcomponent.h"
#include "modelmatchercomponent.h"
#include "settingsmatchingdialog.h"
#include "simulatorselector.h"
#include "blackgui/models/statusmessagelistmodel.h"
#include "blackgui/views/statusmessageview.h"
#include "blackgui/uppercasevalidator.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/aviation/airlineicaocode.h"
@@ -71,9 +72,11 @@ namespace BlackGui
ui->le_Callsign->setValidator(validator);
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_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();
}
@@ -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()
{
const int c = this->getModelSetModelsCount();

View File

@@ -28,6 +28,8 @@ namespace BlackGui
{
namespace Components
{
class CSettingsMatchingDialog;
/*!
* Model matcher testing and configuration
*/
@@ -55,6 +57,9 @@ namespace BlackGui
//! Web data have been read
void onWebDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
//! Display settings dialog
void displaySettingsDialog();
//! Run the matcher
void testModelMatching();
@@ -77,6 +82,7 @@ namespace BlackGui
BlackMisc::Simulation::CAircraftModel defaultModel() const;
QScopedPointer<Ui::CModelMatcherComponent> ui;
CSettingsMatchingDialog *m_settingsDialog = nullptr;
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
};
} // ns

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>356</width>
<height>340</height>
<width>478</width>
<height>561</height>
</rect>
</property>
<property name="windowTitle">
@@ -139,6 +139,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_Settings">
<property name="text">
<string>settings</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_ReverseLookup">
<property name="text">
@@ -159,7 +166,7 @@
<string>use reverse lookup for model matching</string>
</property>
<property name="text">
<string>with lookup</string>
<string>with reverse lookup</string>
</property>
<property name="checked">
<bool>true</bool>

View File

@@ -32,22 +32,45 @@ namespace BlackGui
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);
}
this->deferredReload(5000);
}
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
{
IContextSimulator *simContext = simulatorContext();
if (!simContext) { return; }
const CAircraftMatcherSetup setup = ui->editor_MatchingForm->value();
const CAircraftMatcherSetup setup = ui->form_Matching->value();
simContext->setMatchingSetup(setup);
}
@@ -72,12 +95,12 @@ namespace BlackGui
void CSettingsMatchingComponent::deferredReload(int deferMs)
{
IContextSimulator *simContext = simulatorContext();
if (!simContext) { return; }
if (deferMs < 1)
{
IContextSimulator *simContext = simulatorContext();
if (!simContext) { return; }
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
ui->editor_MatchingForm->setValue(setup);
ui->form_Matching->setValue(setup);
}
else
{

View File

@@ -12,6 +12,7 @@
#ifndef BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
#define BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H
#include "blackmisc/simulation/aircraftmatchersetup.h"
#include <QFrame>
#include <QScopedPointer>
@@ -33,6 +34,15 @@ namespace BlackGui
//! Destructor
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:
QScopedPointer<Ui::CSettingsMatchingComponent> ui;

View File

@@ -54,7 +54,7 @@
<number>0</number>
</property>
<item>
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm">
<widget class="BlackGui::Editors::CMatchingForm" name="form_Matching">
<property name="minimumSize">
<size>
<width>0</width>
@@ -68,7 +68,7 @@
</widget>
</item>
<item>
<widget class="QFrame" name="fr_Butoons">
<widget class="QFrame" name="fr_Buttons">
<layout class="QHBoxLayout" name="hl_Buttons">
<item>
<spacer name="hs_Buttons">

View 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

View 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

View 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>