┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2024-01-22 18:33:09 +0100
committerFelix Ernst <[email protected]>2024-01-23 11:13:00 +0000
commite817c3246cf512a89a3de003763273f29d9cfe8c (patch)
tree7addce2c5685d1792ad9f7f1a777e4fec7211a8e /src/kitemviews
parenta85302d567bd6fdc1fb8678ce827ed409da73485 (diff)
Slightly refactor count resorting
The bug fix 8f043b2958477d3fe2ef094b7e42f792f4cf0b02 introduced a secondary code path to trigger a resort of items. However, the previous way to trigger it only required a small bug fix to work and gives us a couple of optimisations for free. This commit removes the secondary code path and fixes the primary one. CCBUG: 473999
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp5
-rw-r--r--src/kitemviews/kfileitemmodel.h4
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp4
3 files changed, 5 insertions, 8 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 81c3be640..f9bab74cd 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -1726,7 +1726,8 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList &i
// Trigger a resorting if necessary. Note that this can happen even if the sort
// role has not changed at all because the file name can be used as a fallback.
- if (changedRoles.contains(sortRole()) || changedRoles.contains(roleForType(NameRole))) {
+ if (changedRoles.contains(sortRole()) || changedRoles.contains(roleForType(NameRole))
+ || (changedRoles.contains("count") && sortRole() == "size")) { // "count" is used in the "size" sort role, so this might require a resorting.
for (const KItemRange &range : itemRanges) {
bool needsResorting = false;
@@ -1751,7 +1752,7 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList &i
}
if (needsResorting) {
- m_resortAllItemsTimer->start();
+ scheduleResortAllItems();
return;
}
}
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h
index f87d2d543..ad1b0a138 100644
--- a/src/kitemviews/kfileitemmodel.h
+++ b/src/kitemviews/kfileitemmodel.h
@@ -205,8 +205,6 @@ public:
/** set to true to hide application/x-trash files */
void setShowTrashMime(bool show);
- void scheduleResortAllItems();
-
Q_SIGNALS:
/**
* Is emitted if the loading of a directory has been started. It is
@@ -464,6 +462,8 @@ private:
*/
bool isChildItem(int index) const;
+ void scheduleResortAllItems();
+
/**
* Is invoked by KFileItemModelRolesUpdater and results in emitting the
* sortProgress signal with a percent-value of the progress.
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 9dfa674bc..2a3a8eeb3 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -1354,10 +1354,6 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, newData);
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
-
- if (newData.contains("count") && m_model->sortRole() == "size") {
- m_model->scheduleResortAllItems();
- }
}
});
return;