┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlia Kats <[email protected]>2020-12-15 22:20:51 +0100
committerIlia Kats <[email protected]>2020-12-17 13:04:01 +0100
commitacc42f918925983e2e83501cd2bacc7952a55718 (patch)
tree343af939dc0b54b07070396d99bab4bc5f5b48fc /src
parentd74853ef850fdabf2dfad8fcbe634af8185fce36 (diff)
fix display of folder sizes for empty folders
also fixes 1 byte error in size calculation for all folders
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemlistwidget.cpp24
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp4
-rw-r--r--src/kitemviews/private/kdirectorycontentscounterworker.cpp1
3 files changed, 12 insertions, 17 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
index 69a40ddf3..66fcafaf6 100644
--- a/src/kitemviews/kfileitemlistwidget.cpp
+++ b/src/kitemviews/kfileitemlistwidget.cpp
@@ -53,20 +53,16 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
if (role == "size") {
if (values.value("isDir").toBool()) {
- // The item represents a directory.
- if (!roleValue.isNull()) {
- const int count = values.value("count").toInt();
- if (count > 0) {
- if (DetailsModeSettings::directorySizeCount()) {
- // Show the number of sub directories instead of the file size of the directory.
- text = i18ncp("@item:intable", "%1 item", "%1 items", count);
- } else {
- // if we have directory size available
- if (roleValue != -1) {
- const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
- text = KFormat().formatByteSize(size);
- }
- }
+ if (!roleValue.isNull() && roleValue != -1) {
+ // The item represents a directory.
+ if (DetailsModeSettings::directorySizeCount()) {
+ // Show the number of sub directories instead of the file size of the directory.
+ const int count = values.value("count").toInt();
+ text = i18ncp("@item:intable", "%1 item", "%1 items", count);
+ } else {
+ // if we have directory size available
+ const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
+ text = KFormat().formatByteSize(size);
}
}
} else {
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 075ec888a..3bd6d977d 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -776,9 +776,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
if (getSizeRole) {
data.insert("count", count);
- if (size != -1) {
- data.insert("size", QVariant::fromValue(size));
- }
+ data.insert("size", QVariant::fromValue(size));
}
if (getIsExpandableRole) {
data.insert("isExpandable", count > 0);
diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.cpp b/src/kitemviews/private/kdirectorycontentscounterworker.cpp
index 1e3b7ff9f..73799e739 100644
--- a/src/kitemviews/private/kdirectorycontentscounterworker.cpp
+++ b/src/kitemviews/private/kdirectorycontentscounterworker.cpp
@@ -35,6 +35,7 @@ KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
auto dir = QT_OPENDIR(QFile::encodeName(dirPath));
if (dir) {
count = 0;
+ size = 0;
QT_STATBUF buf;
while ((dirEntry = QT_READDIR(dir))) {