Dolphin shows the size of directories by listing their contents, which
for some users might cause unwanted load on the file system.
Depending on the size of the subdirectories in question and how the
storage is accessed, this might cause noticeable delays and even
freezing.
This commit adds a new option under "View -> Content Display" that
enables users to set "Folder size:" to "No size", completely disabling
directory size counting. Directory size counting is still enabled by
default.
As a third option for "Folder size" is added, the DirectorySizeCount
boolean setting is replaced with a DirectorySizeMode enum setting. The
old setting is migrated using a kconf_update script.
FEATURE: 477187
GUI:
<guiicon>></guiicon> icon and collapsed by clicking the <guiicon>v</guiicon> icon.
</para>
<para>
<guiicon>></guiicon> icon and collapsed by clicking the <guiicon>v</guiicon> icon.
</para>
<para>
-<guilabel>Folder size displays</guilabel> allows defining the property to use then sorting folders by their size. It is possible to sort folders by <guilabel>Number of items</guilabel> or <guilabel>Size of contents</guilabel> and choose a limit to the recursive level (can be useful to constrain unneeded iterations in the deep folder structures or on the slow file systems).
+<guilabel>Folder size</guilabel> allows defining the property to use for sorting folders by their size.
+It is possible to sort folders by number of items by choosing <guilabel>Show number of items</guilabel> or by the size of the contents by choosing <guilabel>Show size of contents</guilabel>.
+The recursion level can be limited, which can be useful to constrain unneeded iterations in deep folder structures or on slow file systems.
+It is also possible to disable displaying folder size by choosing <guilabel>Show no size</guilabel> (which might improve performance in rare cases, however impacts other features like sorting).
</para>
<para>
The <guilabel>Date style</guilabel> option can be used to configure the mode to display dates in &dolphin;. It is possible to choose between <guilabel>Relative</guilabel> (⪚, <quote>Yesterday, 3:00pm</quote>) or <guilabel>Absolute</guilabel> (⪚, <quote>2020-12-23 15:00</quote>).
</para>
<para>
The <guilabel>Date style</guilabel> option can be used to configure the mode to display dates in &dolphin;. It is possible to choose between <guilabel>Relative</guilabel> (⪚, <quote>Yesterday, 3:00pm</quote>) or <guilabel>Absolute</guilabel> (⪚, <quote>2020-12-23 15:00</quote>).
DESTINATION ${KDE_INSTALL_KCFGDIR} )
install( FILES settings/dolphin_detailsmodesettings.upd
DESTINATION ${KDE_INSTALL_KCFGDIR} )
install( FILES settings/dolphin_detailsmodesettings.upd
+ settings/dolphin_directorysizemode.upd
+ settings/dolphin_directorysizemode.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR} )
if(BUILD_TESTING)
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR} )
if(BUILD_TESTING)
if (values.value("isDir").toBool()) {
if (!roleValue.isNull() && roleValue != -1) {
// The item represents a directory.
if (values.value("isDir").toBool()) {
if (!roleValue.isNull() && roleValue != -1) {
// The item represents a directory.
- if (ContentDisplaySettings::directorySizeCount() || roleValue == -2 /* size is invalid */) {
+ if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount
+ || roleValue == -2 /* size is invalid */) {
// 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);
// 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);
- if (m_sortDirsFirst || (ContentDisplaySettings::directorySizeCount() && m_sortRole == SizeRole)) {
+ if (m_sortDirsFirst
+ || (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount && m_sortRole == SizeRole)) {
const bool isDirA = a->item.isDir();
const bool isDirB = b->item.isDir();
if (isDirA && !isDirB) {
const bool isDirA = a->item.isDir();
const bool isDirB = b->item.isDir();
if (isDirA && !isDirB) {
- if (ContentDisplaySettings::directorySizeCount() && itemA.isDir()) {
+ if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount && itemA.isDir()) {
// folders first then
// items A and B are folders thanks to lessThan checks
auto valueA = a->values.value("count");
// folders first then
// items A and B are folders thanks to lessThan checks
auto valueA = a->values.value("count");
KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
QString newGroupValue;
if (!item.isNull() && item.isDir()) {
KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
QString newGroupValue;
if (!item.isNull() && item.isDir()) {
- if (ContentDisplaySettings::directorySizeCount() || m_sortDirsFirst) {
+ if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount || m_sortDirsFirst) {
newGroupValue = i18nc("@title:group Size", "Folders");
} else {
fileSize = m_itemData.at(i)->values.value("size").toULongLong();
newGroupValue = i18nc("@title:group Size", "Folders");
} else {
fileSize = m_itemData.at(i)->values.value("size").toULongLong();
void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &item, int index)
{
void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &item, int index)
{
- if (!item.isLocalFile()) {
+ if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::None || !item.isLocalFile()) {
- if (ContentDisplaySettings::directorySizeCount() || item.isSlow()) {
+ if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount || item.isSlow()) {
// fastpath no recursion necessary
auto data = m_model->data(index);
// fastpath no recursion necessary
auto data = m_model->data(index);
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfgfile name="dolphinrc"/>
<group name="ContentDisplay">
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfgfile name="dolphinrc"/>
<group name="ContentDisplay">
- <entry name="DirectorySizeCount" type="Bool">
- <label>Whether or not content count is used as directory size</label>
- <default>true</default>
+ <entry name="DirectorySizeMode" type="Enum">
+ <label>How we display the size of directories</label>
+ <choices>
+ <choice name="ContentCount">
+ <label>Show the content count</label>
+ </choice>
+ <choice name="ContentSize">
+ <label>Show the content size</label>
+ </choice>
+ <choice name="None">
+ <label>Do not show any directory size</label>
+ </choice>
+ </choices>
+ <default>ContentCount</default>
</entry>
<entry name="RecursiveDirectorySizeLimit" type="UInt">
<label>Recursive directory size limit</label>
</entry>
<entry name="RecursiveDirectorySizeLimit" type="UInt">
<label>Recursive directory size limit</label>
--- /dev/null
+import fileinput
+
+for line in fileinput.input():
+ if line.startswith("DirectorySizeCount=true"):
+ print("DirectorySizeMode=ContentCount")
+ if line.startswith("DirectorySizeCount=false"):
+ print("DirectorySizeMode=ContentSize")
+
+print("# DELETE DirectorySizeCount")
+
--- /dev/null
+#Configuration update for Dolphin
+Version=5
+
+#Convert DirectorySizeCount to enum DirectorySizeMode
+Id=convert-directorysizecount-to-directorysizemode
+File=dolphinrc
+Group=ContentDisplay
+Script=dolphin_directorysizemode.py,python3
+
, m_caseInsensitiveSorting(nullptr)
, m_numberOfItems(nullptr)
, m_sizeOfContents(nullptr)
, m_caseInsensitiveSorting(nullptr)
, m_numberOfItems(nullptr)
, m_sizeOfContents(nullptr)
+ , m_noDirectorySize(nullptr)
, m_recursiveDirectorySizeLimit(nullptr)
, m_useRelatetiveDates(nullptr)
, m_useShortDates(nullptr)
, m_recursiveDirectorySizeLimit(nullptr)
, m_useRelatetiveDates(nullptr)
, m_useShortDates(nullptr)
#ifndef Q_OS_WIN
// Sorting properties
#ifndef Q_OS_WIN
// Sorting properties
- m_numberOfItems = new QRadioButton(i18nc("option:radio", "Number of items"));
- m_sizeOfContents = new QRadioButton(i18nc("option:radio", "Size of contents, up to "));
+ m_numberOfItems = new QRadioButton(i18nc("option:radio", "Show number of items"));
+ m_sizeOfContents = new QRadioButton(i18nc("option:radio", "Show size of contents, up to "));
+ m_noDirectorySize = new QRadioButton(i18nc("option:radio", "Show no size"));
QButtonGroup *sortingModeGroup = new QButtonGroup(this);
sortingModeGroup->addButton(m_numberOfItems);
sortingModeGroup->addButton(m_sizeOfContents);
QButtonGroup *sortingModeGroup = new QButtonGroup(this);
sortingModeGroup->addButton(m_numberOfItems);
sortingModeGroup->addButton(m_sizeOfContents);
+ sortingModeGroup->addButton(m_noDirectorySize);
m_recursiveDirectorySizeLimit = new QSpinBox();
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, [this](int value) {
m_recursiveDirectorySizeLimit = new QSpinBox();
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, [this](int value) {
contentsSizeLayout->addWidget(m_sizeOfContents);
contentsSizeLayout->addWidget(m_recursiveDirectorySizeLimit);
contentsSizeLayout->addWidget(m_sizeOfContents);
contentsSizeLayout->addWidget(m_recursiveDirectorySizeLimit);
- topLayout->addRow(i18nc("@title:group", "Folder size displays:"), m_numberOfItems);
+ topLayout->addRow(i18nc("@title:group", "Folder size:"), m_numberOfItems);
topLayout->addRow(QString(), contentsSizeLayout);
topLayout->addRow(QString(), contentsSizeLayout);
+ topLayout->addRow(QString(), m_noDirectorySize);
#endif
QDateTime thirtyMinutesAgo = QDateTime::currentDateTime().addSecs(-30 * 60);
#endif
QDateTime thirtyMinutesAgo = QDateTime::currentDateTime().addSecs(-30 * 60);
connect(m_sizeOfContents, &QRadioButton::toggled, this, [=]() {
m_recursiveDirectorySizeLimit->setEnabled(m_sizeOfContents->isChecked());
});
connect(m_sizeOfContents, &QRadioButton::toggled, this, [=]() {
m_recursiveDirectorySizeLimit->setEnabled(m_sizeOfContents->isChecked());
});
+ connect(m_noDirectorySize, &QRadioButton::toggled, this, &SettingsPageBase::changed);
#endif
connect(m_useRelatetiveDates, &QRadioButton::toggled, this, &SettingsPageBase::changed);
#endif
connect(m_useRelatetiveDates, &QRadioButton::toggled, this, &SettingsPageBase::changed);
{
auto settings = ContentDisplaySettings::self();
#ifndef Q_OS_WIN
{
auto settings = ContentDisplaySettings::self();
#ifndef Q_OS_WIN
- settings->setDirectorySizeCount(m_numberOfItems->isChecked());
+ if (m_numberOfItems->isChecked()) {
+ settings->setDirectorySizeMode(ContentDisplaySettings::EnumDirectorySizeMode::ContentCount);
+ } else if (m_sizeOfContents->isChecked()) {
+ settings->setDirectorySizeMode(ContentDisplaySettings::EnumDirectorySizeMode::ContentSize);
+ } else if (m_noDirectorySize->isChecked()) {
+ settings->setDirectorySizeMode(ContentDisplaySettings::EnumDirectorySizeMode::None);
+ }
+
settings->setRecursiveDirectorySizeLimit(m_recursiveDirectorySizeLimit->value());
#endif
setSortingChoiceValue();
settings->setRecursiveDirectorySizeLimit(m_recursiveDirectorySizeLimit->value());
#endif
setSortingChoiceValue();
{
auto settings = ContentDisplaySettings::self();
#ifndef Q_OS_WIN
{
auto settings = ContentDisplaySettings::self();
#ifndef Q_OS_WIN
- if (settings->directorySizeCount()) {
- m_numberOfItems->setChecked(true);
- m_recursiveDirectorySizeLimit->setEnabled(false);
- } else {
- m_sizeOfContents->setChecked(true);
- m_recursiveDirectorySizeLimit->setEnabled(true);
- }
+ m_numberOfItems->setChecked(settings->directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount);
+ m_sizeOfContents->setChecked(settings->directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentSize);
+ m_noDirectorySize->setChecked(settings->directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::None);
m_recursiveDirectorySizeLimit->setValue(settings->recursiveDirectorySizeLimit());
#endif
m_useRelatetiveDates->setChecked(settings->useShortRelativeDates());
m_recursiveDirectorySizeLimit->setValue(settings->recursiveDirectorySizeLimit());
#endif
m_useRelatetiveDates->setChecked(settings->useShortRelativeDates());
QRadioButton *m_numberOfItems;
QRadioButton *m_sizeOfContents;
QRadioButton *m_numberOfItems;
QRadioButton *m_sizeOfContents;
+ QRadioButton *m_noDirectorySize;
QSpinBox *m_recursiveDirectorySizeLimit;
QRadioButton *m_useRelatetiveDates;
QRadioButton *m_useShortDates;
QSpinBox *m_recursiveDirectorySizeLimit;
QRadioButton *m_useRelatetiveDates;
QRadioButton *m_useShortDates;