Changeset View
Changeset View
Standalone View
Standalone View
solid-device-automounter/kded/DeviceAutomounter.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 62 | msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kded5"), | |||
---|---|---|---|---|---|
64 | QStringLiteral("org.kde.kded5"), | 64 | QStringLiteral("org.kde.kded5"), | ||
65 | QStringLiteral("unloadModule")); | 65 | QStringLiteral("unloadModule")); | ||
66 | msg.setArguments({QVariant(QStringLiteral("device_automounter"))}); | 66 | msg.setArguments({QVariant(QStringLiteral("device_automounter"))}); | ||
67 | dbus.call(msg, QDBus::NoBlock); | 67 | dbus.call(msg, QDBus::NoBlock); | ||
68 | return; | 68 | return; | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | connect(Solid::DeviceNotifier::instance(), &Solid::DeviceNotifier::deviceAdded, this, &DeviceAutomounter::deviceAdded); | 71 | connect(Solid::DeviceNotifier::instance(), &Solid::DeviceNotifier::deviceAdded, this, &DeviceAutomounter::deviceAdded); | ||
72 | QList<Solid::Device> volumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume); | 72 | const QList<Solid::Device> volumes = Solid::Device::listFromType(Solid::DeviceInterface::StorageVolume); | ||
73 | foreach(Solid::Device volume, volumes) { | 73 | for (Solid::Device volume : volumes) { | ||
ervin: nitpick, feel free to ignore: would make sense to switch to a const ref here since we're… | |||||
Unfortunately this is not possible line 78 requires a non-const ref to volume. meven: Unfortunately this is not possible line 78 requires a non-const ref to volume. | |||||
const auto for volumes was possible though. I wonder if it wouldn't have made sense to have a non const ref in the loop then. Would have avoided the (potential) copy and made clear this loop was modifying. Oh well. ervin: const auto for volumes was possible though.
I wonder if it wouldn't have made sense to have a… | |||||
74 | // sa can be 0 (e.g. for the swap partition) | 74 | // sa can be 0 (e.g. for the swap partition) | ||
75 | if (Solid::StorageAccess *sa = volume.as<Solid::StorageAccess>()) { | 75 | if (const Solid::StorageAccess *sa = volume.as<Solid::StorageAccess>()) { | ||
76 | connect(sa, &Solid::StorageAccess::accessibilityChanged, this, &DeviceAutomounter::deviceMountChanged); | 76 | connect(sa, &Solid::StorageAccess::accessibilityChanged, this, &DeviceAutomounter::deviceMountChanged); | ||
77 | } | 77 | } | ||
78 | automountDevice(volume, AutomounterSettings::Login); | 78 | automountDevice(volume, AutomounterSettings::Login); | ||
79 | } | 79 | } | ||
80 | AutomounterSettings::self()->save(); | 80 | AutomounterSettings::self()->save(); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | void DeviceAutomounter::deviceMountChanged(bool accessible, const QString &udi) | 83 | void DeviceAutomounter::deviceMountChanged(bool accessible, const QString &udi) | ||
Show All 39 Lines |
nitpick, feel free to ignore: would make sense to switch to a const ref here since we're touching the line anyway. in the same vein, "const auto" on the line before wouldn't be a bad idea either (if we ever switch to QVector for instance it'd be one less place where compilation would break).