From 8210d5e472a2bff9f1a1f16b0740df25822b5362 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Sat, 14 Dec 2013 11:51:07 +0100 Subject: Update the roles for filtered items if necessary Since Dolphin 4.11, we store not only KFileItems, but also the corresponding ItemData struct for filtered items. This is required for keeping track of the parent-child relationships, and has the nice side effect that the ItemData need not be re-determined when the items are shown again. However, this can become a problem if the visible roles or the sort role change while some items are filtered. This is fixed by is fixed by clearing the QHash "values" for the filtered items if the visible roles change. The hash will be re-populated with all requested data as soon as the items are shown again and the data(int) method of the model is called. Moreover, before the items are inserted into the model after filtering, we have to make sure that the sort role "Permissions"/"User"/etc. is present in the hash "values". This is achieved by factoring out the code that currently does this job for new items in createItemDataList() into a new function, and calling this in insertItems(), because the same treatment is required for the previously filtered files. BUG: 328791 FIXED-IN: 4.12.1 REVIEW: 114266 --- src/kitemviews/kfileitemmodel.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/kitemviews/kfileitemmodel.h') diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index c57329fc8..022429023 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -320,6 +320,13 @@ private: */ QList createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const; + /** + * Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled + * lazily to save time and memory, but for some sort roles, it is expected that the + * sort role data is stored in 'values'. + */ + void prepareItemsForSorting(QList& itemDataList); + static int expandedParentsCount(const ItemData* data); void removeExpandedItems(); -- cgit v1.3