mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
fix display of folder sizes for empty folders
also fixes 1 byte error in size calculation for all folders
This commit is contained in:
parent
d74853ef85
commit
acc42f9189
|
@ -53,20 +53,16 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
|
||||||
|
|
||||||
if (role == "size") {
|
if (role == "size") {
|
||||||
if (values.value("isDir").toBool()) {
|
if (values.value("isDir").toBool()) {
|
||||||
// The item represents a directory.
|
if (!roleValue.isNull() && roleValue != -1) {
|
||||||
if (!roleValue.isNull()) {
|
// The item represents a directory.
|
||||||
const int count = values.value("count").toInt();
|
if (DetailsModeSettings::directorySizeCount()) {
|
||||||
if (count > 0) {
|
// Show the number of sub directories instead of the file size of the directory.
|
||||||
if (DetailsModeSettings::directorySizeCount()) {
|
const int count = values.value("count").toInt();
|
||||||
// Show the number of sub directories instead of the file size of the directory.
|
text = i18ncp("@item:intable", "%1 item", "%1 items", count);
|
||||||
text = i18ncp("@item:intable", "%1 item", "%1 items", count);
|
} else {
|
||||||
} else {
|
// if we have directory size available
|
||||||
// if we have directory size available
|
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
||||||
if (roleValue != -1) {
|
text = KFormat().formatByteSize(size);
|
||||||
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
|
||||||
text = KFormat().formatByteSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -776,9 +776,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
|
||||||
|
|
||||||
if (getSizeRole) {
|
if (getSizeRole) {
|
||||||
data.insert("count", count);
|
data.insert("count", count);
|
||||||
if (size != -1) {
|
data.insert("size", QVariant::fromValue(size));
|
||||||
data.insert("size", QVariant::fromValue(size));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (getIsExpandableRole) {
|
if (getIsExpandableRole) {
|
||||||
data.insert("isExpandable", count > 0);
|
data.insert("isExpandable", count > 0);
|
||||||
|
|
|
@ -35,6 +35,7 @@ KDirectoryContentsCounterWorker::CountResult walkDir(const QString &dirPath,
|
||||||
auto dir = QT_OPENDIR(QFile::encodeName(dirPath));
|
auto dir = QT_OPENDIR(QFile::encodeName(dirPath));
|
||||||
if (dir) {
|
if (dir) {
|
||||||
count = 0;
|
count = 0;
|
||||||
|
size = 0;
|
||||||
QT_STATBUF buf;
|
QT_STATBUF buf;
|
||||||
|
|
||||||
while ((dirEntry = QT_READDIR(dir))) {
|
while ((dirEntry = QT_READDIR(dir))) {
|
||||||
|
|
Loading…
Reference in a new issue