mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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
@@ -24,14 +24,21 @@ namespace BlackGui
|
||||
|
||||
CDistributorList CDistributorFilter::filter(const CDistributorList &inDistributors) const
|
||||
{
|
||||
if (!this->isValid()) { return inDistributors; }
|
||||
if (!this->isValid()) { return inDistributors; }
|
||||
if (this->ignoreSimulator()) { return inDistributors; }
|
||||
|
||||
CDistributorList outContainer;
|
||||
for (const CDistributor &distributor : inDistributors)
|
||||
{
|
||||
if (!distributor.getSimulator().matchesAny(m_simulator)) { continue; }
|
||||
if (!distributor.getSimulator().matchesAnyOrNone(m_simulator)) { continue; }
|
||||
outContainer.push_back(distributor);
|
||||
}
|
||||
return outContainer;
|
||||
}
|
||||
|
||||
bool CDistributorFilter::ignoreSimulator() const
|
||||
{
|
||||
return (m_simulator.isNoSimulator() || m_simulator.isAllSimulators());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -33,6 +33,9 @@ namespace BlackGui
|
||||
virtual BlackMisc::Simulation::CDistributorList filter(const BlackMisc::Simulation::CDistributorList &inDistributors) const override;
|
||||
|
||||
private:
|
||||
//! Ignore simulator filtering?
|
||||
bool ignoreSimulator() const;
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -144,15 +144,21 @@ namespace BlackMisc
|
||||
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
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index)
|
||||
return Compare::compare(m_simulator, compareValue.m_simulator);
|
||||
}
|
||||
|
||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
Q_UNUSED(i18n)
|
||||
const Simulator s = getSimulator();
|
||||
const QString str =
|
||||
(s.testFlag(FSX) ? QStringLiteral("FSX ") : QString()) %
|
||||
|
||||
@@ -132,6 +132,10 @@ namespace BlackMisc
|
||||
//! Matches any simulator
|
||||
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 getSimulator() const { return static_cast<Simulator>(m_simulator); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user