Skip to content

Commit

Permalink
Place the 'Recycle Bin' at the bottom of the list when groups are sor…
Browse files Browse the repository at this point in the history
…ted. (#7004)

Co-authored-by: Gaurav Pruthi <[email protected]>
  • Loading branch information
pruthig and Gaurav Pruthi authored Oct 2, 2021
1 parent 2514c1d commit 6c18b10
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/core/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6c18b10

Please sign in to comment.