summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Hein <hein@kde.org>2017-02-16 13:09:19 (GMT)
committerEike Hein <hein@kde.org>2017-02-16 13:09:19 (GMT)
commit62b803b45dbe14dc24f7593c1c2907d1e4db3d74 (patch)
tree1af412f8b8cd2bc98e1b3e474e3be504f4680519
parent05826bd5ba25f6ed7be94ff8d760d6c8372f148c (diff)
Add comment laying out goals.
-rw-r--r--libtaskmanager/tasksmodel.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libtaskmanager/tasksmodel.cpp b/libtaskmanager/tasksmodel.cpp
index 1937c3f..b458c50 100644
--- a/libtaskmanager/tasksmodel.cpp
+++ b/libtaskmanager/tasksmodel.cpp
@@ -806,6 +806,22 @@ bool TasksModel::Private::lessThan(const QModelIndex &left, const QModelIndex &r
if (sortMode == SortDisabled) {
return (left.row() < right.row());
} else {
+ // The overall goal of alphabetic sorting is to sort tasks belonging to the
+ // same app together, while sorting the resulting sets alphabetically among
+ // themselves by the app name. The following code tries to achieve this by
+ // going for AppName first, and falling back to DisplayRole - which for
+ // window-type tasks generally contains the window title - if AppName is
+ // not available. When comparing tasks with identical resulting sort strings,
+ // we sort them by the source model order (i.e. insertion/creation). Older
+ // versions of this code compared tasks by a concatenation of AppName and
+ // DisplayRole at all times, but always sorting by the window title does more
+ // than our goal description - and can cause tasks within an app's set to move
+ // around when window titles change, which is a nuisance for users (especially
+ // in case of tabbed apps that have the window title reflect the active tab,
+ // e.g. web browsers). To recap, the common case is "sort by AppName, then
+ // insertion order", only swapping out AppName for DisplayRole (i.e. window
+ // title) when necessary.
+
QString leftSortString = left.data(AbstractTasksModel::AppName).toString();
if (leftSortString.isEmpty()) {