1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

rolesupdater: set isExpandable to false when dir is empty

Signed-off-by: Méven Car <meven@kde.org>
This commit is contained in:
Méven Car 2023-12-23 13:48:16 +01:00
parent 5dbea4a227
commit 52559a3a01

View File

@ -1338,16 +1338,24 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
++entryCount;
}
// count has changed
if (origCount < entryCount) {
QHash<QByteArray, QVariant> data;
data.insert("isExpandable", entryCount > 0);
data.insert("count", entryCount);
QHash<QByteArray, QVariant> newData;
QVariant expandable = data.value("isExpandable");
if (expandable.isNull() || expandable.toBool() != (entryCount > 0)) {
// if expandable has changed
newData.insert("isExpandable", entryCount > 0);
}
if (origCount != entryCount) {
// count has changed
newData.insert("count", entryCount);
}
if (!newData.isEmpty()) {
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
m_model->setData(index, newData);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
if (m_model->sortRole() == "size") {
if (newData.contains("count") && m_model->sortRole() == "size") {
m_model->scheduleResortAllItems();
}
}