mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Ref T578, allow to use workbench data in matcher component for testing
This commit is contained in:
committed by
Mat Sutcliffe
parent
246d9abca8
commit
305a1a34c2
@@ -134,6 +134,9 @@ namespace BlackGui
|
||||
this->onStashedModelsDataChangedDigest(ui->comp_StashAircraft->view()->rowCount(), ui->comp_StashAircraft->view()->hasFilter());
|
||||
this->onOwnModelsChangedDigest(ui->comp_OwnAircraftModels->view()->rowCount(), ui->comp_OwnAircraftModels->view()->hasFilter());
|
||||
|
||||
// allow to use workbench data
|
||||
ui->comp_ModelMatcher->setWorkbenchView(ui->comp_ModelWorkbench->view());
|
||||
|
||||
// how to display forms
|
||||
ui->editor_AircraftModel->setSelectOnly();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "simulatorselector.h"
|
||||
#include "blackgui/models/statusmessagelistmodel.h"
|
||||
#include "blackgui/views/statusmessageview.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackgui/uppercasevalidator.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
@@ -32,8 +33,8 @@
|
||||
#include <QCompleter>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QStringBuilder>
|
||||
#include <QTabWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QtGlobal>
|
||||
@@ -77,7 +78,10 @@ namespace BlackGui
|
||||
connect(ui->pb_ReverseLookup, &QPushButton::pressed, this, &CModelMatcherComponent::reverseLookup);
|
||||
connect(ui->pb_Settings, &QPushButton::pressed, this, &CModelMatcherComponent::displaySettingsDialog);
|
||||
|
||||
connect(ui->cb_UseWorkbench, &QCheckBox::toggled, this, &CModelMatcherComponent::onWorkbenchToggled);
|
||||
|
||||
this->redisplay();
|
||||
ui->cb_UseWorkbench->setVisible(false);
|
||||
}
|
||||
|
||||
CModelMatcherComponent::~CModelMatcherComponent()
|
||||
@@ -94,14 +98,51 @@ namespace BlackGui
|
||||
this->redisplay();
|
||||
}
|
||||
|
||||
void CModelMatcherComponent::setWorkbenchView(Views::CAircraftModelView *workbenchView)
|
||||
{
|
||||
if (workbenchView)
|
||||
{
|
||||
ui->cb_UseWorkbench->setVisible(true);
|
||||
m_workbenchView = workbenchView;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->cb_UseWorkbench->setVisible(false);
|
||||
m_workbenchView.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CModelMatcherComponent::onSimulatorChanged(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const CAircraftModelList models = CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator);
|
||||
m_matcher.setModelSet(models, simulator, true);
|
||||
|
||||
ui->tvp_ResultMessages->clear();
|
||||
if (this->useWorkbench())
|
||||
{
|
||||
const CAircraftModelList models = m_workbenchView->container();
|
||||
if (models.isEmpty())
|
||||
{
|
||||
CStatusMessage m(this, CStatusMessage::SeverityWarning, u"No models in workbench, disabled.");
|
||||
ui->tvp_ResultMessages->insert(m);
|
||||
return;
|
||||
}
|
||||
CSimulatorInfo simulator = models.simulatorsWithMaxEntries();
|
||||
m_matcher.setModelSet(models, simulator, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CAircraftModelList models = CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator);
|
||||
m_matcher.setModelSet(models, simulator, true);
|
||||
}
|
||||
this->redisplay();
|
||||
}
|
||||
|
||||
void CModelMatcherComponent::onWorkbenchToggled(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue());
|
||||
}
|
||||
|
||||
void CModelMatcherComponent::onCacheChanged(CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_UNUSED(simulator);
|
||||
@@ -118,7 +159,7 @@ namespace BlackGui
|
||||
{
|
||||
const QString liveryString(ui->comp_LiverySelector->getRawCombinedCode());
|
||||
const CAircraftModel reverseModel = CAircraftMatcher::reverseLookupModel(remoteAircraft.getModel(), liveryString, &msgs);
|
||||
remoteAircraft.setModel(reverseModel);
|
||||
remoteAircraft.setModel(reverseModel); // current model
|
||||
}
|
||||
|
||||
m_matcher.setDefaultModel(CModelMatcherComponent::defaultModel());
|
||||
@@ -163,8 +204,8 @@ namespace BlackGui
|
||||
|
||||
void CModelMatcherComponent::redisplay()
|
||||
{
|
||||
const int c = this->getModelSetModelsCount();
|
||||
ui->le_ModelSetCount->setText(QString::number(c));
|
||||
const int c = this->getMatcherModelsCount();
|
||||
ui->le_ModelSetCount->setText(QString::number(c) % (this->useWorkbench() ? u" (workbench)" : u""));
|
||||
}
|
||||
|
||||
CAircraftModelList CModelMatcherComponent::getModelSetModels() const
|
||||
@@ -174,11 +215,14 @@ namespace BlackGui
|
||||
return models;
|
||||
}
|
||||
|
||||
int CModelMatcherComponent::getModelSetModelsCount() const
|
||||
int CModelMatcherComponent::getMatcherModelsCount() const
|
||||
{
|
||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||
const int modelCount = CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModelsCount(simulator);
|
||||
return modelCount;
|
||||
return m_matcher.getModelSetCount();
|
||||
}
|
||||
|
||||
bool CModelMatcherComponent::useWorkbench() const
|
||||
{
|
||||
return ui->cb_UseWorkbench->isChecked() && m_workbenchView;
|
||||
}
|
||||
|
||||
CSimulatedAircraft CModelMatcherComponent::createAircraft() const
|
||||
|
||||
@@ -20,11 +20,13 @@
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CModelMatcherComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views { class CAircraftModelView; }
|
||||
namespace Components
|
||||
{
|
||||
class CSettingsMatchingDialog;
|
||||
@@ -41,15 +43,21 @@ namespace BlackGui
|
||||
explicit CModelMatcherComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CModelMatcherComponent();
|
||||
virtual ~CModelMatcherComponent() override;
|
||||
|
||||
//! Tab (where this component is embedded) has been changed
|
||||
void tabIndexChanged(int index);
|
||||
|
||||
//! Set an external
|
||||
void setWorkbenchView(Views::CAircraftModelView *workbenchView);
|
||||
|
||||
private:
|
||||
//! Simulator switched
|
||||
void onSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Workbench toggled
|
||||
void onWorkbenchToggled(bool checked);
|
||||
|
||||
//! Cache changed
|
||||
void onCacheChanged(BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
@@ -72,7 +80,10 @@ namespace BlackGui
|
||||
BlackMisc::Simulation::CAircraftModelList getModelSetModels() const;
|
||||
|
||||
//! The current model set models size
|
||||
int getModelSetModelsCount() const;
|
||||
int getMatcherModelsCount() const;
|
||||
|
||||
//! Use workbench data
|
||||
bool useWorkbench() const;
|
||||
|
||||
//! Pseudo aircraft created from entries
|
||||
BlackMisc::Simulation::CSimulatedAircraft createAircraft() const;
|
||||
@@ -81,6 +92,8 @@ namespace BlackGui
|
||||
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
||||
|
||||
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
||||
|
||||
QPointer<Views::CAircraftModelView> m_workbenchView; //!< an external workbenc
|
||||
CSettingsMatchingDialog *m_settingsDialog = nullptr; //!< matching settings as dialog
|
||||
BlackCore::CAircraftMatcher m_matcher { this }; //!< used matcher
|
||||
};
|
||||
|
||||
@@ -32,27 +32,21 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="BlackGui::Components::CAircraftCombinedTypeSelector" name="comp_CombinedCode">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="text">
|
||||
<string>Livery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="BlackGui::Components::CDbAircraftIcaoSelectorComponent" name="comp_AircraftSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -65,59 +59,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="4">
|
||||
<widget class="QFrame" name="fr_Results">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Results" stretch="1,3">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_Results">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CStatusMessageView" name="tvp_ResultMessages">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="BlackGui::Components::CDbLiverySelectorComponent" name="comp_LiverySelector">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="BlackGui::Components::CDbAirlineIcaoSelectorComponent" name="comp_AirlineSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="3">
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QFrame" name="fr_Buttons">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -182,69 +124,80 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_Model">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Aircraft">
|
||||
<property name="text">
|
||||
<string>Aircraft:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Combined">
|
||||
<property name="text">
|
||||
<string>Combined:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="text">
|
||||
<string>Livery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="le_ModelString">
|
||||
<property name="placeholderText">
|
||||
<string>model string</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
<string>Simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_Manufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. Cessna</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="QFrame" name="fr_Results">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Results" stretch="1,3">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_Results">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CStatusMessageView" name="tvp_ResultMessages">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Manufacturer">
|
||||
<property name="text">
|
||||
<string>Manufacturer:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="le_ModelString">
|
||||
<property name="placeholderText">
|
||||
<string>model string</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Aircraft">
|
||||
<property name="text">
|
||||
<string>Aircraft:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Model">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_ModelSetCount">
|
||||
<property name="text">
|
||||
@@ -252,27 +205,105 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_ModelSetCount">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLabel" name="lbl_Callsign">
|
||||
<property name="text">
|
||||
<string>Callsign:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="le_Callsign">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. DAMBZ</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
<string>Simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="BlackGui::Components::CDbLiverySelectorComponent" name="comp_LiverySelector">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QFrame" name="fr_ModelSet">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_ModelSet">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_ModelSetCount">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_UseWorkbench">
|
||||
<property name="text">
|
||||
<string>use workbench</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="BlackGui::Components::CDbAirlineIcaoSelectorComponent" name="comp_AirlineSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Combined">
|
||||
<property name="text">
|
||||
<string>Combined:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="lbl_Callsign">
|
||||
<property name="text">
|
||||
<string>Callsign:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
@@ -315,6 +346,7 @@
|
||||
<tabstops>
|
||||
<tabstop>comp_SimulatorSelector</tabstop>
|
||||
<tabstop>le_ModelSetCount</tabstop>
|
||||
<tabstop>cb_UseWorkbench</tabstop>
|
||||
<tabstop>comp_AircraftSelector</tabstop>
|
||||
<tabstop>comp_AirlineSelector</tabstop>
|
||||
<tabstop>comp_CombinedCode</tabstop>
|
||||
@@ -322,6 +354,7 @@
|
||||
<tabstop>le_Manufacturer</tabstop>
|
||||
<tabstop>le_Callsign</tabstop>
|
||||
<tabstop>le_ModelString</tabstop>
|
||||
<tabstop>pb_Settings</tabstop>
|
||||
<tabstop>pb_ReverseLookup</tabstop>
|
||||
<tabstop>pb_ModelMatching</tabstop>
|
||||
<tabstop>cb_withReverseLookup</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user