Make use of the "resort all items timer" in KFileItemModel::slotRefreshItems
Review Request #111195 - Created June 23, 2013 and submitted
Followup to patch 111146 Make use of the "resort all items timer" in KFileItemModel::slotRefreshItems to avoid too much expensive resorting calls, in case of many refresh items signals. CCBUG: 303873 CCBUG: 299565
Thanks Emmanuel for the patch! In principle you're right that many updates could cause (too) many resortings, and your patch would fix this problem. However, it has the side effect that there will always be a 0.5 second delay between any change of a file and the resorting. This can be a bit irritating, like when you rename a file, and it takes some time until it is moved to the new position. So to fix the problem properly, a solution like the "changes items timer" in KFileItemModelRolesUpdater would be better (i.e., do the first resorting immediately, but if there are many changes in a row, wait until all updates are done). But then I'm not sure how often such a situation will really happen and how urgent is is that we fix that. The "too many resortings" issue will only appear if the sort role is changed for many files at different times. I think that this is rather unrealistic for the "Name" and the "Size", maybe it could happen for the "Date"? Note that the reason why "m_resortAllItemsTimer->start();" is used in KFileItemModel::setData() is that this function can indeed be called many times in a row by KFileItemModelRolesUpdater if it resolves the sort role (like the number of items in a folder or a Nepomuk role) asynchronously. In that case, we really have to avoid that every call of setData triggers a new resorting.