mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
parent
e4b6289c0b
commit
4807ec3368
@ -378,6 +378,20 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems) const
|
||||
return entryList;
|
||||
}
|
||||
|
||||
QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
||||
{
|
||||
QList<const Group*> groupList;
|
||||
if (includeSelf) {
|
||||
groupList.append(this);
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
groupList.append(group->groupsRecursive(true));
|
||||
}
|
||||
|
||||
return groupList;
|
||||
}
|
||||
|
||||
void Group::addEntry(Entry* entry)
|
||||
{
|
||||
Q_ASSERT(entry);
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
QList<Entry*> entries();
|
||||
const QList<Entry*>& entries() const;
|
||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||
QList<const Group *> groupsRecursive(bool includeSelf) const;
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -450,25 +450,34 @@ void EditEntryWidget::removeCustomIcon()
|
||||
if (m_metadata) {
|
||||
QModelIndex index = m_iconsUi->customIconsView->currentIndex();
|
||||
if (index.isValid()) {
|
||||
QList<Entry*> allEntries = m_metadata->database()->rootGroup()->entriesRecursive(true);
|
||||
Uuid uuid = m_customIconModel->uuidFromIndex(index);
|
||||
|
||||
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||
int iconUsedCount = 0;
|
||||
QListIterator<Entry*> i(allEntries);
|
||||
while (i.hasNext()) {
|
||||
Entry* entry = i.next();
|
||||
if (uuid == entry->iconUuid() && entry != m_entry) {
|
||||
|
||||
QList<Entry*> allEntries = m_metadata->database()->rootGroup()->entriesRecursive(true);
|
||||
QListIterator<Entry*> iEntries(allEntries);
|
||||
while (iEntries.hasNext()) {
|
||||
Entry* entry = iEntries.next();
|
||||
if (iconUuid == entry->iconUuid() && entry != m_entry) {
|
||||
iconUsedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
QList<const Group*> allGroups = m_metadata->database()->rootGroup()->groupsRecursive(true);
|
||||
QListIterator<const Group*> iGroups(allGroups);
|
||||
while (iGroups.hasNext()) {
|
||||
const Group* group = iGroups.next();
|
||||
if (iconUuid == group->iconUuid()) {
|
||||
iconUsedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (iconUsedCount == 0) {
|
||||
m_metadata->removeCustomIcon(uuid);
|
||||
m_metadata->removeCustomIcon(iconUuid);
|
||||
m_customIconModel->setIcons(m_metadata->customIcons());
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(this, tr("Icon still used!"),
|
||||
tr("Can't delete icon. Still used by %1 entries.")
|
||||
QMessageBox::information(this, tr("Can't delete icon!"),
|
||||
tr("Can't delete icon. Still used by %1 items.")
|
||||
.arg(iconUsedCount));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user