From e7707401f1af3ee1dc324bb2c43cd1b2911e49a3 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 13 Jul 2021 12:55:11 +0300 Subject: [PATCH] plasma: deal with FIXME related to Solid devices engine Signed-off-by: Ivailo Monev --- .../dataengines/soliddevice/soliddeviceengine.cpp | 23 ++++++---------------- plasma/dataengines/soliddevice/soliddeviceengine.h | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/plasma/dataengines/soliddevice/soliddeviceengine.cpp b/plasma/dataengines/soliddevice/soliddeviceengine.cpp index 078256e0..4281f6e4 100644 --- a/plasma/dataengines/soliddevice/soliddeviceengine.cpp +++ b/plasma/dataengines/soliddevice/soliddeviceengine.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -64,6 +63,8 @@ void SolidDeviceEngine::listenForNewDevices() this, SLOT(deviceAdded(QString))); connect(m_notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); + connect(m_notifier, SIGNAL(contentChanged(QString,bool)), + this, SLOT(deviceContentChanged(QString,bool))); } bool SolidDeviceEngine::sourceRequestEvent(const QString &name) @@ -560,17 +561,6 @@ void SolidDeviceEngine::deviceAdded(const QString& udi) this, SLOT(setIdleState(Solid::ErrorType,QVariant,QString))); } } else if (device.is()) { - // update the volume in case of 2-stage devices -#warning FIXME: broken Solid generic interface usage - if (m_devicemap.contains(udi) && query(udi).value(I18N_NOOP("Size")).toULongLong() == 0) { - Solid::GenericInterface * iface = device.as(); - if (iface) { - iface->setProperty("udi", udi); - connect(iface, SIGNAL(propertyChanged(QMap)), - this, SLOT(deviceChanged(QMap))); - } - } - Solid::StorageAccess *access = device.as(); if (access) { connect(access, SIGNAL(setupRequested(QString)), @@ -622,13 +612,12 @@ void SolidDeviceEngine::setIdleState(Solid::ErrorType error, QVariant errorData, setData(udi, I18N_NOOP("File Path"), storageaccess->filePath()); } -void SolidDeviceEngine::deviceChanged(const QMap &props) +void SolidDeviceEngine::deviceContentChanged(const QString &udi, const bool hascontent) { - Solid::GenericInterface * iface = qobject_cast(sender()); - if (iface && iface->isValid() && props.contains("Size") && iface->property("Size").toInt() > 0) { - const QString udi = qobject_cast(iface)->property("udi").toString(); - if (populateDeviceData(udi)) + if (hascontent) { + if (populateDeviceData(udi)) { forceImmediateUpdateOfAllVisualizations(); + } } } diff --git a/plasma/dataengines/soliddevice/soliddeviceengine.h b/plasma/dataengines/soliddevice/soliddeviceengine.h index 85bdc68d..ab186dae 100644 --- a/plasma/dataengines/soliddevice/soliddeviceengine.h +++ b/plasma/dataengines/soliddevice/soliddeviceengine.h @@ -94,7 +94,7 @@ private Q_SLOTS: void setMountingState(const QString &udi); void setUnmountingState(const QString &udi); void setIdleState(Solid::ErrorType error, QVariant errorData, const QString &udi); - void deviceChanged(const QMap & props); + void deviceContentChanged(const QString &udi, const bool hascontent); }; #endif -- 2.11.0