From kde-commits Wed Feb 13 18:50:52 2008 From: Marco Martin Date: Wed, 13 Feb 2008 18:50:52 +0000 To: kde-commits Subject: kdereview/plasma/applets/trash Message-Id: <1202928652.231743.14877.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120292866202305 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()) { - device.parent().as()->eject(); - } else { - device.as()->teardown(); + foreach (KUrl url, urls) { + Solid::Predicate predicate = Solid::Predicate(Solid::DeviceInterface::StorageAccess, "filePath", url.path()); + + QList 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()) { + device.parent().as()->eject(); + } else { + device.as()->teardown(); + } + + hasDevices = true; } - - isDevice = true; } - if (!isDevice) { + if (!hasDevices) { KonqOperations::del( &m_menu, KonqOperations::TRASH, urls ); } }