Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/fstab/fstabdevice.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 46 | if ((fstype == QLatin1String("fuse.encfs")) || | |||
---|---|---|---|---|---|
48 | m_storageType = StorageType::Encrypted; | 48 | m_storageType = StorageType::Encrypted; | ||
49 | } | 49 | } | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | const QStringList& gvfsOptions = FstabHandling::options(m_device); | 52 | const QStringList& gvfsOptions = FstabHandling::options(m_device); | ||
53 | for (const QString &option : gvfsOptions) { | 53 | for (const QString &option : gvfsOptions) { | ||
54 | if (option.startsWith(QLatin1String("x-gvfs-name="))) { | 54 | if (option.startsWith(QLatin1String("x-gvfs-name="))) { | ||
55 | QStringRef encoded = option.midRef(12); | 55 | QStringRef encoded = option.midRef(12); | ||
56 | m_description = QUrl::fromPercentEncoding(encoded.toLatin1()); | 56 | m_displayName = QUrl::fromPercentEncoding(encoded.toLatin1()); | ||
57 | } else if (option.startsWith(QLatin1String("x-gvfs-icon="))) { | 57 | } else if (option.startsWith(QLatin1String("x-gvfs-icon="))) { | ||
58 | QStringRef encoded = option.midRef(12); | 58 | QStringRef encoded = option.midRef(12); | ||
59 | m_iconName = QUrl::fromPercentEncoding(encoded.toLatin1()); | 59 | m_iconName = QUrl::fromPercentEncoding(encoded.toLatin1()); | ||
60 | } | 60 | } | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | if (m_description.isEmpty()) { | | |||
64 | if (m_storageType == StorageType::NetworkShare) { | 63 | if (m_storageType == StorageType::NetworkShare) { | ||
65 | m_description = QCoreApplication::translate("", "%1 on %2", | 64 | m_description = QCoreApplication::translate("", "%1 on %2", | ||
66 | "%1 is sharename, %2 is servername").arg(m_product, m_vendor); | 65 | "%1 is sharename, %2 is servername").arg(m_product, m_vendor); | ||
67 | } else { | 66 | } else { | ||
68 | m_description = QCoreApplication::translate("", "%1 (%2)", | 67 | m_description = QCoreApplication::translate("", "%1 (%2)", | ||
69 | "%1 is mountpoint, %2 is fs type").arg(m_product, m_vendor); | 68 | "%1 is mountpoint, %2 is fs type").arg(m_product, m_vendor); | ||
70 | } | 69 | } | ||
70 | | ||||
71 | if (m_displayName.isEmpty()) { | ||||
72 | const QStringList currentMountPoints = FstabHandling::currentMountPoints(m_device); | ||||
dfaure: `const` | |||||
73 | if (currentMountPoints.isEmpty()) { | ||||
74 | const QStringList mountPoints = FstabHandling::mountPoints(m_device); | ||||
dfaure: `const` so that first() doesn't detach. | |||||
75 | m_displayName = mountPoints.isEmpty() ? m_description : mountPoints.first(); | ||||
76 | } else { | ||||
77 | m_displayName = currentMountPoints.first(); | ||||
bruns: the `if (m_displayName.isEmpty())` block belongs here | |||||
78 | } | ||||
71 | } | 79 | } | ||
72 | 80 | | |||
73 | if (m_iconName.isEmpty()) { | 81 | if (m_iconName.isEmpty()) { | ||
74 | if (m_storageType == StorageType::NetworkShare) { | 82 | if (m_storageType == StorageType::NetworkShare) { | ||
75 | m_iconName = QLatin1String("network-server"); | 83 | m_iconName = QLatin1String("network-server"); | ||
76 | } else if (m_storageType == StorageType::Encrypted) { | 84 | } else if (m_storageType == StorageType::Encrypted) { | ||
77 | m_iconName = QLatin1String("folder-decrypted"); | 85 | m_iconName = QLatin1String("folder-decrypted"); | ||
78 | } else { | 86 | } else { | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 136 | if (m_storageAccess->isAccessible()) { | |||
129 | res << "emblem-mounted"; | 137 | res << "emblem-mounted"; | ||
130 | } else { | 138 | } else { | ||
131 | res << "emblem-unmounted"; | 139 | res << "emblem-unmounted"; | ||
132 | } | 140 | } | ||
133 | 141 | | |||
134 | return res; | 142 | return res; | ||
135 | } | 143 | } | ||
136 | 144 | | |||
145 | QString FstabDevice::displayName() const | ||||
146 | { | ||||
147 | return m_displayName; | ||||
148 | } | ||||
149 | | ||||
137 | QString FstabDevice::description() const | 150 | QString FstabDevice::description() const | ||
138 | { | 151 | { | ||
139 | return m_description; | 152 | return m_description; | ||
140 | } | 153 | } | ||
141 | 154 | | |||
bruns: use `FstabHandling::mountPoints(m_device).first()` instead of m_storageAccess. | |||||
I don't think that it is necessary : m_storageAccess already equals to FstabHandling::mountPoints(m_device).first(), looking at FstabStorageAccess::FstabStorageAccess and FstabStorageAccess::onMtabChanged. (That's why I wrote it like this in the first place). meven: I don't think that it is necessary : m_storageAccess already equals to `FstabHandling… | |||||
bruns: I think it is. You always create a FstabStorageAccess instance now. | |||||
142 | bool FstabDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &interfaceType) const | 155 | bool FstabDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &interfaceType) const | ||
filePath in most cases does not depend on isAccessible ... it would be annoying if the label changed everytime the device is mounted. bruns: filePath in most cases does not depend on isAccessible ... it would be annoying if the label… | |||||
meven: Indeed thanks for pointing it out. | |||||
143 | { | 156 | { | ||
144 | if (interfaceType == Solid::DeviceInterface::StorageAccess) { | 157 | if (interfaceType == Solid::DeviceInterface::StorageAccess) { | ||
145 | return true; | 158 | return true; | ||
146 | } | 159 | } | ||
147 | if ((m_storageType == StorageType::NetworkShare) && | 160 | if ((m_storageType == StorageType::NetworkShare) && | ||
148 | (interfaceType == Solid::DeviceInterface::NetworkShare)) { | 161 | (interfaceType == Solid::DeviceInterface::NetworkShare)) { | ||
149 | return true; | 162 | return true; | ||
150 | } | 163 | } | ||
Show All 28 Lines |
const