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