From 472d3e1a5cfd416e270f857bbcb59ce151621f02 Mon Sep 17 00:00:00 2001 From: alex-z Date: Tue, 12 Sep 2023 13:32:36 +0200 Subject: [PATCH] Bring activities requiring interaction on top. Signed-off-by: alex-z --- src/gui/tray/sortedactivitylistmodel.cpp | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/gui/tray/sortedactivitylistmodel.cpp b/src/gui/tray/sortedactivitylistmodel.cpp index d62ad4985bfae..a148509f9973c 100644 --- a/src/gui/tray/sortedactivitylistmodel.cpp +++ b/src/gui/tray/sortedactivitylistmodel.cpp @@ -74,6 +74,53 @@ bool SortedActivityListModel::lessThan(const QModelIndex &sourceLeft, const QMod return leftIsErrorFileItemStatus; } + auto leftActivityNeedsPostInteraction = false; + auto rightActivityNeedsPostInteraction = false; + + auto leftActivityNeedsReplyInteraction = false; + auto rightActivityNeedsReplyInteraction = false; + + auto leftActivityNeedsWebInteraction = false; + auto rightActivityNeedsWebInteraction = false; + + for (const auto &link : leftActivity._links) { + if (link._verb == QByteArrayLiteral("POST")) { + leftActivityNeedsPostInteraction = true; + } else if (link._verb == QByteArrayLiteral("REPLY")) { + leftActivityNeedsReplyInteraction = true; + } else if (link._verb == QByteArrayLiteral("WEB")) { + leftActivityNeedsWebInteraction = true; + } + } + + for (const auto &link : rightActivity._links) { + if (link._verb == QByteArrayLiteral("POST")) { + rightActivityNeedsPostInteraction = true; + } else if (link._verb == QByteArrayLiteral("REPLY")) { + rightActivityNeedsReplyInteraction = true; + } else if (link._verb == QByteArrayLiteral("WEB")) { + rightActivityNeedsWebInteraction = true; + } + } + + if (leftActivityNeedsPostInteraction && !rightActivityNeedsPostInteraction) { + return true; + } else if (!leftActivityNeedsPostInteraction && rightActivityNeedsPostInteraction) { + return false; + } + + if (leftActivityNeedsReplyInteraction && !rightActivityNeedsReplyInteraction) { + return true; + } else if (!leftActivityNeedsReplyInteraction && rightActivityNeedsReplyInteraction) { + return false; + } + + if (leftActivityNeedsWebInteraction && !rightActivityNeedsWebInteraction) { + return true; + } else if (!leftActivityNeedsWebInteraction && rightActivityNeedsWebInteraction) { + return false; + } + // Let's go back to more broadly comparing by type if (const auto rightType = rightActivity._type; leftType != rightType) { return leftType < rightType;