mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T75, filter aircraft model by id
This commit is contained in:
@@ -46,6 +46,7 @@ namespace BlackGui
|
||||
connect(ui->le_AirlineIcao, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_AirlineName, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_LiveryCode, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_Id, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_ModelDescription, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_ModelString, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_FileName, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
@@ -64,6 +65,7 @@ namespace BlackGui
|
||||
ui->le_ModelString->setValidator(ucv);
|
||||
ui->le_AircraftManufacturer->setValidator(ucv);
|
||||
ui->le_LiveryCode->setValidator(ucv);
|
||||
ui->le_Id->setValidator(new QIntValidator(ui->le_Id));
|
||||
|
||||
// reset form
|
||||
this->clearForm();
|
||||
@@ -100,6 +102,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
return std::make_unique<CAircraftModelFilter>(
|
||||
convertDbId(ui->le_Id->text()),
|
||||
ui->le_ModelString->text(),
|
||||
ui->le_ModelDescription->text(),
|
||||
mf,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<width>651</width>
|
||||
<height>72</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -111,7 +111,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="11">
|
||||
<item row="0" column="7">
|
||||
<widget class="QLineEdit" name="le_ModelString">
|
||||
<property name="placeholderText">
|
||||
<string>Key, i.e. model key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QLineEdit" name="le_AirlineIcao">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@@ -127,69 +134,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="12">
|
||||
<widget class="QLineEdit" name="le_AirlineName">
|
||||
<property name="placeholderText">
|
||||
<string>Airline name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLabel" name="lbl_Model">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="12">
|
||||
<item row="0" column="11">
|
||||
<widget class="QLineEdit" name="le_AircraftManufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>Manufacturer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="10">
|
||||
<item row="0" column="6">
|
||||
<widget class="QLabel" name="lbl_Model">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="11">
|
||||
<widget class="QLineEdit" name="le_AirlineName">
|
||||
<property name="placeholderText">
|
||||
<string>Airline name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="lbl_Aircraft">
|
||||
<property name="text">
|
||||
<string>Aircraft:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Livery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="QLineEdit" name="le_LiveryCode">
|
||||
<property name="placeholderText">
|
||||
<string>Code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<item row="0" column="4">
|
||||
<widget class="QCheckBox" name="cbt_Db">
|
||||
<property name="toolTip">
|
||||
<string>DB data?</string>
|
||||
@@ -202,36 +175,92 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4" alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::Filters::CFilterBarButtons" name="filter_Buttons">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<item row="1" column="9">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QCheckBox" name="cbt_IncludeExclude">
|
||||
<item row="1" column="6">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="toolTip">
|
||||
<string>Included/excluded models?</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Incl.</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
<string>Livery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="11" colspan="2">
|
||||
<item row="0" column="8">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QLineEdit" name="le_LiveryCode">
|
||||
<property name="placeholderText">
|
||||
<string>Code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QWidget" name="wi_Id" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_Id">
|
||||
<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="QLabel" name="lbl_Id">
|
||||
<property name="text">
|
||||
<string>Id:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Id">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="10" colspan="2">
|
||||
<widget class="BlackGui::Components::CDbDistributorSelectorComponent" name="comp_DistributorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
@@ -241,42 +270,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="10">
|
||||
<widget class="QLabel" name="lbl_Distributor">
|
||||
<property name="text">
|
||||
<string>Distributor:</string>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="BlackGui::Filters::CFilterBarButtons" name="filter_Buttons">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="9">
|
||||
<widget class="QCheckBox" name="cbt_ColorLiveries">
|
||||
<property name="toolTip">
|
||||
<string>Color liveries</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color liv.</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="6">
|
||||
<item row="2" column="0" colspan="5">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="frp_SimulatorSelector"/>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QCheckBox" name="cbt_Military">
|
||||
<property name="toolTip">
|
||||
<string>Military</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mil.</string>
|
||||
</property>
|
||||
<property name="tristate">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
CAircraftModelFilter::CAircraftModelFilter(const QString &modelKey, const QString &description,
|
||||
CAircraftModelFilter::CAircraftModelFilter(int id, const QString &modelKey, const QString &description,
|
||||
CAircraftModel::ModelModeFilter modelMode, BlackMisc::Db::DbKeyStateFilter dbKeyFilter,
|
||||
Qt::CheckState military, Qt::CheckState colorLiveries,
|
||||
const QString &aircraftIcao, const QString &aircraftManufacturer,
|
||||
@@ -27,6 +27,7 @@ namespace BlackGui
|
||||
const QString &liveryCode, const QString &fileName,
|
||||
const CSimulatorInfo &simInfo,
|
||||
const CDistributor &distributor) :
|
||||
m_id(id),
|
||||
m_modelKey(modelKey.trimmed().toUpper()), m_description(description.trimmed()),
|
||||
m_modelMode(modelMode), m_dbKeyFilter(dbKeyFilter), m_military(military), m_colorLiveries(colorLiveries),
|
||||
m_aircraftIcao(aircraftIcao.trimmed().toUpper()), m_aircraftManufacturer(aircraftManufacturer.trimmed().toUpper()),
|
||||
@@ -45,6 +46,17 @@ namespace BlackGui
|
||||
CAircraftModelList outContainer;
|
||||
for (const CAircraftModel &model : inContainer)
|
||||
{
|
||||
if (m_id >= 0)
|
||||
{
|
||||
// search only for id
|
||||
if (model.isLoadedFromDb() && model.getDbKey() == m_id)
|
||||
{
|
||||
outContainer.push_back(model);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_simulatorInfo.isAllSimulators())
|
||||
{
|
||||
if (!this->m_simulatorInfo.matchesAny(model.getSimulator())) { continue; }
|
||||
@@ -140,10 +152,12 @@ namespace BlackGui
|
||||
|
||||
bool CAircraftModelFilter::valid() const
|
||||
{
|
||||
const bool allEmpty = this->m_modelKey.isEmpty() && this->m_description.isEmpty() &&
|
||||
this->m_aircraftManufacturer.isEmpty() && this->m_aircraftIcao.isEmpty() &&
|
||||
this->m_airlineIcao.isEmpty() && this->m_airlineName.isEmpty() &&
|
||||
this->m_liveryCode.isEmpty() && this->m_fileName.isEmpty();
|
||||
const bool allEmpty =
|
||||
m_id < 0 &&
|
||||
this->m_modelKey.isEmpty() && this->m_description.isEmpty() &&
|
||||
this->m_aircraftManufacturer.isEmpty() && this->m_aircraftIcao.isEmpty() &&
|
||||
this->m_airlineIcao.isEmpty() && this->m_airlineName.isEmpty() &&
|
||||
this->m_liveryCode.isEmpty() && this->m_fileName.isEmpty();
|
||||
if (!allEmpty) { return true; }
|
||||
const bool noSim = this->m_simulatorInfo.isNoSimulator() || this->m_simulatorInfo.isAllSimulators();
|
||||
const bool noModelMode = this->m_modelMode == CAircraftModel::Undefined || this->m_modelMode == CAircraftModel::All;
|
||||
|
||||
@@ -31,22 +31,25 @@ namespace BlackGui
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CAircraftModelFilter(const QString &modelKey, const QString &description,
|
||||
BlackMisc::Simulation::CAircraftModel::ModelModeFilter modelMode,
|
||||
BlackMisc::Db::DbKeyStateFilter dbKeyFilter,
|
||||
Qt::CheckState military, Qt::CheckState colorLiveries,
|
||||
const QString &aircraftIcao, const QString &aircraftManufacturer,
|
||||
const QString &airlineIcao, const QString &airlineName,
|
||||
const QString &liveryCode,
|
||||
const QString &fileName,
|
||||
const BlackMisc::Simulation::CSimulatorInfo &simInfo = BlackMisc::Simulation::CSimulatorInfo::allSimulators(),
|
||||
const BlackMisc::Simulation::CDistributor &distributor = BlackMisc::Simulation::CDistributor()
|
||||
);
|
||||
CAircraftModelFilter(
|
||||
int id,
|
||||
const QString &modelKey, const QString &description,
|
||||
BlackMisc::Simulation::CAircraftModel::ModelModeFilter modelMode,
|
||||
BlackMisc::Db::DbKeyStateFilter dbKeyFilter,
|
||||
Qt::CheckState military, Qt::CheckState colorLiveries,
|
||||
const QString &aircraftIcao, const QString &aircraftManufacturer,
|
||||
const QString &airlineIcao, const QString &airlineName,
|
||||
const QString &liveryCode,
|
||||
const QString &fileName,
|
||||
const BlackMisc::Simulation::CSimulatorInfo &simInfo = BlackMisc::Simulation::CSimulatorInfo::allSimulators(),
|
||||
const BlackMisc::Simulation::CDistributor &distributor = BlackMisc::Simulation::CDistributor()
|
||||
);
|
||||
|
||||
//! \copydoc IModelFilter::filter
|
||||
virtual BlackMisc::Simulation::CAircraftModelList filter(const BlackMisc::Simulation::CAircraftModelList &inContainer) const override;
|
||||
|
||||
private:
|
||||
int m_id = -1;
|
||||
QString m_modelKey;
|
||||
QString m_description;
|
||||
BlackMisc::Simulation::CAircraftModel::ModelModeFilter m_modelMode;
|
||||
|
||||
Reference in New Issue
Block a user