From a2bbbd1751db66171e3dfdaa32a3cda7e42fb209 Mon Sep 17 00:00:00 2001 From: Konrad Materka Date: Wed, 26 May 2021 01:02:30 +0200 Subject: [PATCH] [applets/systemtray] Fix inconsistent sorting Notification applet should alway come first, but the sorting algorith was incomplete. This leads to unexpected behaviour. BUG: 437519 FIXED-IN: 5.22 (cherry picked from commit d1e4dda51ee234f28ffbaf7e178afb629b9db237) --- applets/systemtray/sortedsystemtraymodel.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applets/systemtray/sortedsystemtraymodel.cpp b/applets/systemtray/sortedsystemtraymodel.cpp index ee543a126..84063952b 100644 --- a/applets/systemtray/sortedsystemtraymodel.cpp +++ b/applets/systemtray/sortedsystemtraymodel.cpp @@ -63,8 +63,13 @@ bool SortedSystemTrayModel::lessThanConfigurationPage(const QModelIndex &left, c bool SortedSystemTrayModel::lessThanSystemTray(const QModelIndex &left, const QModelIndex &right) const { - QVariant itemId = sourceModel()->data(left, static_cast(BaseModel::BaseRole::ItemId)); - if (itemId.isValid() && itemId.toString() == QLatin1String("org.kde.plasma.notifications")) { + QVariant itemIdLeft = sourceModel()->data(left, static_cast(BaseModel::BaseRole::ItemId)); + QVariant itemIdRight = sourceModel()->data(left, static_cast(BaseModel::BaseRole::ItemId)); + if (itemIdRight.toString() == QLatin1String("org.kde.plasma.notifications")) { + // return false when at least right is "org.kde.plasma.notifications" + return false; + } else if (itemIdLeft.toString() == QLatin1String("org.kde.plasma.notifications")) { + // return true when only left is "org.kde.plasma.notifications" return true; }