Place the 'Recycle Bin' at the bottom of the list when groups are sorted. (#7004)

Co-authored-by: Gaurav Pruthi <gaurav.pruthi@oracle.com>
This commit is contained in:
Gaurav Pruthi 2021-10-02 12:25:42 +05:30 committed by GitHub
parent 2514c1d5c5
commit 6c18b10979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);