From 6c18b10979e737ee6aef8c773d3707b23c650220 Mon Sep 17 00:00:00 2001 From: Gaurav Pruthi Date: Sat, 2 Oct 2021 12:25:42 +0530 Subject: [PATCH] Place the 'Recycle Bin' at the bottom of the list when groups are sorted. (#7004) Co-authored-by: Gaurav Pruthi --- src/core/Group.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 2f6ace76..c8220903 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -1155,13 +1155,18 @@ void Group::applyGroupIconToChildEntries() void Group::sortChildrenRecursively(bool reverse) { - std::sort( - m_children.begin(), m_children.end(), [reverse](const Group* childGroup1, const Group* childGroup2) -> bool { - QString name1 = childGroup1->name(); - QString name2 = childGroup2->name(); - return reverse ? name1.compare(name2, Qt::CaseInsensitive) > 0 - : name1.compare(name2, Qt::CaseInsensitive) < 0; - }); + Group* recycleBin = nullptr; + if (database()) { + recycleBin = database()->metadata()->recycleBin(); + } + std::sort(m_children.begin(), m_children.end(), [=](const Group* childGroup1, const Group* childGroup2) -> bool { + if (childGroup1 == recycleBin) { + return false; + } + QString name1 = childGroup1->name(); + QString name2 = childGroup2->name(); + return reverse ? name1.compare(name2, Qt::CaseInsensitive) > 0 : name1.compare(name2, Qt::CaseInsensitive) < 0; + }); for (auto child : m_children) { child->sortChildrenRecursively(reverse);