mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T298, exclude models
This commit is contained in:
@@ -48,7 +48,7 @@ namespace BlackMisc
|
||||
//! Max.key value (making sense with integer key)
|
||||
KEYTYPE getMaxKey(bool *ok = nullptr) const;
|
||||
|
||||
//! Remove objects with key
|
||||
//! Remove objects with keys
|
||||
int removeObjectsWithKeys(const QSet<KEYTYPE> &keys);
|
||||
|
||||
//! Remove objects without key
|
||||
|
||||
@@ -523,39 +523,33 @@ namespace BlackMisc
|
||||
int CAircraftModelList::removeAllWithoutModelString()
|
||||
{
|
||||
if (this->isEmpty()) { return 0; }
|
||||
int c = 0;
|
||||
for (auto it = this->begin(); it != this->end();)
|
||||
const int s = this->size();
|
||||
CAircraftModelList withModelStr;
|
||||
for (const CAircraftModel &model : *this)
|
||||
{
|
||||
if (it->hasModelString())
|
||||
{
|
||||
++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
c++;
|
||||
it = this->erase(it);
|
||||
}
|
||||
if (!model.hasModelString()) { continue; }
|
||||
withModelStr.push_back(model);
|
||||
}
|
||||
return c;
|
||||
const int diff = s - withModelStr.size();
|
||||
if (diff < 1) { return 0; }
|
||||
*this = withModelStr;
|
||||
return diff;
|
||||
}
|
||||
|
||||
int CAircraftModelList::removeIfExcluded()
|
||||
{
|
||||
if (this->isEmpty()) { return 0; }
|
||||
int c = 0;
|
||||
for (auto it = this->begin(); it != this->end();)
|
||||
const int s = this->size();
|
||||
CAircraftModelList onlyIncluded;
|
||||
for (const CAircraftModel &model : *this)
|
||||
{
|
||||
if (it->getModelMode() != CAircraftModel::Exclude)
|
||||
{
|
||||
++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
c++;
|
||||
it = this->erase(it);
|
||||
}
|
||||
if (model.getModelMode() == CAircraftModel::Exclude) { continue; }
|
||||
onlyIncluded.push_back(model);
|
||||
}
|
||||
return c;
|
||||
const int diff = s - onlyIncluded.size();
|
||||
if (diff < 1) { return 0; }
|
||||
*this = onlyIncluded;
|
||||
return diff;
|
||||
}
|
||||
|
||||
int CAircraftModelList::replaceOrAddModelsWithString(const CAircraftModelList &addOrReplaceList, Qt::CaseSensitivity sensitivity)
|
||||
|
||||
Reference in New Issue
Block a user