mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #618, allow to filter my include/exclude
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
#include "aircraftmodelfilterbar.h"
|
||||
#include "ui_aircraftmodelfilterbar.h"
|
||||
#include "blackgui/uppercasevalidator.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Components;
|
||||
@@ -34,6 +36,10 @@ namespace BlackGui
|
||||
connect(ui->le_LiveryCode, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_ModelDescription, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
connect(ui->le_ModelKey, &QLineEdit::returnPressed, this, &CFilterWidget::triggerFilter);
|
||||
|
||||
connect(ui->cb_Include, &QCheckBox::toggled, this, &CAircraftModelFilterBar::ps_checkBoxChanged);
|
||||
connect(ui->cb_Exclude, &QCheckBox::toggled, this, &CAircraftModelFilterBar::ps_checkBoxChanged);
|
||||
|
||||
connect(ui->frp_SimulatorSelector, &CSimulatorSelector::changed, this, &CAircraftModelFilterBar::ps_simulatorSelectionChanged);
|
||||
connect(ui->comp_DistributorSelector, &CDbDistributorSelectorComponent::changedDistributor, this, &CAircraftModelFilterBar::ps_distributorChanged);
|
||||
|
||||
@@ -52,10 +58,13 @@ namespace BlackGui
|
||||
|
||||
std::unique_ptr<BlackGui::Models::IModelFilter<BlackMisc::Simulation::CAircraftModelList> > CAircraftModelFilterBar::createModelFilter() const
|
||||
{
|
||||
CAircraftModel::ModelModeFilter mf = this->ui->cb_Include->isChecked() ? CAircraftModel::Include : CAircraftModel::Undefined;
|
||||
if (this->ui->cb_Exclude->isChecked()) { mf |= CAircraftModel::Exclude; }
|
||||
return std::unique_ptr<CAircraftModelFilter>(
|
||||
new CAircraftModelFilter(
|
||||
this->ui->le_ModelKey->text(),
|
||||
this->ui->le_ModelDescription->text(),
|
||||
mf,
|
||||
this->ui->le_AircraftIcao->text(),
|
||||
this->ui->le_AircraftManufacturer->text(),
|
||||
this->ui->le_AirlineIcao->text(),
|
||||
@@ -82,6 +91,8 @@ namespace BlackGui
|
||||
this->ui->le_LiveryCode->clear();
|
||||
this->ui->frp_SimulatorSelector->setAll();
|
||||
this->ui->comp_DistributorSelector->clear();
|
||||
this->ui->cb_Exclude->setChecked(true);
|
||||
this->ui->cb_Include->setChecked(true);
|
||||
}
|
||||
|
||||
void CAircraftModelFilterBar::ps_simulatorSelectionChanged(const BlackMisc::Simulation::CSimulatorInfo &info)
|
||||
@@ -95,5 +106,11 @@ namespace BlackGui
|
||||
Q_UNUSED(distributor);
|
||||
this->triggerFilter();
|
||||
}
|
||||
|
||||
void CAircraftModelFilterBar::ps_checkBoxChanged(bool state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
triggerFilter();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -57,6 +57,9 @@ namespace BlackGui
|
||||
//! Distributor changed
|
||||
void ps_distributorChanged(const BlackMisc::Simulation::CDistributor &distributor);
|
||||
|
||||
//! Checkbox has been changed
|
||||
void ps_checkBoxChanged(bool state);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftModelFilterBar> ui;
|
||||
};
|
||||
|
||||
@@ -38,10 +38,92 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="11">
|
||||
<widget class="QLineEdit" name="le_AircraftManufacturer">
|
||||
<item row="0" column="5">
|
||||
<widget class="QWidget" name="wi_IncludeExclude" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_IncludeExclude">
|
||||
<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="QCheckBox" name="cb_Include">
|
||||
<property name="toolTip">
|
||||
<string>Included models</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>In.</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Exclude">
|
||||
<property name="toolTip">
|
||||
<string>Excluded models</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ex.</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="BlackGui::Components::CDbDistributorSelectorComponent" name="comp_DistributorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="frp_SimulatorSelector"/>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QLineEdit" name="le_AirlineIcao">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Manufacturer</string>
|
||||
<string>ICAO</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -65,26 +147,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="10">
|
||||
<widget class="QLineEdit" name="le_AirlineIcao">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="11">
|
||||
<widget class="QLineEdit" name="le_AircraftManufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>ICAO</string>
|
||||
<string>Manufacturer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QLineEdit" name="le_LiveryCode">
|
||||
<property name="placeholderText">
|
||||
<string>Code</string>
|
||||
<item row="1" column="9">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -95,6 +168,13 @@
|
||||
</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="6">
|
||||
<widget class="QLabel" name="lbl_Livery">
|
||||
<property name="text">
|
||||
@@ -102,13 +182,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="9">
|
||||
<widget class="QLabel" name="lbl_Airline">
|
||||
<property name="text">
|
||||
<string>Airline:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="text">
|
||||
@@ -119,13 +192,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLineEdit" name="le_ModelKey">
|
||||
<property name="placeholderText">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QLabel" name="lbl_Aircraft">
|
||||
<property name="text">
|
||||
@@ -133,48 +199,10 @@
|
||||
</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>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="hs_FilterButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="frp_SimulatorSelector"/>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="BlackGui::Components::CDbDistributorSelectorComponent" name="comp_DistributorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<item row="0" column="7">
|
||||
<widget class="QLineEdit" name="le_ModelKey">
|
||||
<property name="placeholderText">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -16,15 +16,13 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
|
||||
CAircraftModelFilter::CAircraftModelFilter(
|
||||
const QString &modelKey, const QString &description,
|
||||
CAircraftModelFilter::CAircraftModelFilter(const QString &modelKey, const QString &description, CAircraftModel::ModelModeFilter modelMode,
|
||||
const QString &aircraftIcao, const QString &aircraftManufacturer,
|
||||
const QString &airlineIcao, const QString &airlineName,
|
||||
const QString &liveryCode,
|
||||
const CSimulatorInfo &simInfo,
|
||||
const CDistributor &distributor) :
|
||||
m_modelKey(modelKey.trimmed()), m_description(description.trimmed()),
|
||||
m_modelKey(modelKey.trimmed().toUpper()), m_description(description.trimmed()), m_modelMode(modelMode),
|
||||
m_aircraftIcao(aircraftIcao.trimmed().toUpper()), m_aircraftManufacturer(aircraftManufacturer.trimmed().toUpper()),
|
||||
m_airlineIcao(airlineIcao.trimmed().toUpper()), m_airlineName(airlineName.trimmed().toUpper()),
|
||||
m_liveryCode(liveryCode.trimmed().toUpper()),
|
||||
@@ -53,6 +51,11 @@ namespace BlackGui
|
||||
if (!this->stringMatchesFilterExpression(model.getDescription(), this->m_description)) { continue; }
|
||||
}
|
||||
|
||||
if (this->m_modelMode != CAircraftModel::Undefined)
|
||||
{
|
||||
if (!model.matchesMode(this->m_modelMode)) { continue; }
|
||||
}
|
||||
|
||||
if (!this->m_aircraftIcao.isEmpty())
|
||||
{
|
||||
if (!this->stringMatchesFilterExpression(model.getAircraftIcaoCodeDesignator(), this->m_aircraftIcao)) { continue; }
|
||||
@@ -91,6 +94,7 @@ namespace BlackGui
|
||||
bool CAircraftModelFilter::isValid() const
|
||||
{
|
||||
return !(this->m_modelKey.isEmpty() && this->m_description.isEmpty() &&
|
||||
(this->m_modelMode != CAircraftModel::Undefined && this->m_modelMode != CAircraftModel::All) &&
|
||||
this->m_aircraftManufacturer.isEmpty() && this->m_aircraftIcao.isEmpty() &&
|
||||
this->m_airlineIcao.isEmpty() && this->m_airlineName.isEmpty() &&
|
||||
this->m_liveryCode.isEmpty() &&
|
||||
|
||||
@@ -20,13 +20,12 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
|
||||
//! Filter for aircraft models
|
||||
class BLACKGUI_EXPORT CAircraftModelFilter : public IModelFilter<BlackMisc::Simulation::CAircraftModelList>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CAircraftModelFilter(const QString &modelKey, const QString &description,
|
||||
CAircraftModelFilter(const QString &modelKey, const QString &description, BlackMisc::Simulation::CAircraftModel::ModelModeFilter modelMode,
|
||||
const QString &aircraftIcao, const QString &aircraftManufacturer,
|
||||
const QString &airlineIcao, const QString &airlineName,
|
||||
const QString &liveryCode,
|
||||
@@ -43,6 +42,7 @@ namespace BlackGui
|
||||
private:
|
||||
QString m_modelKey;
|
||||
QString m_description;
|
||||
BlackMisc::Simulation::CAircraftModel::ModelModeFilter m_modelMode;
|
||||
QString m_aircraftIcao;
|
||||
QString m_aircraftManufacturer;
|
||||
QString m_airlineIcao;
|
||||
|
||||
@@ -295,6 +295,11 @@ namespace BlackMisc
|
||||
return distributors.matchesAnyKeyOrAlias(this->m_distributor.getDbKey());
|
||||
}
|
||||
|
||||
bool CAircraftModel::matchesMode(ModelModeFilter mode) const
|
||||
{
|
||||
return (mode & this->m_modelMode) > 0;
|
||||
}
|
||||
|
||||
const CIcon &CAircraftModel::getModelModeAsIcon() const
|
||||
{
|
||||
switch (this->getModelMode())
|
||||
@@ -303,6 +308,8 @@ namespace BlackMisc
|
||||
return CIconList::iconByIndex(CIcons::ModelInclude);
|
||||
case Exclude:
|
||||
return CIconList::iconByIndex(CIcons::ModelExclude);
|
||||
case Undefined:
|
||||
return CIconList::iconByIndex(CIcons::StandardIconUnknown16);
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong mode");
|
||||
break;
|
||||
@@ -332,6 +339,7 @@ namespace BlackMisc
|
||||
if (this->m_fileName.isEmpty()) { this->setFileName(otherModel.getFileName()); }
|
||||
if (this->m_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); }
|
||||
if (this->m_modelType == TypeUnknown) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_modelMode == Undefined) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_simulator.isUnspecified())
|
||||
{
|
||||
this->setSimulatorInfo(otherModel.getSimulatorInfo());
|
||||
|
||||
@@ -49,10 +49,14 @@ namespace BlackMisc
|
||||
//! Mode
|
||||
enum ModelMode
|
||||
{
|
||||
Include,
|
||||
Exclude
|
||||
Undefined = 0,
|
||||
Include = 1 << 0,
|
||||
Exclude = 1 << 1
|
||||
};
|
||||
|
||||
//! Supposed to be used only in filter operations
|
||||
Q_DECLARE_FLAGS(ModelModeFilter, ModelMode)
|
||||
|
||||
//! Indexes
|
||||
enum ColumnIndex
|
||||
{
|
||||
@@ -201,6 +205,9 @@ namespace BlackMisc
|
||||
//! Model mode
|
||||
ModelMode getModelMode() const { return m_modelMode; }
|
||||
|
||||
//! Matches given mode?
|
||||
bool matchesMode(BlackMisc::Simulation::CAircraftModel::ModelModeFilter mode) const;
|
||||
|
||||
//! Model mode as string
|
||||
const QString &getModelModeAsString() const { return modelModeToString(getModelMode()); }
|
||||
|
||||
@@ -309,8 +316,11 @@ BLACK_DECLARE_TUPLE_CONVERSION(
|
||||
attr(o.m_modelType),
|
||||
attr(o.m_modelMode)
|
||||
))
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel::ModelType)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel::ModelMode)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CAircraftModel::ModelModeFilter)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::CAircraftModel::ModelModeFilter)
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user