┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.cpp
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2021-03-08 07:25:31 +0100
committerMéven Car <[email protected]>2021-06-27 09:19:43 +0000
commita3559a19db218e2a320fd81634d14e7cf891662e (patch)
treeb546b0b8a5949f36955a053393a687af2246c2e2 /src/kitemviews/kfileitemmodel.cpp
parent216068bd7c920d837938c7ffedb78bcce48518d7 (diff)
KFileItemModel: Allow to group files and folder together
When folders size is available and unless sort dir first is set, folders and files can be grouped together in the regular size groups. Without this you can end up with multiple groups being added each time a folder size alternates with a file size. Relates to d520b417c97bdbdfece2a497dac8b5384a80b597
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index a6c5e48ec..9441bc871 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -2026,16 +2026,24 @@ QList<QPair<int, QVariant> > KFileItemModel::sizeRoleGroups() const
}
const KFileItem& item = m_itemData.at(i)->item;
- const KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
+ KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
QString newGroupValue;
if (!item.isNull() && item.isDir()) {
- newGroupValue = i18nc("@title:group Size", "Folders");
- } else if (fileSize < 5 * 1024 * 1024) {
- newGroupValue = i18nc("@title:group Size", "Small");
- } else if (fileSize < 10 * 1024 * 1024) {
- newGroupValue = i18nc("@title:group Size", "Medium");
- } else {
- newGroupValue = i18nc("@title:group Size", "Big");
+ if (DetailsModeSettings::directorySizeCount() || m_sortDirsFirst) {
+ newGroupValue = i18nc("@title:group Size", "Folders");
+ } else {
+ fileSize = m_itemData.at(i)->values.value("size").toULongLong();
+ }
+ }
+
+ if (newGroupValue.isEmpty()) {
+ if (fileSize < 5 * 1024 * 1024) { // < 5 MB
+ newGroupValue = i18nc("@title:group Size", "Small");
+ } else if (fileSize < 10 * 1024 * 1024) { // < 10 MB
+ newGroupValue = i18nc("@title:group Size", "Medium");
+ } else {
+ newGroupValue = i18nc("@title:group Size", "Big");
+ }
}
if (newGroupValue != groupValue) {