Changeset View
Changeset View
Standalone View
Standalone View
solid-device-automounter/kcm/DeviceModel.cpp
Show All 20 Lines | |||||
21 | #include "DeviceModel.h" | 21 | #include "DeviceModel.h" | ||
22 | 22 | | |||
23 | #include <QIcon> | 23 | #include <QIcon> | ||
24 | 24 | | |||
25 | #include <KLocalizedString> | 25 | #include <KLocalizedString> | ||
26 | #include <Solid/DeviceNotifier> | 26 | #include <Solid/DeviceNotifier> | ||
27 | #include <Solid/Device> | 27 | #include <Solid/Device> | ||
28 | #include <Solid/StorageVolume> | 28 | #include <Solid/StorageVolume> | ||
29 | #include <Solid/StorageAccess> | ||||
29 | 30 | | |||
30 | #include "AutomounterSettings.h" | 31 | #include "AutomounterSettings.h" | ||
31 | 32 | | |||
32 | DeviceModel::DeviceModel(QObject *parent) | 33 | DeviceModel::DeviceModel(QObject *parent) | ||
33 | : QAbstractItemModel(parent) | 34 | : QAbstractItemModel(parent) | ||
34 | { | 35 | { | ||
35 | reload(); | 36 | reload(); | ||
36 | 37 | | |||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 109 | if (!m_loginForced.contains(udi)) { | |||
109 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login); | 110 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login); | ||
110 | } | 111 | } | ||
111 | if (!m_attachedForced.contains(udi)) { | 112 | if (!m_attachedForced.contains(udi)) { | ||
112 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach); | 113 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach); | ||
113 | } | 114 | } | ||
114 | 115 | | |||
115 | const Solid::Device dev(udi); | 116 | const Solid::Device dev(udi); | ||
116 | if (dev.isValid()) { | 117 | if (dev.isValid()) { | ||
118 | const Solid::StorageAccess *access = dev.as<Solid::StorageAccess>(); | ||||
119 | if (access == nullptr || !access->isIgnored()) { | ||||
broulik: Do we want to add items that are *not* a `StorageAccess`?
Shouldn't this be more like
```
if… | |||||
I needed to add the not mounted storage access as storage access ignores not mounted system meven: I needed to add the not mounted storage access as storage access ignores not mounted system | |||||
117 | beginInsertRows(index(0, 0), m_attached.size(), m_attached.size()); | 120 | beginInsertRows(index(0, 0), m_attached.size(), m_attached.size()); | ||
118 | m_attached << udi; | 121 | m_attached << udi; | ||
122 | endInsertRows(); | ||||
123 | } | ||||
119 | } else { | 124 | } else { | ||
120 | beginInsertRows(index(1, 0), m_disconnected.size(), m_disconnected.size()); | 125 | beginInsertRows(index(1, 0), m_disconnected.size(), m_disconnected.size()); | ||
121 | m_disconnected << udi; | 126 | m_disconnected << udi; | ||
122 | } | | |||
123 | | ||||
124 | endInsertRows(); | 127 | endInsertRows(); | ||
125 | } | 128 | } | ||
129 | } | ||||
126 | 130 | | |||
127 | void DeviceModel::reload() | 131 | void DeviceModel::reload() | ||
128 | { | 132 | { | ||
129 | beginResetModel(); | 133 | beginResetModel(); | ||
130 | m_loginForced.clear(); | 134 | m_loginForced.clear(); | ||
131 | m_attachedForced.clear(); | 135 | m_attachedForced.clear(); | ||
132 | m_attached.clear(); | 136 | m_attached.clear(); | ||
133 | m_disconnected.clear(); | 137 | m_disconnected.clear(); | ||
134 | 138 | | |||
135 | foreach (const QString &dev, AutomounterSettings::knownDevices()) { | 139 | for (const QString &dev : AutomounterSettings::knownDevices()) { | ||
136 | addNewDevice(dev); | 140 | addNewDevice(dev); | ||
137 | } | 141 | } | ||
138 | foreach (const QString &udi, m_loginForced.keys()) { | 142 | for (const QString &udi : m_loginForced.keys()) { | ||
139 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login); | 143 | m_loginForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Login); | ||
140 | m_attachedForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach); | 144 | m_attachedForced[udi] = AutomounterSettings::deviceAutomountIsForced(udi, AutomounterSettings::Attach); | ||
141 | } | 145 | } | ||
142 | endResetModel(); | 146 | endResetModel(); | ||
143 | } | 147 | } | ||
144 | 148 | | |||
145 | QModelIndex DeviceModel::index(int row, int column, const QModelIndex &parent) const | 149 | QModelIndex DeviceModel::index(int row, int column, const QModelIndex &parent) const | ||
146 | { | 150 | { | ||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |
Do we want to add items that are *not* a StorageAccess?
Shouldn't this be more like