20
#include "core/Config.h"
21
#include "core/Group.h"
22
#include "gui/MessageBox.h"
26
bool confirmDeleteEntries(QWidget* parent, const QList<Entry*>& entries, bool permanent)
28
if (!parent || entries.isEmpty()) {
34
if (entries.size() == 1) {
35
prompt = QObject::tr("Do you really want to delete the entry \"%1\" for good?")
36
.arg(entries.first()->title().toHtmlEscaped());
38
prompt = QObject::tr("Do you really want to delete %n entry(s) for good?", "", entries.size());
41
auto answer = MessageBox::question(parent,
42
QObject::tr("Delete entry(s)?", "", entries.size()),
44
MessageBox::Delete | MessageBox::Cancel,
47
return answer == MessageBox::Delete;
48
} else if (config()->get(Config::Security_NoConfirmMoveEntryToRecycleBin).toBool()) {
52
if (entries.size() == 1) {
53
prompt = QObject::tr("Do you really want to move entry \"%1\" to the recycle bin?")
54
.arg(entries.first()->title().toHtmlEscaped());
56
prompt = QObject::tr("Do you really want to move %n entry(s) to the recycle bin?", "", entries.size());
59
auto answer = MessageBox::question(parent,
60
QObject::tr("Move entry(s) to recycle bin?", "", entries.size()),
62
MessageBox::Move | MessageBox::Cancel,
65
return answer == MessageBox::Move;
69
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent)
71
if (!parent || entries.isEmpty()) {
75
QList<Entry*> selectedEntries;
77
for (auto entry : entries) {
79
auto references = entry->database()->rootGroup()->referencesRecursive(entry);
80
if (!references.isEmpty()) {
82
for (auto e : entries) {
83
references.removeAll(e);
86
auto result = MessageBox::question(
88
QObject::tr("Replace references to entry?"),
90
"Entry \"%1\" has %2 reference(s). "
91
"Do you want to overwrite references with values, skip this entry, or delete anyway?",
94
.arg(entry->resolvePlaceholder(entry->title()).toHtmlEscaped())
95
.arg(references.size()),
96
MessageBox::Overwrite | MessageBox::Skip | MessageBox::Delete,
97
MessageBox::Overwrite);
99
if (result == MessageBox::Overwrite) {
100
for (auto ref : references) {
101
ref->replaceReferencesWithValues(entry);
103
} else if (result == MessageBox::Skip) {
109
selectedEntries << entry;
112
for (auto entry : asConst(selectedEntries)) {
116
entry->database()->recycleEntry(entry);
119
return selectedEntries.size();