mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Improve removeIf() to support set types
We can now replace QMutable*Iterator by removeIf() which usage is more consistent with other algorithm functions.
This commit is contained in:
parent
4ed8b31641
commit
c6f3da1097
7 changed files with 60 additions and 31 deletions
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <QDir>
|
||||
#include <QLocale>
|
||||
#include <QMutableListIterator>
|
||||
#include <QSettings>
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
|
@ -49,6 +48,7 @@
|
|||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "global.h"
|
||||
#include "settingsstorage.h"
|
||||
#include "utils/fs.h"
|
||||
|
@ -516,13 +516,12 @@ QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
|
|||
|
||||
void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets)
|
||||
{
|
||||
QMutableListIterator<QString> i(subnets);
|
||||
while (i.hasNext()) {
|
||||
Algorithm::removeIf(subnets, [](const QString &subnet)
|
||||
{
|
||||
bool ok = false;
|
||||
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(i.next().trimmed(), &ok);
|
||||
if (!ok)
|
||||
i.remove();
|
||||
}
|
||||
Utils::Net::parseSubnet(subnet.trimmed(), &ok);
|
||||
return !ok;
|
||||
});
|
||||
|
||||
setValue("Preferences/WebUI/AuthSubnetWhitelist", subnets);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue