]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Remove KonqOperations::emptyTrash() and port to KIO::emptyTrash() instead.
authorDavid Faure <faure@kde.org>
Thu, 21 Aug 2014 20:01:23 +0000 (22:01 +0200)
committerDavid Faure <faure@kde.org>
Thu, 21 Aug 2014 20:01:23 +0000 (22:01 +0200)
src/dolphincontextmenu.cpp
src/panels/places/placespanel.cpp

index 1fca7509bf3fb68fbdb2897894ca916b98b43607..22272fb74b10f0c1b1530947dba850603fca9165 100644 (file)
@@ -35,6 +35,8 @@
 #include <KGlobal>
 #include <KIconLoader>
 #include <KIO/RestoreJob>
+#include <KIO/EmptyTrashJob>
+#include <KIO/JobUiDelegate>
 #include <KJobUiDelegate>
 #include <KJobWidgets>
 #include <KMenu>
@@ -158,7 +160,13 @@ void DolphinContextMenu::openTrashContextMenu()
     addShowMenuBarAction();
 
     if (exec(m_pos) == emptyTrashAction) {
-        KonqOperations::emptyTrash(m_mainWindow);
+        KIO::JobUiDelegate uiDelegate;
+        uiDelegate.setWindow(m_mainWindow);
+        if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
+            KIO::Job* job = KIO::emptyTrash();
+            KJobWidgets::setWindow(job, m_mainWindow);
+            job->ui()->setAutoErrorHandlingEnabled(true);
+        }
     }
 }
 
index 487751931ad370cf1ecedfe7df61972b6c011550..ce6c7b7ab36edc2b438a1a8abb224896560e1d90 100644 (file)
@@ -29,6 +29,7 @@
 #include <KDirNotify>
 #include <KIcon>
 #include <KIO/Job>
+#include <KIO/EmptyTrashJob>
 #include <KIO/JobUiDelegate>
 #include <KJobWidgets>
 #include <KLocale>
@@ -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);
     }
 }