Commit a3559a19 authored by Méven Car's avatar Méven Car
Browse files

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 d520b417
parent 216068bd
Pipeline #67694 passed with stage
in 5 minutes and 48 seconds
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment