Add non-const version of Group::groupsRecursive().

This commit is contained in:
Felix Geyer 2015-01-11 16:20:24 +01:00
parent 835c411d12
commit 33650c4a04
4 changed files with 20 additions and 2 deletions

View File

@ -434,6 +434,20 @@ QList<const Group*> Group::groupsRecursive(bool includeSelf) const
groupList.append(this);
}
Q_FOREACH (const Group* group, m_children) {
groupList.append(group->groupsRecursive(true));
}
return groupList;
}
QList<Group*> Group::groupsRecursive(bool includeSelf)
{
QList<Group*> groupList;
if (includeSelf) {
groupList.append(this);
}
Q_FOREACH (Group* group, m_children) {
groupList.append(group->groupsRecursive(true));
}

View File

@ -101,6 +101,7 @@ public:
const QList<Entry*>& entries() const;
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
QList<const Group*> groupsRecursive(bool includeSelf) const;
QList<Group*> groupsRecursive(bool includeSelf);
QSet<Uuid> customIconsRecursive() const;
/**
* Creates a duplicate of this group including all child entries and groups.

View File

@ -168,7 +168,7 @@ void EditWidgetIcons::removeCustomIcon()
}
}
QList<const Group*> allGroups = m_database->rootGroup()->groupsRecursive(true);
QList<Group*> allGroups = m_database->rootGroup()->groupsRecursive(true);
Q_FOREACH (const Group* group, allGroups) {
if (iconUuid == group->iconUuid() && m_currentUuid != group->uuid()) {
iconUsedCount++;

View File

@ -85,7 +85,10 @@ void EntryModel::setEntryList(const QList<Entry*>& entries)
Q_FOREACH (Database* db, databases) {
Q_ASSERT(db);
m_allGroups.append(db->rootGroup()->groupsRecursive(true));
Q_FOREACH (const Group* group, db->rootGroup()->groupsRecursive(true)) {
m_allGroups.append(group);
}
if (db->metadata()->recycleBin()) {
m_allGroups.removeOne(db->metadata()->recycleBin());
}