X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0dd0b65bf02f52da0d2e9d270160e69b81a357ca..ec12391a1b:/src/panels/places/placesitem.cpp diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp index 3c6023ba8..ee168e4a3 100644 --- a/src/panels/places/placesitem.cpp +++ b/src/panels/places/placesitem.cpp @@ -21,13 +21,13 @@ ***************************************************************************/ #include "placesitem.h" +#include "trash/dolphintrash.h" -#include #include "dolphindebug.h" +#include "placesitemsignalhandler.h" + #include #include -#include "placesitemsignalhandler.h" -#include #include PlacesItem::PlacesItem(const KBookmark& bookmark, PlacesItem* parent) : @@ -61,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(&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); @@ -146,7 +139,7 @@ void PlacesItem::setBookmark(const KBookmark& bookmark) const QString udi = bookmark.metaDataItem(QStringLiteral("UDI")); if (udi.isEmpty()) { setIcon(bookmark.icon()); - setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData())); + setText(i18ndc("kio5", "KFile System Bookmarks", bookmark.text().toUtf8().constData())); setUrl(bookmark.url()); setSystemItem(bookmark.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true")); } else { @@ -240,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()); @@ -260,7 +245,7 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role) // // NOTE: It is important to use "KFile System Bookmarks" as context // (see PlacesItemModel::createSystemBookmarks()). - if (text() != i18nc("KFile System Bookmarks", m_bookmark.text().toUtf8().data())) { + if (text() != i18ndc("kio5", "KFile System Bookmarks", m_bookmark.text().toUtf8().data())) { m_bookmark.setFullText(text()); } } else if (role == "url") {