┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-10 16:30:50 +0200
committerPeter Penz <[email protected]>2012-04-10 16:36:26 +0200
commitd9dbd3398a258d04ec4517fd13e795b437c869d6 (patch)
tree6f608d12001818cd416271ac7c4f462e9ddefc7a /src/kitemviews/kfileitemmodel.h
parentb8c3d933e66598c78180a73cb394b211ca6b52d0 (diff)
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
Diffstat (limited to 'src/kitemviews/kfileitemmodel.h')
-rw-r--r--src/kitemviews/kfileitemmodel.h21
1 files changed, 21 insertions, 0 deletions
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);
@@ -317,6 +324,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<KDirLister> m_dirLister;
@@ -344,6 +363,7 @@ private:
bool m_sortFoldersFirst;
RoleType m_sortRole;
+ int m_sortProgressPercent; // Value of sortProgress() signal
QSet<QByteArray> m_roles;
Qt::CaseSensitivity m_caseSensitivity;
@@ -385,6 +405,7 @@ private:
QSet<KUrl> m_urlsToExpand;
friend class KFileItemModelSortAlgorithm; // Accesses lessThan() method
+ friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method
friend class KFileItemModelTest; // For unit testing
};