refs #618, allow to filter my include/exclude

This commit is contained in:
Klaus Basan
2016-03-21 04:14:30 +01:00
parent ec8f9b70b6
commit 7d785b4e3b
7 changed files with 158 additions and 88 deletions

View File

@@ -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());

View File

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