┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/places
diff options
context:
space:
mode:
Diffstat (limited to 'src/panels/places')
-rw-r--r--src/panels/places/placesitem.cpp22
-rw-r--r--src/panels/places/placesitem.h6
-rw-r--r--src/panels/places/placesitemsignalhandler.cpp7
-rw-r--r--src/panels/places/placesitemsignalhandler.h5
-rw-r--r--src/panels/places/placespanel.cpp31
-rw-r--r--src/panels/places/placespanel.h2
6 files changed, 10 insertions, 63 deletions
diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp
index 20c19e152..ff81e8e63 100644
--- a/src/panels/places/placesitem.cpp
+++ b/src/panels/places/placesitem.cpp
@@ -21,6 +21,7 @@
***************************************************************************/
#include "placesitem.h"
+#include "trash/dolphintrash.h"
#include "dolphindebug.h"
#include "placesitemsignalhandler.h"
@@ -60,16 +61,9 @@ void PlacesItem::setUrl(const QUrl &url)
if (dataValue("url").toUrl() != url) {
delete m_trashDirLister;
if (url.scheme() == QLatin1String("trash")) {
- // The trash icon must always be updated dependent on whether
- // the trash is empty or not. We use a KDirLister that automatically
- // watches for changes if the number of items has been changed.
- // The update of the icon is handled in onTrashDirListerCompleted().
- m_trashDirLister = new KDirLister();
- m_trashDirLister->setAutoErrorHandlingEnabled(false, nullptr);
- m_trashDirLister->setDelayedMimeTypes(true);
- QObject::connect(m_trashDirLister.data(), static_cast<void(KDirLister::*)()>(&KDirLister::completed),
- m_signalHandler.data(), &PlacesItemSignalHandler::onTrashDirListerCompleted);
- m_trashDirLister->openUrl(url);
+ QObject::connect(&Trash::instance(), &Trash::emptinessChanged, [this](bool isTrashEmpty){
+ setIcon(isTrashEmpty ? QStringLiteral("user-trash") : QStringLiteral("user-trash-full"));
+ });
}
setDataValue("url", url);
@@ -239,14 +233,6 @@ void PlacesItem::onAccessibilityChanged()
setUrl(QUrl::fromLocalFile(m_access->filePath()));
}
-void PlacesItem::onTrashDirListerCompleted()
-{
- Q_ASSERT(url().scheme() == QLatin1String("trash"));
-
- const bool isTrashEmpty = m_trashDirLister->items().isEmpty();
- setIcon(isTrashEmpty ? QStringLiteral("user-trash") : QStringLiteral("user-trash-full"));
-}
-
void PlacesItem::updateBookmarkForRole(const QByteArray& role)
{
Q_ASSERT(!m_bookmark.isNull());
diff --git a/src/panels/places/placesitem.h b/src/panels/places/placesitem.h
index 680590dcd..3de626983 100644
--- a/src/panels/places/placesitem.h
+++ b/src/panels/places/placesitem.h
@@ -92,12 +92,6 @@ private:
void onAccessibilityChanged();
/**
- * Is invoked if the listing of the trash has been completed.
- * Updates the state of the trash-icon to be empty or full.
- */
- void onTrashDirListerCompleted();
-
- /**
* Applies the data-value from the role to m_bookmark.
*/
void updateBookmarkForRole(const QByteArray& role);
diff --git a/src/panels/places/placesitemsignalhandler.cpp b/src/panels/places/placesitemsignalhandler.cpp
index 5531d1b63..c85c8336e 100644
--- a/src/panels/places/placesitemsignalhandler.cpp
+++ b/src/panels/places/placesitemsignalhandler.cpp
@@ -39,13 +39,6 @@ void PlacesItemSignalHandler::onAccessibilityChanged()
}
}
-void PlacesItemSignalHandler::onTrashDirListerCompleted()
-{
- if (m_item) {
- m_item->onTrashDirListerCompleted();
- }
-}
-
void PlacesItemSignalHandler::onTearDownRequested(const QString& udi)
{
Q_UNUSED(udi)
diff --git a/src/panels/places/placesitemsignalhandler.h b/src/panels/places/placesitemsignalhandler.h
index 49c8e43c9..6158d7180 100644
--- a/src/panels/places/placesitemsignalhandler.h
+++ b/src/panels/places/placesitemsignalhandler.h
@@ -56,11 +56,6 @@ public slots:
*/
void onAccessibilityChanged();
- /**
- * Calls PlacesItem::onTrashDirListerCompleted()
- */
- void onTrashDirListerCompleted();
-
void onTearDownRequested(const QString& udi);
signals:
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 29acd034c..216b76038 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -25,16 +25,17 @@
#include "dolphin_generalsettings.h"
#include "global.h"
+#include "kitemviews/kitemlistcontainer.h"
+#include "kitemviews/kitemlistcontroller.h"
+#include "kitemviews/kitemlistselectionmanager.h"
+#include "kitemviews/kstandarditem.h"
#include "placesitem.h"
#include "placesitemeditdialog.h"
#include "placesitemlistgroupheader.h"
#include "placesitemlistwidget.h"
#include "placesitemmodel.h"
#include "placesview.h"
-#include "kitemviews/kitemlistcontainer.h"
-#include "kitemviews/kitemlistcontroller.h"
-#include "kitemviews/kitemlistselectionmanager.h"
-#include "kitemviews/kstandarditem.h"
+#include "trash/dolphintrash.h"
#include "views/draganddrophelper.h"
#include <KDirNotify>
@@ -226,7 +227,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
QAction* action = menu.exec(pos.toPoint());
if (action) {
if (action == emptyTrashAction) {
- emptyTrash();
+ Trash::empty(this);
} else {
// The index might have changed if devices were added/removed while
// the context menu was open.
@@ -425,15 +426,6 @@ void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget*
}
}
-void PlacesPanel::slotTrashUpdated(KJob* job)
-{
- if (job->error()) {
- emit errorMessage(job->errorString());
- }
- // as long as KIO doesn't do this, do it ourselves
- KNotification::event(QStringLiteral("Trash: emptied"), QString(), QPixmap(), nullptr, KNotification::DefaultEvent);
-}
-
void PlacesPanel::slotStorageSetupDone(int index, bool success)
{
disconnect(m_model, &PlacesItemModel::storageSetupDone,
@@ -453,17 +445,6 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
}
}
-void PlacesPanel::emptyTrash()
-{
- 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);
- }
-}
-
void PlacesPanel::addEntry()
{
const int index = m_controller->selectionManager()->currentItem();
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 7159357f8..d62697940 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -68,11 +68,9 @@ private slots:
void slotItemDropEventStorageSetupDone(int index, bool success);
void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
- void slotTrashUpdated(KJob* job);
void slotStorageSetupDone(int index, bool success);
private:
- void emptyTrash();
void addEntry();
void editEntry(int index);