mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-29 19:06:55 -05:00
Add group sorting feature
* Enabling sorting of groups and their children in ascending and descending direction
This commit is contained in:
parent
0c2d1bcc50
commit
09181fab13
15 changed files with 373 additions and 0 deletions
|
|
@ -521,6 +521,11 @@ QStringList Group::hierarchy() const
|
|||
return hierarchy;
|
||||
}
|
||||
|
||||
bool Group::hasChildren() const
|
||||
{
|
||||
return !children().isEmpty();
|
||||
}
|
||||
|
||||
Database* Group::database()
|
||||
{
|
||||
return m_db;
|
||||
|
|
@ -1074,6 +1079,23 @@ void Group::applyGroupIconTo(Entry* entry)
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
for (auto child : m_children) {
|
||||
child->sortChildrenRecursively(reverse);
|
||||
}
|
||||
|
||||
emit groupModified();
|
||||
}
|
||||
|
||||
bool Group::GroupData::operator==(const Group::GroupData& other) const
|
||||
{
|
||||
return equals(other, CompareItemDefault);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue