]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.cpp
Merge branch 'master' into frameworks
[dolphin.git] / src / panels / places / placespanel.cpp
index d3614c9ce1c0c6d5f7ca56e229e98e8fccc7ed34..37965eb90b9c452f1ace2d60f086385c7cefd8ea 100644 (file)
@@ -29,6 +29,7 @@
 #include <KDirNotify>
 #include <KIcon>
 #include <KIO/Job>
+#include <KIO/EmptyTrashJob>
 #include <KIO/JobUiDelegate>
 #include <KJobWidgets>
 #include <KLocale>
@@ -338,7 +339,7 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
 
     const PlacesItem* destItem = m_model->placesItem(index);
     const PlacesItem::GroupType group = destItem->groupType();
-    if (group == PlacesItem::SearchForType || group == PlacesItem::RecentlyAccessedType) {
+    if (group == PlacesItem::SearchForType || group == PlacesItem::RecentlySavedType) {
         return;
     }
 
@@ -426,7 +427,8 @@ void PlacesPanel::slotTrashUpdated(KJob* job)
     if (job->error()) {
         emit errorMessage(job->errorString());
     }
-    org::kde::KDirNotify::emitFilesAdded(QUrl("trash:/"));
+    // as long as KIO doesn't do this, do it ourselves
+    KNotification::event("Trash: emptied", QString(), QPixmap(), 0, KNotification::DefaultEvent);
 }
 
 void PlacesPanel::slotStorageSetupDone(int index, bool success)
@@ -450,20 +452,11 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
 
 void PlacesPanel::emptyTrash()
 {
-    const QString text = i18nc("@info", "Do you really want to empty the Trash? All items will be deleted.");
-    const bool del = KMessageBox::warningContinueCancel(window(),
-                                                        text,
-                                                        QString(),
-                                                        KGuiItem(i18nc("@action:button", "Empty Trash"),
-                                                                 KIcon("user-trash"))
-                                                       ) == KMessageBox::Continue;
-    if (del) {
-        QByteArray packedArgs;
-        QDataStream stream(&packedArgs, QIODevice::WriteOnly);
-        stream << int(1);
-        KIO::Job *job = KIO::special(KUrl("trash:/"), packedArgs);
-        KNotification::event("Trash: emptied", QString() , QPixmap() , 0, KNotification::DefaultEvent);
-        KJobWidgets::setWindow(job, parentWidget());
+    KIO::JobUiDelegate uiDelegate;
+    uiDelegate.setWindow(window());
+    if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
+        KIO::Job* job = KIO::emptyTrash();
+        KJobWidgets::setWindow(job, window());
         connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated);
     }
 }
@@ -546,4 +539,3 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
 }
 
 
-#include "placespanel.moc"