Commit b7ac6986 authored by Jan Grulich's avatar Jan Grulich

Get rid of Q_FOREACH

parent 3a9706ba
......@@ -157,7 +157,7 @@ KCMNetworkmanagement::KCMNetworkmanagement(QWidget *parent, const QVariantList &
}
});
Q_FOREACH (const NetworkManager::Connection::Ptr &connection, connectionList) {
for (const NetworkManager::Connection::Ptr &connection : connectionList) {
const NetworkManager::ConnectionSettings::ConnectionType type = connection->settings()->connectionType();
if (UiUtils::isConnectionTypeSupported(type)) {
selectedConnection = connection;
......@@ -332,7 +332,7 @@ void KCMNetworkmanagement::onRequestCreateConnection(int connectionType, const Q
wifiSetting->setMode(NetworkManager::WirelessSetting::Adhoc);
wifiSetting->setSsid(i18n("my_shared_connection").toUtf8());
Q_FOREACH (const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr & device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Wifi) {
NetworkManager::WirelessDevice::Ptr wifiDev = device.objectCast<NetworkManager::WirelessDevice>();
if (wifiDev) {
......@@ -485,7 +485,7 @@ void KCMNetworkmanagement::importVpn()
// get the list of supported extensions
const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin");
QString extensions;
Q_FOREACH (const KService::Ptr &service, services) {
for (const KService::Ptr &service : services) {
VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
if (vpnPlugin) {
extensions += vpnPlugin->supportedFileExtensions() % QStringLiteral(" ");
......@@ -502,7 +502,7 @@ void KCMNetworkmanagement::importVpn()
const QString ext = QStringLiteral("*.") % fi.suffix();
qCDebug(PLASMA_NM) << "Importing VPN connection " << filename << "extension:" << ext;
Q_FOREACH (const KService::Ptr &service, services) {
for (const KService::Ptr &service : services) {
VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
if (vpnPlugin && vpnPlugin->supportedFileExtensions().contains(ext)) {
qCDebug(PLASMA_NM) << "Found VPN plugin" << service->name() << ", type:" << service->property("X-NetworkManager-Services", QVariant::String).toString();
......
......@@ -58,7 +58,7 @@ bool BluetoothMonitor::bluetoothConnectionExists(const QString &bdAddr, const QS
return false;
}
Q_FOREACH (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
for (const NetworkManager::Connection::Ptr &con : NetworkManager::listConnections()) {
if (con && con->settings() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Bluetooth) {
NetworkManager::BluetoothSetting::Ptr btSetting = con->settings()->setting(NetworkManager::Setting::Bluetooth).staticCast<NetworkManager::BluetoothSetting>();
if (btSetting->profileType() == profile && btSetting->bluetoothAddress() == NetworkManager::macAddressFromString(bdAddr)) {
......
......@@ -60,7 +60,7 @@ ModemMonitor::ModemMonitor(QObject * parent)
if (grp.isValid()) {
if (grp.readEntry(QLatin1String("UnlockModemOnDetection"), true)) {
connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &ModemMonitor::unlockModem);
Q_FOREACH (const ModemManager::ModemDevice::Ptr &iface, ModemManager::modemDevices()) {
for (const ModemManager::ModemDevice::Ptr &iface : ModemManager::modemDevices()) {
unlockModem(iface->uni());
}
}
......
......@@ -40,14 +40,14 @@ Notification::Notification(QObject *parent) :
QObject(parent)
{
// devices
Q_FOREACH (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
addDevice(device);
}
connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceAdded, this, &Notification::deviceAdded);
// connections
Q_FOREACH (const NetworkManager::ActiveConnection::Ptr &ac, NetworkManager::activeConnections()) {
for (const NetworkManager::ActiveConnection::Ptr &ac : NetworkManager::activeConnections()) {
addActiveConnection(ac);
}
......
......@@ -37,7 +37,7 @@ PinDialog::PinDialog(ModemManager::Modem *modem, const Type type, QWidget *paren
if (modem) {
m_udi = modem->uni();
m_name = modem->device();
Q_FOREACH (const Solid::Device &d, Solid::Device::allDevices()) {
for (const Solid::Device &d : Solid::Device::allDevices()) {
if (d.udi().contains(m_name, Qt::CaseInsensitive)) {
m_name = d.product();
if (!m_name.startsWith(d.vendor())) {
......
......@@ -71,7 +71,7 @@ NMVariantMapMap SecretAgent::GetSecrets(const NMVariantMapMap &connection, const
qCDebug(PLASMA_NM) << "Flags:" << flags;
const QString callId = connection_path.path() % setting_name;
Q_FOREACH (const SecretsRequest & request, m_calls) {
for (const SecretsRequest &request : m_calls) {
if (request == callId) {
qCWarning(PLASMA_NM) << "GetSecrets was called again! This should not happen, cancelling first call" << connection_path.path() << setting_name;
CancelGetSecrets(connection_path, setting_name);
......@@ -231,7 +231,7 @@ void SecretAgent::dialogAccepted()
}
// Load temporary secrets from auth dialog which are not returned to NM
Q_FOREACH (const QString &key, tmpOpenconnectSecrets.keys()) {
for (const QString &key : tmpOpenconnectSecrets.keys()) {
if (secrets.contains(QLatin1Literal("save_passwords")) && secrets.value(QLatin1Literal("save_passwords")) == QLatin1String("yes")) {
data.insert(key + QLatin1String("-flags"), QString::number(NetworkManager::Setting::AgentOwned));
} else {
......@@ -470,7 +470,7 @@ bool SecretAgent::processSaveSecrets(SecretsRequest &request) const
}
if (m_wallet->setFolder("Network Management")) {
Q_FOREACH (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
for (const NetworkManager::Setting::Ptr &setting : connectionSettings.settings()) {
NMStringMap secretsMap = setting->secretsToStringMap();
if (!secretsMap.isEmpty()) {
......@@ -506,9 +506,9 @@ bool SecretAgent::processDeleteSecrets(SecretsRequest &request) const
if (m_wallet->isOpen()) {
if (m_wallet->hasFolder("Network Management") && m_wallet->setFolder("Network Management")) {
NetworkManager::ConnectionSettings connectionSettings(request.connection);
Q_FOREACH (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
for (const NetworkManager::Setting::Ptr &setting : connectionSettings.settings()) {
QString entryName = QLatin1Char('{') % connectionSettings.uuid() % QLatin1Char('}') % QLatin1Char(';') % setting->name();
Q_FOREACH (const QString &entry, m_wallet->entryList()) {
for (const QString &entry : m_wallet->entryList()) {
if (entry.startsWith(entryName)) {
m_wallet->removeEntry(entryName);
}
......@@ -562,7 +562,7 @@ bool SecretAgent::useWallet() const
bool SecretAgent::hasSecrets(const NMVariantMapMap &connection) const
{
NetworkManager::ConnectionSettings connectionSettings(connection);
Q_FOREACH (const NetworkManager::Setting::Ptr &setting, connectionSettings.settings()) {
for (const NetworkManager::Setting::Ptr &setting : connectionSettings.settings()) {
if (!setting->secretsToMap().isEmpty()) {
return true;
}
......@@ -586,7 +586,7 @@ void SecretAgent::importSecretsFromPlainTextFiles()
// No action is required when the list of secrets is empty
if (!config.groupList().isEmpty()) {
Q_FOREACH (const QString &groupName, config.groupList()) {
for (const QString &groupName : config.groupList()) {
QString loadedUuid = groupName.split(';').first().remove('{').remove('}');
QString loadedSettingType = groupName.split(';').last();
NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(loadedUuid);
......@@ -595,7 +595,7 @@ void SecretAgent::importSecretsFromPlainTextFiles()
QMap<QString, QString> secrets = config.entryMap(groupName);
NMVariantMapMap settings = connection->settings()->toMap();
Q_FOREACH (const QString &setting, settings.keys()) {
for (const QString &setting : settings.keys()) {
if (setting == QLatin1String("vpn")) {
NetworkManager::VpnSetting::Ptr vpnSetting = connection->settings()->setting(NetworkManager::Setting::Vpn).staticCast<NetworkManager::VpnSetting>();
if (vpnSetting) {
......@@ -605,7 +605,7 @@ void SecretAgent::importSecretsFromPlainTextFiles()
NMStringMap vpnData = vpnSetting->data();
// Reset flags, we can't save secrets to our secret agent when KWallet is not enabled, because
// we dropped support for plaintext files, therefore they need to be stored to NetworkManager
Q_FOREACH (const QString &key, vpnData.keys()) {
for (const QString &key : vpnData.keys()) {
if (key.endsWith(QLatin1String("-flags"))) {
vpnData.insert(key, QString::number((int)secretFlags));
}
......@@ -620,7 +620,7 @@ void SecretAgent::importSecretsFromPlainTextFiles()
QVariantMap tmpSetting = settings.value(setting);
// Reset flags, we can't save secrets to our secret agent when KWallet is not enabled, because
// we dropped support for plaintext files, therefore they need to be stored to NetworkManager
Q_FOREACH (const QString &key, tmpSetting.keys()) {
for (const QString &key : tmpSetting.keys()) {
if (key.endsWith(QLatin1String("-flags"))) {
tmpSetting.insert(key, (int)secretFlags);
}
......
......@@ -29,7 +29,7 @@ AvailableDevices::AvailableDevices(QObject* parent)
, m_modemDeviceAvailable(false)
, m_bluetoothDeviceAvailable(false)
{
Q_FOREACH (const NetworkManager::Device::Ptr& device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Modem) {
m_modemDeviceAvailable = true;
} else if (device->type() == NetworkManager::Device::Wifi) {
......@@ -97,7 +97,7 @@ void AvailableDevices::deviceRemoved()
bool modem = false;
bool bluetooth = false;
Q_FOREACH (const NetworkManager::Device::Ptr& device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Modem) {
modem = true;
} else if (device->type() == NetworkManager::Device::Wifi) {
......
......@@ -61,7 +61,7 @@ ConnectionIcon::ConnectionIcon(QObject* parent)
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanEnabledChanged, this, &ConnectionIcon::wwanEnabledChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanHardwareEnabledChanged, this, &ConnectionIcon::wwanEnabledChanged);
Q_FOREACH (NetworkManager::Device::Ptr device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Ethernet) {
NetworkManager::WiredDevice::Ptr wiredDevice = device.staticCast<NetworkManager::WiredDevice>();
if (wiredDevice) {
......@@ -76,7 +76,7 @@ ConnectionIcon::ConnectionIcon(QObject* parent)
}
}
Q_FOREACH (NetworkManager::ActiveConnection::Ptr activeConnection, NetworkManager::activeConnections()) {
for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) {
addActiveConnection(activeConnection->path());
}
setStates();
......@@ -272,7 +272,7 @@ void ConnectionIcon::setStates()
{
bool connecting = false;
bool vpn = false;
Q_FOREACH (NetworkManager::ActiveConnection::Ptr activeConnection, NetworkManager::activeConnections()) {
for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) {
NetworkManager::VpnConnection::Ptr vpnConnection;
if (activeConnection->vpn()) {
vpnConnection = activeConnection.objectCast<NetworkManager::VpnConnection>();
......@@ -322,7 +322,7 @@ void ConnectionIcon::setIcons()
highest probability of being the main one (order is: vpn, wired, wireless, gsm, cdma, bluetooth) */
if ((!connection && !NetworkManager::activeConnections().isEmpty()) || (connection && connection->type() == NetworkManager::ConnectionSettings::Generic)
|| (connection && connection->type() == NetworkManager::ConnectionSettings::Tun)) {
Q_FOREACH (const NetworkManager::ActiveConnection::Ptr &activeConnection, NetworkManager::activeConnections()) {
for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) {
const NetworkManager::ConnectionSettings::ConnectionType type = activeConnection->type();
if (type == NetworkManager::ConnectionSettings::Bluetooth) {
if (connection && connection->type() <= NetworkManager::ConnectionSettings::Bluetooth) {
......@@ -421,7 +421,7 @@ void ConnectionIcon::setDisconnectedIcon()
m_limited = false;
m_vpn = false;
Q_FOREACH (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Ethernet) {
NetworkManager::WiredDevice::Ptr wiredDev = device.objectCast<NetworkManager::WiredDevice>();
if (wiredDev->carrier()) {
......
......@@ -93,7 +93,7 @@ QString NetworkStatus::networkStatus() const
void NetworkStatus::activeConnectionsChanged()
{
Q_FOREACH (const NetworkManager::ActiveConnection::Ptr & active, NetworkManager::activeConnections()) {
for (const NetworkManager::ActiveConnection::Ptr & active : NetworkManager::activeConnections()) {
connect(active.data(), &NetworkManager::ActiveConnection::default4Changed, this, &NetworkStatus::defaultChanged, Qt::UniqueConnection);
connect(active.data(), &NetworkManager::ActiveConnection::default6Changed, this, &NetworkStatus::defaultChanged, Qt::UniqueConnection);
connect(active.data(), &NetworkManager::ActiveConnection::stateChanged, this, &NetworkStatus::changeActiveConnections);
......@@ -165,7 +165,7 @@ void NetworkStatus::changeActiveConnections()
return NetworkStatus::connectionTypeToSortedType(left->type()) < NetworkStatus::connectionTypeToSortedType(right->type());
});
Q_FOREACH (const NetworkManager::ActiveConnection::Ptr & active, activeConnectionList) {
for (const NetworkManager::ActiveConnection::Ptr &active : activeConnectionList) {
if (!active->devices().isEmpty() && UiUtils::isConnectionTypeSupported(active->type())) {
NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first());
......
......@@ -100,7 +100,7 @@ NMVariantMapMap ConnectionEditorBase::setting() const
{
NMVariantMapMap settings = m_connectionWidget->setting();
Q_FOREACH (SettingWidget *widget, m_settingWidgets) {
for (SettingWidget *widget : m_settingWidgets) {
const QString type = widget->type();
if (type != NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x) &&
type != NetworkManager::Setting::typeAsString(NetworkManager::Setting::WirelessSecurity)) {
......@@ -296,7 +296,7 @@ void ConnectionEditorBase::initialize()
// Re-check validation
bool valid = true;
Q_FOREACH (SettingWidget *widget, m_settingWidgets) {
for (SettingWidget *widget : m_settingWidgets) {
valid = valid && widget->isValid();
connect(widget, &SettingWidget::validChanged, this, &ConnectionEditorBase::validChanged);
}
......@@ -397,7 +397,7 @@ void ConnectionEditorBase::initialize()
}
}
} else {
Q_FOREACH (const QString &secret, requiredSecrets) {
for (const QString &secret : requiredSecrets) {
if (setting.contains(secret + QLatin1String("-flags"))) {
NetworkManager::Setting::SecretFlagType secretFlag = (NetworkManager::Setting::SecretFlagType)setting.value(secret + QLatin1String("-flags")).toInt();
if (secretFlag == NetworkManager::Setting::None || secretFlag == NetworkManager::Setting::AgentOwned) {
......@@ -436,12 +436,12 @@ void ConnectionEditorBase::replyFinished(QDBusPendingCallWatcher *watcher)
const QString settingName = watcher->property("settingName").toString();
if (reply.isValid()) {
NMVariantMapMap secrets = reply.argumentAt<0>();
Q_FOREACH (const QString &key, secrets.keys()) {
for (const QString &key : secrets.keys()) {
if (key == settingName) {
NetworkManager::Setting::Ptr setting = m_connection->setting(NetworkManager::Setting::typeFromString(key));
if (setting) {
setting->secretsFromMap(secrets.value(key));
Q_FOREACH (SettingWidget *widget, m_settingWidgets) {
for (SettingWidget *widget : m_settingWidgets) {
const QString type = widget->type();
if (type == settingName ||
(settingName == NetworkManager::Setting::typeAsString(NetworkManager::Setting::Security8021x) &&
......@@ -476,7 +476,7 @@ void ConnectionEditorBase::validChanged(bool valid)
Q_EMIT validityChanged(false);
return;
} else {
Q_FOREACH (SettingWidget *widget, m_settingWidgets) {
for (SettingWidget *widget : m_settingWidgets) {
if (!widget->isValid()) {
m_valid = false;
Q_EMIT validityChanged(false);
......
......@@ -315,11 +315,11 @@ QVariantMap MobileProviders::getCdmaInfo(const QString & provider)
return temp;
}
QString MobileProviders::getNameByLocale(const QMap<QString, QString> & localizedNames) const
QString MobileProviders::getNameByLocale(const QMap<QString, QString> &localizedNames) const
{
QString name;
const QStringList locales = QLocale().uiLanguages();
Q_FOREACH (const QString & locale, locales) {
for (const QString &locale : locales) {
QString language = locale.split(QLatin1Char('-')).at(0);
if (localizedNames.contains(language)) {
......
......@@ -275,7 +275,7 @@ void BondWidget::populateBonds()
{
m_ui->bonds->clear();
Q_FOREACH (const NetworkManager::Connection::Ptr &connection, NetworkManager::listConnections()) {
for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) {
NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
if (settings->master() == m_uuid && settings->slaveType() == type()) {
const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
......@@ -293,7 +293,7 @@ bool BondWidget::isValid() const
return false;
}
Q_FOREACH (const QString & ip, ipAddresses) {
for (const QString &ip : ipAddresses) {
QHostAddress ipAddress(ip);
if (ipAddress.isNull()) {
return false;
......
......@@ -225,7 +225,7 @@ void BridgeWidget::populateBridges()
{
m_ui->bridges->clear();
Q_FOREACH (const NetworkManager::Connection::Ptr &connection, NetworkManager::listConnections()) {
for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) {
NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
if (settings->master() == m_uuid && settings->slaveType() == type()) {
const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
......
......@@ -99,7 +99,7 @@ void ConnectionWidget::loadConfig(const NetworkManager::ConnectionSettings::Ptr
const QStringList secondaries = settings->secondaries();
const QStringList vpnKeys = vpnConnections().keys();
if (!secondaries.isEmpty() && !vpnKeys.isEmpty()) {
Q_FOREACH (const QString & vpnKey, vpnKeys) {
for (const QString &vpnKey : vpnKeys) {
if (secondaries.contains(vpnKey)) {
m_widget->vpnCombobox->setCurrentIndex(m_widget->vpnCombobox->findData(vpnKey));
m_widget->autoconnectVpn->setChecked(true);
......@@ -177,7 +177,7 @@ NMStringMap ConnectionWidget::vpnConnections() const
NetworkManager::Connection::List list = NetworkManager::listConnections();
NMStringMap result;
Q_FOREACH (const NetworkManager::Connection::Ptr & conn, list) {
for (const NetworkManager::Connection::Ptr &conn : list) {
NetworkManager::ConnectionSettings::Ptr conSet = conn->settings();
if (conSet->connectionType() == NetworkManager::ConnectionSettings::Vpn) {
// qCDebug(PLASMA_NM) << "Found VPN" << conSet->id() << conSet->uuid();
......
......@@ -160,7 +160,7 @@ void IPv4Widget::loadConfig(const NetworkManager::Setting::Ptr &setting)
// dns
QStringList tmp;
Q_FOREACH (const QHostAddress & addr, ipv4Setting->dns()) {
for (const QHostAddress &addr : ipv4Setting->dns()) {
tmp.append(addr.toString());
}
m_ui->dns->setText(tmp.join(","));
......@@ -169,7 +169,7 @@ void IPv4Widget::loadConfig(const NetworkManager::Setting::Ptr &setting)
m_ui->dhcpClientId->setText(ipv4Setting->dhcpClientId());
// addresses
Q_FOREACH (const NetworkManager::IpAddress &addr, ipv4Setting->addresses()) {
for (const NetworkManager::IpAddress &addr : ipv4Setting->addresses()) {
QList<QStandardItem *> item;
item << new QStandardItem(addr.ip().toString())
<< new QStandardItem(addr.netmask().toString())
......@@ -217,7 +217,7 @@ QVariantMap IPv4Widget::setting() const
if (m_ui->dns->isEnabled() && !m_ui->dns->text().isEmpty()) {
QStringList tmp = m_ui->dns->text().split(',');
QList<QHostAddress> tmpAddrList;
Q_FOREACH (const QString & str, tmp) {
for (const QString &str : tmp) {
QHostAddress addr(str);
if (!addr.isNull())
tmpAddrList.append(addr);
......@@ -488,7 +488,7 @@ bool IPv4Widget::isValid() const
if (!m_ui->dns->text().isEmpty() && (m_ui->method->currentIndex() == Automatic || m_ui->method->currentIndex() == Manual || m_ui->method->currentIndex() == AutomaticOnlyIP)) {
const QStringList tmp = m_ui->dns->text().split(',');
Q_FOREACH (const QString & str, tmp) {
for (const QString &str : tmp) {
QHostAddress addr(str);
if (addr.isNull()) {
return false;
......
......@@ -149,14 +149,14 @@ void IPv6Widget::loadConfig(const NetworkManager::Setting::Ptr &setting)
// dns
QStringList tmp;
Q_FOREACH (const QHostAddress & addr, ipv6Setting->dns()) {
for (const QHostAddress &addr : ipv6Setting->dns()) {
tmp.append(addr.toString());
}
m_ui->dns->setText(tmp.join(","));
m_ui->dnsSearch->setText(ipv6Setting->dnsSearch().join(","));
// addresses
Q_FOREACH (const NetworkManager::IpAddress &address, ipv6Setting->addresses()) {
for (const NetworkManager::IpAddress &address : ipv6Setting->addresses()) {
QList<QStandardItem *> item;
item << new QStandardItem(address.ip().toString())
......@@ -210,7 +210,7 @@ QVariantMap IPv6Widget::setting() const
if (m_ui->dns->isEnabled() && !m_ui->dns->text().isEmpty()) {
QStringList tmp = m_ui->dns->text().split(',');
QList<QHostAddress> tmpAddrList;
Q_FOREACH (const QString & str, tmp) {
for (const QString &str : tmp) {
QHostAddress addr(str);
if (!addr.isNull())
tmpAddrList.append(addr);
......@@ -479,7 +479,7 @@ bool IPv6Widget::isValid() const
if (!m_ui->dns->text().isEmpty() && (m_ui->method->currentIndex() == Automatic || m_ui->method->currentIndex() == Manual || m_ui->method->currentIndex() == AutomaticOnlyIP)) {
const QStringList tmp = m_ui->dns->text().split(',');
Q_FOREACH (const QString & str, tmp) {
for (const QString &str : tmp) {
QHostAddress addr(str);
if (addr.isNull()) {
return false;
......
......@@ -156,7 +156,7 @@ void Security8021x::loadConfig(const NetworkManager::Setting::Ptr &setting)
m_ui->tlsCACert->setUrl(QUrl::fromLocalFile(securitySetting->caCertificate()));
m_ui->leTlsSubjectMatch->setText(securitySetting->subjectMatch());
m_ui->leTlsAlternativeSubjectMatches->setText(securitySetting->altSubjectMatches().join(QLatin1String(", ")));
Q_FOREACH (const QString &match, securitySetting->altSubjectMatches()) {
for (const QString &match : securitySetting->altSubjectMatches()) {
if (match.startsWith(QLatin1String("DNS:"))) {
servers.append(match.right(match.length()-4));
}
......@@ -333,7 +333,7 @@ QVariantMap Security8021x::setting() const
}
QStringList altsubjectmatches = m_ui->leTlsAlternativeSubjectMatches->text().remove(QLatin1Char(' ')).split(QLatin1Char(','), QString::SkipEmptyParts);
Q_FOREACH (const QString &match, m_ui->leTlsConnectToServers->text().remove(QLatin1Char(' ')).split(QLatin1Char(','), QString::SkipEmptyParts)) {
for (const QString &match : m_ui->leTlsConnectToServers->text().remove(QLatin1Char(' ')).split(QLatin1Char(','), QString::SkipEmptyParts)) {
const QString tempstr = QLatin1String("DNS:") + match;
if (!altsubjectmatches.contains(tempstr)) {
altsubjectmatches.append(tempstr);
......
......@@ -214,7 +214,7 @@ void TeamWidget::populateTeams()
{
m_ui->teams->clear();
Q_FOREACH (const NetworkManager::Connection::Ptr &connection, NetworkManager::listConnections()) {
for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) {
NetworkManager::ConnectionSettings::Ptr settings = connection->settings();
if (settings->master() == m_uuid && settings->slaveType() == type()) {
const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType()));
......
......@@ -94,7 +94,7 @@ void VlanWidget::fillConnections()
{
m_ui->parent->clear();
Q_FOREACH (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
for (const NetworkManager::Connection::Ptr &con : NetworkManager::listConnections()) {
if (!con->settings()->isSlave() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Wired)
m_ui->parent->addItem(con->name(), con->uuid());
}
......
......@@ -308,11 +308,11 @@ QVariantMap WifiSecurity::setting8021x() const
void WifiSecurity::onSsidChanged(const QString &ssid)
{
Q_FOREACH (const NetworkManager::Device::Ptr &device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Wifi) {
NetworkManager::WirelessDevice::Ptr wifiDevice = device.staticCast<NetworkManager::WirelessDevice>();
if (wifiDevice) {
Q_FOREACH (const NetworkManager::WirelessNetwork::Ptr wifiNetwork, wifiDevice->networks()) {
for (const NetworkManager::WirelessNetwork::Ptr wifiNetwork : wifiDevice->networks()) {
if (wifiNetwork && wifiNetwork->ssid() == ssid) {
NetworkManager::AccessPoint::Ptr ap = wifiNetwork->referenceAccessPoint();
NetworkManager::WirelessSecurityType securityType = NetworkManager::findBestWirelessSecurity(wifiDevice->wirelessCapabilities(), true, (wifiDevice->mode() == NetworkManager::WirelessDevice::Adhoc),
......
......@@ -97,7 +97,7 @@ QValidator::State SimpleIpV4AddressValidator::checkTetradsRanges(QString &value,
tetrads << -1 << -1 << -1 << -1;
// lets check address parts
Q_FOREACH (const QStringRef &part, addrParts) {
for (const QStringRef &part : addrParts) {
if (part.isEmpty()) {
if (i != (addrParts.size() - 1)) {
// qCDebug(PLASMA_NM) << "part.isEmpty()";
......
......@@ -110,7 +110,7 @@ QValidator::State SimpleIpV6AddressValidator::checkTetradsRanges(QString &value)
// lets check address parts
bool emptypresent = false;
int i = 1;
Q_FOREACH (QString part, addrParts) { // krazy:exclude=Q_FOREACH
for (QString part : addrParts) {
if (part.isEmpty() && i < number) {
// There is only one case where you can have 3 empty parts
// and that is when you have the string: "::" which is valid
......
......@@ -42,7 +42,7 @@ AdvancedPermissionsWidget::AdvancedPermissionsWidget(QWidget *parent):
Q_D(AdvancedPermissionsWidget);
d->ui.setupUi(this);
Q_FOREACH (const KUser &user, KUser::allUsers()) {
for (const KUser &user : KUser::allUsers()) {
if (user.userId().nativeId() >= 1000 && user.loginName() != QLatin1String("nobody"))
d->ui.availUsers->addTopLevelItem(constructItem(user));
}
......@@ -56,7 +56,7 @@ AdvancedPermissionsWidget::AdvancedPermissionsWidget(const QHash<QString,QString
Q_D(AdvancedPermissionsWidget);
d->ui.setupUi(this);
Q_FOREACH (const KUser &user, KUser::allUsers()) {
for (const KUser &user : KUser::allUsers()) {
const QString name = user.loginName();
if (!users.contains(name) && user.userId().nativeId() >= 1000 && user.loginName() != QLatin1String("nobody"))
d->ui.availUsers->addTopLevelItem(constructItem(user));
......@@ -127,7 +127,7 @@ QHash<QString, QString> AdvancedPermissionsWidget::currentUsers() const
void AdvancedPermissionsWidget::rightArrowClicked()
{
Q_D(AdvancedPermissionsWidget);
Q_FOREACH (QTreeWidgetItem *item, d->ui.availUsers->selectedItems()) {
for (QTreeWidgetItem *item : d->ui.availUsers->selectedItems()) {
const int index = d->ui.availUsers->indexOfTopLevelItem(item);
d->ui.availUsers->takeTopLevelItem(index);
d->ui.currentUsers->addTopLevelItem(item);
......@@ -137,7 +137,7 @@ void AdvancedPermissionsWidget::rightArrowClicked()
void AdvancedPermissionsWidget::leftArrowClicked()
{
Q_D(AdvancedPermissionsWidget);
Q_FOREACH (QTreeWidgetItem *item, d->ui.currentUsers->selectedItems()) {
for (QTreeWidgetItem *item : d->ui.currentUsers->selectedItems()) {
if (item->data(LoginName, Qt::DisplayRole) != KUser().loginName()) {
const int index = d->ui.currentUsers->indexOfTopLevelItem(item);
d->ui.currentUsers->takeTopLevelItem(index);
......
......@@ -84,7 +84,7 @@ void BssidComboBox::init(const QString & bssid, const QString &ssid)
QList<NetworkManager::AccessPoint::Ptr> aps;
Q_FOREACH (const NetworkManager::Device::Ptr & device, NetworkManager::networkInterfaces()) {
for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) {
if (device->type() == NetworkManager::Device::Wifi) {
NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>();
NetworkManager::WirelessNetwork::Ptr wifiNetwork = wifiDevice->findNetwork(ssid);
......@@ -93,9 +93,9 @@ void BssidComboBox::init(const QString & bssid, const QString &ssid)
continue;
}
Q_FOREACH (const NetworkManager::AccessPoint::Ptr & newAp, wifiNetwork->accessPoints()) {
for (const NetworkManager::AccessPoint::Ptr &newAp : wifiNetwork->accessPoints()) {
bool found = false;;
Q_FOREACH (const NetworkManager::AccessPoint::Ptr & existingAp, aps) {
for (const NetworkManager::AccessPoint::Ptr &existingAp : aps) {
if (newAp->hardwareAddress() == existingAp->hardwareAddress()) {
if (newAp->signalStrength() > existingAp->signalStrength()) {
aps.removeOne(existingAp);
......@@ -136,7 +136,7 @@ void BssidComboBox::addBssidsToCombo(const QList<NetworkManager::AccessPoint::Pt
return;
}
Q_FOREACH (const NetworkManager::AccessPoint::Ptr & ap, aps) {
for (const NetworkManager::AccessPoint::Ptr &ap : aps) {
if (!ap) {
continue;
}
......
......@@ -82,7 +82,7 @@ void HwAddrComboBox::init(const NetworkManager::Device::Type &deviceType, const
// qCDebug(PLASMA_NM) << "Initial address:" << m_initialAddress;
QString deviceName;
Q_FOREACH (const NetworkManager::Device::