From d9dbd3398a258d04ec4517fd13e795b437c869d6 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 10 Apr 2012 16:30:50 +0200 Subject: Improvements for slow sorting roles If the sorting is done for data which is resolved asynchronously (e.g. rating), it is important to give a visual feedback about the state of the sorting. This is done now by a progress indication in the statusbar. Also optimizations for "Sort by type" have been done: Although resolving a type can be expensive in the most often case it is a very cheap operation. So it the sorting is done by type, try to resolve the type synchronously for at least 200 ms to prevent a asynchronous resorting. This is usually sufficient to have resolved types even for directories with several thousands of items. BUG: 292733 FIXED-IN: 4.9.0 --- src/kitemviews/kfileitemmodelrolesupdater.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/kitemviews/kfileitemmodelrolesupdater.h') diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index e5e105e04..ce8cf1c73 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -128,6 +128,8 @@ private slots: void slotItemsRemoved(const KItemRangeList& itemRanges); void slotItemsChanged(const KItemRangeList& itemRanges, const QSet& roles); + void slotSortRoleChanged(const QByteArray& current, + const QByteArray& previous); /** * Is invoked after a preview has been received successfully. @@ -180,6 +182,22 @@ private: void resetPendingRoles(); void sortAndResolveAllRoles(); void sortAndResolvePendingRoles(); + void applySortProgressToModel(); + + /** + * Updates m_sortProgress to be 0 if the sort-role + * needs to get resolved asynchronously and hence a + * progress is required. Otherwise m_sortProgress + * will be set to -1 which means that no progress + * will be provided. + */ + void updateSortProgress(); + + /** + * @return True, if at least one item from the model + * has an unknown MIME-type. + */ + bool hasUnknownMimeTypes() const; enum ResolveHint { ResolveFast, @@ -222,11 +240,14 @@ private: // during the roles-updater has been paused by setPaused(). bool m_clearPreviews; + int m_sortProgress; + KFileItemModel* m_model; QSize m_iconSize; int m_firstVisibleIndex; int m_lastVisibleIndex; QSet m_roles; + QSet m_resolvableRoles; QStringList m_enabledPlugins; QSet m_pendingVisibleItems; -- cgit v1.3.1