[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-20 10:40:06
Message-ID: 1203504006.364151.25263.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 777281 by mart:
-remove dolphin sidebar items when dropped in the trashcan
-fix a compile warning
M +1 -1 CMakeLists.txt
M +18 -7 trash.cpp
M +3 -1 trash.h
--- trunk/kdereview/plasma/applets/trash/CMakeLists.txt #777280:777281
@@ -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} ${SOLID_LIBS} konq \
${KDE4_KIO_LIBS}) +target_link_libraries(plasma_applet_trash ${PLASMA_LIBS} \
${SOLID_LIBS} konq ${KDE4_KFILE_LIBS} ${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 #777280:777281
@@ -35,6 +35,7 @@
#include <KMessageBox>
#include <KUrl>
#include <konq_operations.h>
+#include <kfileplacesmodel.h>
//Plasma
#include <plasma/widgets/icon.h>
@@ -66,6 +67,8 @@
{
m_icon = new Plasma::Icon(KIcon("user-trash"),QString(),this);
+ m_places = new KFilePlacesModel(this);
+
createMenu();
connect(m_icon, SIGNAL(activated()), this, SLOT(slotOpen()));
@@ -116,7 +119,7 @@
m_icon->addAction(menu);
}
-void Trash::popup(bool pressed)
+void Trash::popup()
{
if (m_menu.isVisible()) {
m_menu.hide();
@@ -265,7 +268,6 @@
moveBy(delta.x(),delta.y());
} else if (parent) {
//don't move the icon as well because our parent (usually an \
appletHandle) will do it for us
- //parent->moveBy(delta.x(),delta.y());
QPointF curPos = parent->transform().map(event->pos());
QPointF lastPos = parent->transform().map(event->lastPos());
QPointF delta = curPos-lastPos;
@@ -297,16 +299,20 @@
if (urls.count() > 0) {
event->accept();
- //if some of the urls dropped are mountpoints unmount them instead of \
deleting
- bool hasDevices = false;
+ //some spacial operation was done instead of simply deleting a file
+ bool specialOperation = false;
foreach (KUrl url, urls) {
Solid::Predicate predicate = \
Solid::Predicate(Solid::DeviceInterface::StorageAccess, "filePath", url.path());
+ //query for mounted devices
QList<Solid::Device> devList = \
Solid::Device::listFromQuery(predicate, QString());
+ //seek for an item in the places (e.g. Dolphin sidebar)
+ const QModelIndex index = m_places->closestItem(url);
+
if (devList.count() > 0) {
- //Assuming there is only one mountpoint per device
+ //Assuming a mountpoint has a single device
Solid::Device device = devList.first();
if (device.is<Solid::OpticalDisc>()) {
@@ -315,11 +321,16 @@
device.as<Solid::StorageAccess>()->teardown();
}
- hasDevices = true;
+ specialOperation = true;
+ //hide if there is exactly that item in the places model
+ } else if (m_places->bookmarkForIndex(index).url() == url) {
+ m_places->removePlace(index);
+ specialOperation = true;
}
}
- if (!hasDevices) {
+ //finally, try to trash a file
+ if (!specialOperation) {
KonqOperations::del( &m_menu, KonqOperations::TRASH, urls );
}
}
--- trunk/kdereview/plasma/applets/trash/trash.h #777280:777281
@@ -31,6 +31,7 @@
#include <plasma/applet.h>
class KPropertiesDialog;
+class KFilePlacesModel;
class QAction;
namespace Plasma
@@ -62,7 +63,7 @@
void setIcon();
protected slots:
- void popup(bool pressed);
+ void popup();
void slotClear();
void slotCompleted();
void slotDeleteItem(const KFileItem &);
@@ -78,6 +79,7 @@
int m_count;
bool m_showText;
Plasma::ToolTipData m_data;
+ KFilePlacesModel *m_places;
};
K_EXPORT_PLASMA_APPLET(trash, Trash)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic