Allow setting group icons to children groups/entries (#3273)

* Add combo menu button to apply an icon to children

- allow more options to apply icons (child groups, child entries)
- extend tests in TestGroup (applying icons for groups/entries only)
- prevent blue folder icon being set for entries (on entry creation only)

* Do not show the combo menu button for entries
This commit is contained in:
Matthias Drexler 2019-06-19 16:02:07 +02:00 committed by Jonathan White
parent 84eec03cb7
commit bb8377ae6a
11 changed files with 242 additions and 4 deletions

View file

@ -1080,8 +1080,10 @@ Entry* Group::addEntryWithPath(const QString& entryPath)
return entry;
}
void Group::applyGroupIconTo(Entry* entry)
void Group::applyGroupIconOnCreateTo(Entry* entry)
{
Q_ASSERT(entry);
if (!config()->get("UseGroupIconOnEntryCreation").toBool()) {
return;
}
@ -1090,6 +1092,13 @@ void Group::applyGroupIconTo(Entry* entry)
return;
}
applyGroupIconTo(entry);
}
void Group::applyGroupIconTo(Entry* entry)
{
Q_ASSERT(entry);
if (iconUuid().isNull()) {
entry->setIcon(iconNumber());
} else {
@ -1097,6 +1106,31 @@ void Group::applyGroupIconTo(Entry* entry)
}
}
void Group::applyGroupIconTo(Group* other)
{
Q_ASSERT(other);
if (iconUuid().isNull()) {
other->setIcon(iconNumber());
} else {
other->setIcon(iconUuid());
}
}
void Group::applyGroupIconToChildGroups()
{
for (Group* recursiveChild : groupsRecursive(false)) {
applyGroupIconTo(recursiveChild);
}
}
void Group::applyGroupIconToChildEntries()
{
for (Entry* recursiveEntry : entriesRecursive(false)) {
applyGroupIconTo(recursiveEntry);
}
}
void Group::sortChildrenRecursively(bool reverse)
{
std::sort(