diff options
| author | Roman Inflianskas <[email protected]> | 2018-03-03 19:44:56 +0300 |
|---|---|---|
| committer | Roman Inflianskas <[email protected]> | 2018-03-11 17:32:33 +0300 |
| commit | f16fbcba4e9ed3cd48cb2c1a40c01daf1d511f4b (patch) | |
| tree | 2dd71c3a19bb24ff82fc7d655f42c5040294a520 /src/panels/places/placesitem.cpp | |
| parent | 0c9343d614872b88da59a7c1a18d19c8df83739f (diff) | |
Add Trash (empty, isEmpty, emptinessChanged)
Summary: Add `Trash` class to handle all trash operations.
Reviewers: elvisangelaccio, markg, ngraham
Reviewed By: elvisangelaccio, markg, ngraham
Subscribers: ngraham, markg, rkflx, elvisangelaccio, #dolphin
Differential Revision: https://phabricator.kde.org/D11012
Diffstat (limited to 'src/panels/places/placesitem.cpp')
| -rw-r--r-- | src/panels/places/placesitem.cpp | 22 |
1 files changed, 4 insertions, 18 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()); |
