From 4a7be9f25332942b071e7a1659a7aed67236cfb8 Mon Sep 17 00:00:00 2001 From: Jussi Räsänen Date: Sun, 22 Feb 2026 16:10:02 +0200 Subject: kitemviews: add "Folder Name" column to details view BUG: 433937 --- src/kitemviews/kfileitemmodel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 12b8e2a98..c8bac0b9d 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1707,6 +1707,7 @@ void KFileItemModel::prepareItemsForSorting(QList &itemDataList) case GroupRole: case DestinationRole: case PathRole: + case FolderRole: case DeletionTimeRole: // These roles can be determined with retrieveData, and they have to be stored // in the QHash "values" for the sorting. @@ -1999,6 +2000,13 @@ QHash KFileItemModel::retrieveData(const KFileItem &item, data.insert(sharedValue("path"), path); } + if (m_requestRole[FolderRole]) { + QUrl parentUrl = + (item.url().scheme() == QLatin1String("trash")) ? QUrl::fromLocalFile(item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA)) : item.targetUrl(); + QString folderName = parentUrl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).fileName(); + data.insert(sharedValue("folder"), folderName); + } + if (m_requestRole[DeletionTimeRole]) { QDateTime deletionTime; if (item.url().scheme() == QLatin1String("trash")) { @@ -2846,6 +2854,7 @@ const KFileItemModel::RoleInfoMap *KFileItemModel::rolesInfoMap(int &count) { "videoCodec", VideoCodecRole, kli18nc("@label", "Video Codec"), kli18nc("@label", "Video"), KLazyLocalizedString(), true, true }, { "width", WidthRole, kli18nc("@label", "Width"), kli18nc("@label", "Video"), KLazyLocalizedString(), true, true }, { "path", PathRole, kli18nc("@label", "Path"), kli18nc("@label", "Other"), KLazyLocalizedString(), false, false }, + { "folder", FolderRole, kli18nc("@label", "Folder Name"), kli18nc("@label", "Other"), KLazyLocalizedString(), false, false }, { "extension", ExtensionRole, kli18nc("@label", "File Extension"), kli18nc("@label", "Other"), KLazyLocalizedString(), false, false }, { "deletiontime", DeletionTimeRole, kli18nc("@label", "Deletion Time"), kli18nc("@label", "Other"), KLazyLocalizedString(), false, false }, { "destination", DestinationRole, kli18nc("@label", "Link Destination"), kli18nc("@label", "Other"), KLazyLocalizedString(), false, false }, -- cgit v1.3