mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 11:56:57 +08:00
Distributor filter improvements
* if all or none simulator is selected do not filter * also select if there is no (NULL) simulator
This commit is contained in:
committed by
Mat Sutcliffe
parent
00b2034b2d
commit
1642502aae
@@ -25,13 +25,20 @@ namespace BlackGui
|
|||||||
CDistributorList CDistributorFilter::filter(const CDistributorList &inDistributors) const
|
CDistributorList CDistributorFilter::filter(const CDistributorList &inDistributors) const
|
||||||
{
|
{
|
||||||
if (!this->isValid()) { return inDistributors; }
|
if (!this->isValid()) { return inDistributors; }
|
||||||
|
if (this->ignoreSimulator()) { return inDistributors; }
|
||||||
|
|
||||||
CDistributorList outContainer;
|
CDistributorList outContainer;
|
||||||
for (const CDistributor &distributor : inDistributors)
|
for (const CDistributor &distributor : inDistributors)
|
||||||
{
|
{
|
||||||
if (!distributor.getSimulator().matchesAny(m_simulator)) { continue; }
|
if (!distributor.getSimulator().matchesAnyOrNone(m_simulator)) { continue; }
|
||||||
outContainer.push_back(distributor);
|
outContainer.push_back(distributor);
|
||||||
}
|
}
|
||||||
return outContainer;
|
return outContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDistributorFilter::ignoreSimulator() const
|
||||||
|
{
|
||||||
|
return (m_simulator.isNoSimulator() || m_simulator.isAllSimulators());
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ namespace BlackGui
|
|||||||
virtual BlackMisc::Simulation::CDistributorList filter(const BlackMisc::Simulation::CDistributorList &inDistributors) const override;
|
virtual BlackMisc::Simulation::CDistributorList filter(const BlackMisc::Simulation::CDistributorList &inDistributors) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Ignore simulator filtering?
|
||||||
|
bool ignoreSimulator() const;
|
||||||
|
|
||||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -144,15 +144,21 @@ namespace BlackMisc
|
|||||||
return (m_simulator & otherInfo.m_simulator) > 0;
|
return (m_simulator & otherInfo.m_simulator) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorInfo::matchesAnyOrNone(const CSimulatorInfo &otherInfo) const
|
||||||
|
{
|
||||||
|
if (this->isNoSimulator()) { return true; }
|
||||||
|
return this->matchesAny(otherInfo);
|
||||||
|
}
|
||||||
|
|
||||||
int CSimulatorInfo::comparePropertyByIndex(const CPropertyIndex &index, const CSimulatorInfo &compareValue) const
|
int CSimulatorInfo::comparePropertyByIndex(const CPropertyIndex &index, const CSimulatorInfo &compareValue) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(index);
|
Q_UNUSED(index)
|
||||||
return Compare::compare(m_simulator, compareValue.m_simulator);
|
return Compare::compare(m_simulator, compareValue.m_simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n)
|
||||||
const Simulator s = getSimulator();
|
const Simulator s = getSimulator();
|
||||||
const QString str =
|
const QString str =
|
||||||
(s.testFlag(FSX) ? QStringLiteral("FSX ") : QString()) %
|
(s.testFlag(FSX) ? QStringLiteral("FSX ") : QString()) %
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ namespace BlackMisc
|
|||||||
//! Matches any simulator
|
//! Matches any simulator
|
||||||
bool matchesAny(const CSimulatorInfo &otherInfo) const;
|
bool matchesAny(const CSimulatorInfo &otherInfo) const;
|
||||||
|
|
||||||
|
//! Matches any simulator or None (NULL)
|
||||||
|
//! \remark for cases where no specified sim. also matches
|
||||||
|
bool matchesAnyOrNone(const CSimulatorInfo &otherInfo) const;
|
||||||
|
|
||||||
//! Simulator
|
//! Simulator
|
||||||
Simulator getSimulator() const { return static_cast<Simulator>(m_simulator); }
|
Simulator getSimulator() const { return static_cast<Simulator>(m_simulator); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user