From a2c9c05de2dfabbb2bb614390c8e03023dad2bd1 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Tue, 29 Nov 2022 18:16:59 +0000 Subject: Exit the deleted directory when it is removed If current directory is a local file, try to find nearest dir ancestor and open it. Display warning to the user. --- src/kitemviews/kfileitemmodel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 1c48b2275..c08f8e964 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1150,7 +1150,14 @@ void KFileItemModel::slotItemsDeleted(const KFileItemList& items) indexesToRemove.reserve(items.count()); KFileItemList dirsChanged; + const auto currentDir = directory(); + for (const KFileItem& item : items) { + if (item.url() == currentDir) { + Q_EMIT currentDirectoryRemoved(); + return; + } + const int indexForItem = index(item); if (indexForItem >= 0) { indexesToRemove.append(indexForItem); -- cgit v1.3