From kde-commits Wed Feb 13 13:25:26 2008 From: Marco Martin Date: Wed, 13 Feb 2008 13:25:26 +0000 To: kde-commits Subject: kdereview/plasma/applets/trash Message-Id: <1202909126.632284.26513.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=120290913527420 SVN commit 774536 by mart: Experiment: eject (with solid) cds and unmount drives when they are dropped on the trashcan M +1 -1 CMakeLists.txt M +31 -3 trash.cpp M +0 -1 trash.h --- trunk/kdereview/plasma/applets/trash/CMakeLists.txt #774535:774536 @@ -10,7 +10,7 @@ include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) kde4_add_plugin(plasma_applet_trash ${trash_SRCS}) -target_link_libraries(plasma_applet_trash ${PLASMA_LIBS} konq ${KDE4_KIO_LIBS}) +target_link_libraries(plasma_applet_trash ${PLASMA_LIBS} ${SOLID_LIBS} konq ${KDE4_KIO_LIBS}) install(TARGETS plasma_applet_trash DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES plasma-applet-trash.desktop DESTINATION ${SERVICES_INSTALL_DIR}) --- trunk/kdereview/plasma/applets/trash/trash.cpp #774535:774536 @@ -34,12 +34,22 @@ #include #include #include +#include - -#include +//Plasma #include #include +//Solid +#include +#include +#include +#include +#include +#include +#include + + Trash::Trash(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), m_icon(0), @@ -282,7 +292,25 @@ if (urls.count() > 0) { event->accept(); - KonqOperations::del( &m_menu, KonqOperations::TRASH, urls ); + + //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()); + + foreach (Solid::Device device, Solid::Device::listFromQuery(predicate, QString())) { + if (device.is()) { + device.parent().as()->eject(); + } else { + device.as()->teardown(); + } + + isDevice = true; + } + + if (!isDevice) { + KonqOperations::del( &m_menu, KonqOperations::TRASH, urls ); + } } } --- trunk/kdereview/plasma/applets/trash/trash.h #774535:774536 @@ -29,7 +29,6 @@ #include #include -//#include class KPropertiesDialog; class QAction;