Changeset View
Changeset View
Standalone View
Standalone View
dataengines/soliddevice/soliddeviceengine.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 92 | if (device.isValid()) { | |||
---|---|---|---|---|---|
95 | } else { | 95 | } else { | ||
96 | m_devicemap[name] = device; | 96 | m_devicemap[name] = device; | ||
97 | return populateDeviceData(name); | 97 | return populateDeviceData(name); | ||
98 | } | 98 | } | ||
99 | } | 99 | } | ||
100 | } else { | 100 | } else { | ||
101 | Solid::Predicate predicate = Solid::Predicate::fromString(name); | 101 | Solid::Predicate predicate = Solid::Predicate::fromString(name); | ||
102 | if (predicate.isValid() && !m_predicatemap.contains(name)) { | 102 | if (predicate.isValid() && !m_predicatemap.contains(name)) { | ||
103 | foreach (const Solid::Device &device, Solid::Device::listFromQuery(predicate)) { | 103 | const auto devices = Solid::Device::listFromQuery(predicate); | ||
104 | for (const Solid::Device &device : devices) { | ||||
104 | m_predicatemap[name] << device.udi(); | 105 | m_predicatemap[name] << device.udi(); | ||
105 | } | 106 | } | ||
106 | 107 | | |||
107 | setData(name, m_predicatemap[name]); | 108 | setData(name, m_predicatemap[name]); | ||
108 | return true; | 109 | return true; | ||
109 | } | 110 | } | ||
110 | } | 111 | } | ||
111 | 112 | | |||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Line(s) | 213 | if (device.is<Solid::OpticalDrive>()) { | |||
270 | setData(name, I18N_NOOP("Supported Media"), supportedtypes); | 271 | setData(name, I18N_NOOP("Supported Media"), supportedtypes); | ||
271 | 272 | | |||
272 | setData(name, I18N_NOOP("Read Speed"), opticaldrive->readSpeed()); | 273 | setData(name, I18N_NOOP("Read Speed"), opticaldrive->readSpeed()); | ||
273 | setData(name, I18N_NOOP("Write Speed"), opticaldrive->writeSpeed()); | 274 | setData(name, I18N_NOOP("Write Speed"), opticaldrive->writeSpeed()); | ||
274 | 275 | | |||
275 | //the following method return QList<int> so we need to convert it to QList<QVariant> | 276 | //the following method return QList<int> so we need to convert it to QList<QVariant> | ||
276 | const QList<int> writespeeds = opticaldrive->writeSpeeds(); | 277 | const QList<int> writespeeds = opticaldrive->writeSpeeds(); | ||
277 | QList<QVariant> variantlist; | 278 | QList<QVariant> variantlist; | ||
278 | foreach(int num, writespeeds) { | 279 | for (int num : writespeeds) { | ||
279 | variantlist << num; | 280 | variantlist << num; | ||
280 | } | 281 | } | ||
281 | setData(name, I18N_NOOP("Write Speeds"), variantlist); | 282 | setData(name, I18N_NOOP("Write Speeds"), variantlist); | ||
282 | 283 | | |||
283 | } | 284 | } | ||
284 | if (device.is<Solid::StorageVolume>()) { | 285 | if (device.is<Solid::StorageVolume>()) { | ||
285 | Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>(); | 286 | Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>(); | ||
286 | if (!storagevolume) { | 287 | if (!storagevolume) { | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
446 | setData(name, I18N_NOOP("Device Types"), devicetypes); | 447 | setData(name, I18N_NOOP("Device Types"), devicetypes); | ||
447 | return true; | 448 | return true; | ||
448 | } | 449 | } | ||
449 | 450 | | |||
450 | void SolidDeviceEngine::deviceAdded(const QString& udi) | 451 | void SolidDeviceEngine::deviceAdded(const QString& udi) | ||
451 | { | 452 | { | ||
452 | Solid::Device device(udi); | 453 | Solid::Device device(udi); | ||
453 | 454 | | |||
454 | foreach (const QString &query, m_predicatemap.keys()) { | 455 | const auto keys = m_predicatemap.keys(); | ||
456 | for (const QString &query : keys) { | ||||
455 | Solid::Predicate predicate = Solid::Predicate::fromString(query); | 457 | Solid::Predicate predicate = Solid::Predicate::fromString(query); | ||
456 | if (predicate.matches(device)) { | 458 | if (predicate.matches(device)) { | ||
457 | m_predicatemap[query] << udi; | 459 | m_predicatemap[query] << udi; | ||
458 | setData(query, m_predicatemap[query]); | 460 | setData(query, m_predicatemap[query]); | ||
459 | } | 461 | } | ||
460 | } | 462 | } | ||
461 | 463 | | |||
462 | if (device.is<Solid::OpticalDisc>()) { | 464 | if (device.is<Solid::OpticalDisc>()) { | ||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | 672 | { | |||
672 | //hence we trigger an update when a device contained in an encrypted container device dies | 674 | //hence we trigger an update when a device contained in an encrypted container device dies | ||
673 | const QString containerUdi = m_encryptedContainerMap.value(udi, QString()); | 675 | const QString containerUdi = m_encryptedContainerMap.value(udi, QString()); | ||
674 | 676 | | |||
675 | if (!containerUdi.isEmpty()) { | 677 | if (!containerUdi.isEmpty()) { | ||
676 | forceUpdateAccessibility(containerUdi); | 678 | forceUpdateAccessibility(containerUdi); | ||
677 | m_encryptedContainerMap.remove(udi); | 679 | m_encryptedContainerMap.remove(udi); | ||
678 | } | 680 | } | ||
679 | 681 | | |||
680 | foreach (const QString &query, m_predicatemap.keys()) { | 682 | const auto keys = m_predicatemap.keys(); | ||
683 | for (const QString &query : keys) { | ||||
681 | m_predicatemap[query].removeAll(udi); | 684 | m_predicatemap[query].removeAll(udi); | ||
682 | setData(query, m_predicatemap[query]); | 685 | setData(query, m_predicatemap[query]); | ||
683 | } | 686 | } | ||
684 | 687 | | |||
685 | Solid::Device device(udi); | 688 | Solid::Device device(udi); | ||
686 | if (device.is<Solid::StorageVolume>()) { | 689 | if (device.is<Solid::StorageVolume>()) { | ||
687 | Solid::StorageAccess *access = device.as<Solid::StorageAccess>(); | 690 | Solid::StorageAccess *access = device.as<Solid::StorageAccess>(); | ||
688 | if (access) { | 691 | if (access) { | ||
Show All 23 Lines |