mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39:53 -05:00
Don't fail upon deletion of a custom icon if history items contain the icon, but set a default icon.
This commit is contained in:
parent
1415829eaf
commit
62073fa74d
@ -68,18 +68,12 @@ IconStruct EditWidgetIcons::save()
|
|||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
iconStruct.number = index.row();
|
iconStruct.number = index.row();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
iconStruct.number = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QModelIndex index = m_ui->customIconsView->currentIndex();
|
QModelIndex index = m_ui->customIconsView->currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
iconStruct.uuid = m_customIconModel->uuidFromIndex(m_ui->customIconsView->currentIndex());
|
iconStruct.uuid = m_customIconModel->uuidFromIndex(m_ui->customIconsView->currentIndex());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
iconStruct.number = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return iconStruct;
|
return iconStruct;
|
||||||
@ -152,10 +146,18 @@ void EditWidgetIcons::removeCustomIcon()
|
|||||||
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
Uuid iconUuid = m_customIconModel->uuidFromIndex(index);
|
||||||
int iconUsedCount = 0;
|
int iconUsedCount = 0;
|
||||||
|
|
||||||
QList<Entry*> allEntries = m_database->rootGroup()->entriesRecursive(false);
|
QList<Entry*> allEntries = m_database->rootGroup()->entriesRecursive(true);
|
||||||
Q_FOREACH (const Entry* entry, allEntries) {
|
QList<Entry*> historyEntriesWithSameIcon;
|
||||||
if (iconUuid == entry->iconUuid() && m_currentUuid != entry->uuid()) {
|
|
||||||
iconUsedCount++;
|
Q_FOREACH (Entry* entry, allEntries) {
|
||||||
|
bool isHistoryEntry = !entry->group();
|
||||||
|
if (iconUuid == entry->iconUuid()) {
|
||||||
|
if (isHistoryEntry) {
|
||||||
|
historyEntriesWithSameIcon << entry;
|
||||||
|
}
|
||||||
|
else if (m_currentUuid != entry->uuid()) {
|
||||||
|
iconUsedCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,9 +169,13 @@ void EditWidgetIcons::removeCustomIcon()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iconUsedCount == 0) {
|
if (iconUsedCount == 0) {
|
||||||
|
Q_FOREACH (Entry* entry, historyEntriesWithSameIcon) {
|
||||||
|
entry->setUpdateTimeinfo(false);
|
||||||
|
entry->setIcon(0);
|
||||||
|
entry->setUpdateTimeinfo(true);
|
||||||
|
}
|
||||||
|
|
||||||
m_database->metadata()->removeCustomIcon(iconUuid);
|
m_database->metadata()->removeCustomIcon(iconUuid);
|
||||||
// TODO update icons of history items
|
|
||||||
// with updateTimeinfo = false
|
|
||||||
m_customIconModel->setIcons(m_database->metadata()->customIcons(),
|
m_customIconModel->setIcons(m_database->metadata()->customIcons(),
|
||||||
m_database->metadata()->customIconsOrder());
|
m_database->metadata()->customIconsOrder());
|
||||||
if (m_customIconModel->rowCount() > 0) {
|
if (m_customIconModel->rowCount() > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user