From b714604a6795f9ed398a886c23348a2d52fbb7d1 Mon Sep 17 00:00:00 2001 From: Thomas Surrel Date: Thu, 22 Nov 2018 22:24:37 +0100 Subject: Do not sort twice when changing role and order at the same time Summary: When using the list header to change the role and order, if one changes the order to descending and then changes role, dolphin also changes the order back to ascending. This results in sorting the list of files twice in a row. This patch removes the first (useless) sort. Reviewers: #dolphin, elvisangelaccio Reviewed By: #dolphin, elvisangelaccio Subscribers: elvisangelaccio, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D17111 --- src/kitemviews/kitemmodelbase.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/kitemviews/kitemmodelbase.h') diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h index 257872f9c..f1945de06 100644 --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -85,8 +85,9 @@ public: * Sets the sort-role to \a role. The method KItemModelBase::onSortRoleChanged() will be * called so that model-implementations can react on the sort-role change. Afterwards the * signal sortRoleChanged() will be emitted. + * The implementation should resort only if \a resortItems is true. */ - void setSortRole(const QByteArray& role); + void setSortRole(const QByteArray& role, bool resortItems = true); QByteArray sortRole() const; /** @@ -266,8 +267,9 @@ protected: * Usually the most efficient way is to emit a * itemsRemoved() signal for all items, reorder the items internally and to emit a * itemsInserted() signal afterwards. + * The implementation should resort only if \a resortItems is true. */ - virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous); + virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true); /** * Is invoked if the sort order has been changed by KItemModelBase::setSortOrder(). Allows -- cgit v1.3.1