Commit efdf88ec authored by Méven Car's avatar Méven Car Committed by Méven Car

Solid-device-automounter/kcm: Convert some foreach

Test Plan: builds

Reviewers: broulik, ervin, #plasma

Reviewed By: ervin

Subscribers: alex, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27052
parent 18c201cf
......@@ -88,7 +88,8 @@ DeviceAutomounterKCM::~DeviceAutomounterKCM()
void DeviceAutomounterKCM::updateForgetDeviceButton()
{
foreach (const QModelIndex &idx, deviceView->selectionModel()->selectedIndexes()) {
const auto selectedIndex = deviceView->selectionModel()->selectedIndexes();
for (const QModelIndex &idx : selectedIndex) {
if (idx.data(DeviceModel::TypeRole) == DeviceModel::Detatched) {
forgetDevice->setEnabled(true);
return;
......@@ -167,7 +168,8 @@ void DeviceAutomounterKCM::save()
}
}
foreach (const QString &possibleDevice, AutomounterSettings::knownDevices()) {
const auto knownDevices = AutomounterSettings::knownDevices();
for (const QString &possibleDevice : knownDevices) {
if (!validDevices.contains(possibleDevice)) {
AutomounterSettings::deviceSettings(possibleDevice).deleteGroup();
}
......
......@@ -141,10 +141,12 @@ void DeviceModel::reload()
m_automaticLogin = AutomounterSettings::automountOnLogin();
m_automaticAttached = AutomounterSettings::automountOnPlugin();
foreach (const QString &dev, AutomounterSettings::knownDevices()) {
const auto knownDevices = AutomounterSettings::knownDevices();
for (const QString &dev : knownDevices) {
addNewDevice(dev);
}
foreach (const QString &udi, m_loginForced.keys()) {
const auto keys = m_loginForced.keys();
for (const QString &udi : keys) {
m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login);
m_attachedForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach);
}
......
......@@ -69,10 +69,10 @@ void DeviceAutomounter::init()
}
connect(Solid::DeviceNotifier::instance(), &Solid::DeviceNotifier::deviceAdded, this, &DeviceAutomounter::deviceAdded);
QList<Solid::Device> volumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume);
foreach(Solid::Device volume, volumes) {
const QList<Solid::Device> volumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume);
for (Solid::Device volume : volumes) {
// sa can be 0 (e.g. for the swap partition)
if (Solid::StorageAccess *sa = volume.as<Solid::StorageAccess>()) {
if (const Solid::StorageAccess *sa = volume.as<Solid::StorageAccess>()) {
connect(sa, &Solid::StorageAccess::accessibilityChanged, this, &DeviceAutomounter::deviceMountChanged);
}
automountDevice(volume, AutomounterSettings::Login);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment