[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdereview/plasma/applets/trash
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-02-13 18:50:52
Message-ID: 1202928652.231743.14877.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 774650 by mart:

Allow to unmount multiple devices at once

 M  +19 -12    trash.cpp  


--- trunk/kdereview/plasma/applets/trash/trash.cpp #774649:774650
@@ -293,22 +293,29 @@
         if (urls.count() > 0) {
             event->accept();
 
-            //try to unmount a mountpoint if the first item is a mountpoint
-            //TODO: decide if iterate all urls if there is more than one (would it \
be too complex? and how to behave if there are ordinary files mixed with mount \
                points?)
-            bool isDevice = false;
-            Solid::Predicate predicate = \
Solid::Predicate(Solid::DeviceInterface::StorageAccess, "filePath", \
urls.first().path()); +            //if some of the urls dropped are mountpoints \
unmount them instead of deleting +            bool hasDevices = false;
 
-            foreach (Solid::Device device, Solid::Device::listFromQuery(predicate, \
                QString())) {
-                if (device.is<Solid::OpticalDisc>()) {
-                    device.parent().as<Solid::OpticalDrive>()->eject();
-                } else {
-                    device.as<Solid::StorageAccess>()->teardown();
+            foreach (KUrl url, urls) {
+                Solid::Predicate predicate = \
Solid::Predicate(Solid::DeviceInterface::StorageAccess, "filePath", url.path()); +
+                QList<Solid::Device> devList = \
Solid::Device::listFromQuery(predicate, QString()); +
+                if (devList.count() > 0) {
+                    //Assuming there is only one mountpoint per device
+                    Solid::Device device = devList.first();
+
+                    if (device.is<Solid::OpticalDisc>()) {
+                        device.parent().as<Solid::OpticalDrive>()->eject();
+                    } else {
+                        device.as<Solid::StorageAccess>()->teardown();
+                    }
+
+                    hasDevices = true;
                 }
-
-                isDevice = true;
             }
 
-            if (!isDevice) {
+            if (!hasDevices) {
                 KonqOperations::del( &m_menu, KonqOperations::TRASH, urls );
             }
         }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic