KDE/kdebase/workspace/plasma/applets/devicenotifier

Alessandro Diaferia alediaferia at gmail.com
Fri Aug 21 12:05:15 CEST 2009


SVN commit 1013934 by adiaferia:

update the space info patch and actually commit it - soliddevice engine issue fixed
CCMAIL:plasma-devel at kde.org


 M  +2 -1      CMakeLists.txt  
 M  +11 -0     devicenotifier.cpp  
 A             devicespaceinfodelegate.cpp   [License: LGPL (v2+)]
 A             devicespaceinfodelegate.h   [License: LGPL (v2)]
 M  +4 -1      notifierdialog.cpp  
 M  +3 -2      notifierdialog.h  
 M  +3 -1      notifierview.cpp  


--- trunk/KDE/kdebase/workspace/plasma/applets/devicenotifier/CMakeLists.txt #1013933:1013934
@@ -3,7 +3,8 @@
 set(devicenotifier_SRCS
     devicenotifier.cpp
     notifierdialog.cpp
-    notifierview.cpp)
+    notifierview.cpp
+    devicespaceinfodelegate.cpp)
 
 kde4_add_plugin(plasma_applet_devicenotifier ${devicenotifier_SRCS})
 target_link_libraries(plasma_applet_devicenotifier ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS})
--- trunk/KDE/kdebase/workspace/plasma/applets/devicenotifier/devicenotifier.cpp #1013933:1013934
@@ -146,6 +146,7 @@
         return;
     }
 
+    kDebug() << data.keys();
     //data from hotplug engine
     //kDebug() << data["udi"] << data["predicateFiles"].toStringList() << data["Device Types"].toStringList();
     QStringList predicateFiles = data["predicateFiles"].toStringList();
@@ -180,6 +181,10 @@
 
         //data from soliddevice engine
     } else if (data["Device Types"].toStringList().contains("Storage Access")) {
+        QList<QVariant> freeSpaceData;
+        freeSpaceData << QVariant(0) << QVariant(0);
+        m_dialog->setDeviceData(source, QVariant(freeSpaceData), NotifierDialog::DeviceFreeSpaceRole);
+
         //kDebug() << "DeviceNotifier::solidDeviceEngine updated" << source;
         if (data["Accessible"].toBool() == true) {
             m_dialog->setUnMount(true,source);
@@ -188,6 +193,12 @@
             QStringList overlays;
             overlays << "emblem-mounted";
             m_dialog->setDeviceData(source, KIcon(m_dialog->getDeviceData(source,NotifierDialog::IconNameRole).toString(), NULL, overlays), Qt::DecorationRole);
+ 
+            if (data["Free Space"].isValid()) {
+                QList<QVariant> freeSpaceData;
+                freeSpaceData << data["Size"] << data["Free Space"];
+                m_dialog->setDeviceData(source, QVariant(freeSpaceData), NotifierDialog::DeviceFreeSpaceRole);
+            }
         } else if (data["Device Types"].toStringList().contains("OpticalDisc")) {
             //Unmounted optical drive
             m_dialog->setDeviceData(source, KIcon("media-eject"), Qt::DecorationRole);
--- trunk/KDE/kdebase/workspace/plasma/applets/devicenotifier/notifierdialog.cpp #1013933:1013934
@@ -51,6 +51,7 @@
 //own
 #include "notifierview.h"
 #include "devicenotifier.h"
+#include "devicespaceinfodelegate.h"
 
 using namespace Notifier;
 using namespace Plasma;
@@ -273,7 +274,9 @@
     m_notifierView->setMinimumSize(150,300);
     m_notifierView->setFocusPolicy(Qt::NoFocus);
 
-    Plasma::Delegate *delegate = new Delegate(this);
+
+    DeviceSpaceInfoDelegate *delegate = new DeviceSpaceInfoDelegate(this);
+    //Plasma::Delegate *delegate = new Delegate(this);
     //map the roles of m_hotplugModel into the standard Plasma::Delegate roles
     delegate->setRoleMapping(Plasma::Delegate::SubTitleRole, ActionRole);
     delegate->setRoleMapping(Plasma::Delegate::ColumnTypeRole, ScopeRole);
--- trunk/KDE/kdebase/workspace/plasma/applets/devicenotifier/notifierdialog.h #1013933:1013934
@@ -69,9 +69,10 @@
               ActionRole = Qt::UserRole + 3,
               IconNameRole = Qt::UserRole + 4,
               ScopeRole = Qt::UserRole + 5,
-              SubTitleMandatoryRole = Qt::UserRole + 6
+              SubTitleMandatoryRole = Qt::UserRole + 6,
+              DeviceFreeSpaceRole =  Qt::UserRole + 7
           };
-  
+
           /**
           * Constructor of the dialog
           * @param notifier the notifier attached to this dialog
--- trunk/KDE/kdebase/workspace/plasma/applets/devicenotifier/notifierview.cpp #1013933:1013934
@@ -18,6 +18,8 @@
 */
 
 #include "notifierview.h"
+#include "devicespaceinfodelegate.h"
+#include "notifierdialog.h"
 
 // Qt
 
@@ -280,7 +282,7 @@
     if (index == currentIndex()) {
         option.state |= QStyle::State_HasFocus;
     }
-
+    QList<QVariant> freeSpaceData = index.data(NotifierDialog::DeviceFreeSpaceRole).toList();
     itemDelegate(index)->paint(&painter,option,index);
 }
 


More information about the Plasma-devel mailing list