+ return KFilePlacesModel::dropMimeData(data, action, row, column, parent);
+}
+
+QVariant DolphinPlacesModel::data(const QModelIndex &index, int role) const
+{
+ switch (role) {
+ case Qt::DecorationRole:
+ if (isTrash(index)) {
+ if (m_isEmpty) {
+ return QIcon::fromTheme(QStringLiteral("user-trash"));
+ } else {
+ return QIcon::fromTheme(QStringLiteral("user-trash-full"));
+ }
+ }
+ break;
+ case KFilePlacesModel::GroupRole: {
+ // When panels are unlocked, avoid a double "Places" heading,
+ // one from the panel title bar, one from the places view section.
+ if (!m_panelsLocked) {
+ const auto groupType = KFilePlacesModel::groupType(index);
+ if (groupType == KFilePlacesModel::PlacesType) {
+ return QString();
+ }
+ }
+ break;
+ }
+ }
+
+ return KFilePlacesModel::data(index, role);
+}
+
+void DolphinPlacesModel::slotTrashEmptinessChanged(bool isEmpty)
+{
+ if (m_isEmpty == isEmpty) {
+ return;
+ }
+
+ // NOTE Trash::isEmpty() reads the config file whereas emptinessChanged is
+ // hooked up to whether a dirlister in trash:/ has any files and they disagree...
+ m_isEmpty = isEmpty;
+
+ for (int i = 0; i < rowCount(); ++i) {
+ const QModelIndex index = this->index(i, 0);
+ if (isTrash(index)) {
+ Q_EMIT dataChanged(index, index, {Qt::DecorationRole});
+ }
+ }
+}
+
+bool DolphinPlacesModel::isTrash(const QModelIndex &index) const
+{
+ return url(index) == QUrl(QStringLiteral("trash:/"));
+}
+
+DolphinPlacesModelSingleton::DolphinPlacesModelSingleton()
+ : m_placesModel(new DolphinPlacesModel())
+{