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/kfileitemmodel.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/kitemviews/kfileitemmodel.h') diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 42cb15403..eaf35fecd 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -184,6 +184,13 @@ signals: */ void loadingCompleted(); + /** + * Is emitted if the sort-role gets resolved asynchronously and provides + * the progress-information of the sorting in percent. It is assured + * that the last sortProgress-signal contains 100 as value. + */ + void sortProgress(int percent); + protected: virtual void onGroupedSortingChanged(bool current); virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous); @@ -316,6 +323,12 @@ private: */ KFileItemList childItems(const KFileItem& item) const; + /** + * Is invoked by KFileItemModelRolesUpdater and results in emitting the + * sortProgress signal with a percent-value of the progress. + */ + void emitSortProgress(int resolvedCount); + /** * Maps the QByteArray-roles to RoleTypes and provides translation- and * group-contexts. @@ -337,6 +350,12 @@ private: */ static const RoleInfoMap* rolesInfoMap(int& count); + /** + * Determines the MIME-types of all items that can be done within + * the given timeout. + */ + static void determineMimeTypes(const KFileItemList& items, int timeout); + private: QWeakPointer m_dirLister; @@ -344,6 +363,7 @@ private: bool m_sortFoldersFirst; RoleType m_sortRole; + int m_sortProgressPercent; // Value of sortProgress() signal QSet m_roles; Qt::CaseSensitivity m_caseSensitivity; @@ -385,6 +405,7 @@ private: QSet m_urlsToExpand; friend class KFileItemModelSortAlgorithm; // Accesses lessThan() method + friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method friend class KFileItemModelTest; // For unit testing }; -- cgit v1.3.1