Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
Dolphin
Commits
acc42f91
Commit
acc42f91
authored
Dec 15, 2020
by
Ilia Kats
Browse files
fix display of folder sizes for empty folders
also fixes 1 byte error in size calculation for all folders
parent
d74853ef
Pipeline
#44383
passed with stage
in 6 minutes and 49 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/kitemviews/kfileitemlistwidget.cpp
View file @
acc42f91
...
...
@@ -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
{
...
...
src/kitemviews/kfileitemmodelrolesupdater.cpp
View file @
acc42f91
...
...
@@ -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
);
...
...
src/kitemviews/private/kdirectorycontentscounterworker.cpp
View file @
acc42f91
...
...
@@ -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
)))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment