mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-23 15:00:47 -04:00
parent
e4b6289c0b
commit
4807ec3368
3 changed files with 34 additions and 10 deletions
|
@ -378,6 +378,20 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems) const
|
||||||
return entryList;
|
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)
|
void Group::addEntry(Entry* entry)
|
||||||
{
|
{
|
||||||
Q_ASSERT(entry);
|
Q_ASSERT(entry);
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
QList<Entry*> entries();
|
QList<Entry*> entries();
|
||||||
const QList<Entry*>& entries() const;
|
const QList<Entry*>& entries() const;
|
||||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||||
|
QList<const Group *> groupsRecursive(bool includeSelf) const;
|
||||||
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
|
@ -450,25 +450,34 @@ void EditEntryWidget::removeCustomIcon()
|
||||||
if (m_metadata) {
|
if (m_metadata) {
|
||||||
QModelIndex index = m_iconsUi->customIconsView->currentIndex();
|
QModelIndex index = m_iconsUi->customIconsView->currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
QList<Entry*> allEntries = m_metadata->database()->rootGroup()->entriesRecursive(true);
|
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||||
Uuid uuid = m_customIconModel->uuidFromIndex(index);
|
|
||||||
|
|
||||||
int iconUsedCount = 0;
|
int iconUsedCount = 0;
|
||||||
QListIterator<Entry*> i(allEntries);
|
|
||||||
while (i.hasNext()) {
|
QList<Entry*> allEntries = m_metadata->database()->rootGroup()->entriesRecursive(true);
|
||||||
Entry* entry = i.next();
|
QListIterator<Entry*> iEntries(allEntries);
|
||||||
if (uuid == entry->iconUuid() && entry != m_entry) {
|
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++;
|
iconUsedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconUsedCount == 0) {
|
if (iconUsedCount == 0) {
|
||||||
m_metadata->removeCustomIcon(uuid);
|
m_metadata->removeCustomIcon(iconUuid);
|
||||||
m_customIconModel->setIcons(m_metadata->customIcons());
|
m_customIconModel->setIcons(m_metadata->customIcons());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::information(this, tr("Icon still used!"),
|
QMessageBox::information(this, tr("Can't delete icon!"),
|
||||||
tr("Can't delete icon. Still used by %1 entries.")
|
tr("Can't delete icon. Still used by %1 items.")
|
||||||
.arg(iconUsedCount));
|
.arg(iconUsedCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue