+ // The default check in KStandardItem::setDataValue()
+ // for equal values does not work with a custom value
+ // like KUrl. Hence do a manual check to prevent that
+ // setting an equal URL results in an itemsChanged()
+ // signal.
+ if (dataValue("url").value<KUrl>() != url) {
+ delete m_trashDirLister;
+ if (url.protocol() == 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, 0);
+ m_trashDirLister->setDelayedMimeTypes(true);
+ QObject::connect(m_trashDirLister.data(), static_cast<void(KDirLister::*)()>(&KDirLister::completed),
+ m_signalHandler.data(), &PlacesItemSignalHandler::onTrashDirListerCompleted);
+ m_trashDirLister->openUrl(url);
+ }
+
+ setDataValue("url", url);
+ }