Commit 78a7b357 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to use same result

parent 8b456a34
Pipeline #74260 canceled with stage
......@@ -21,13 +21,28 @@ Akonadi::Item::List ConfirmBeforeDeletingInterface::exec(const Akonadi::Item::Li
{
Akonadi::Item::List lst;
QString checkFoundStr;
QVector<ConfirmBeforeDeletingRule> ruleDelete;
QVector<ConfirmBeforeDeletingRule> ruleNotDelete;
for (const auto &item : list) {
if (ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(item, checkFoundStr)) {
ConfirmBeforeDeletingRule r;
if (ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(item, checkFoundStr, r)) {
// TODO add checkbox for use same result for a specific check
if (ruleDelete.contains(r)) {
lst << item;
continue;
}
if (ruleNotDelete.contains(r)) {
continue;
}
auto result =
KMessageBox::questionYesNoCancel(parentWidget(), i18n("Do you want to delete this email?\n%1", checkFoundStr), i18n("Confirm Delete Mail"));
if (result == KMessageBox::Yes) {
lst << item;
ruleDelete.append(r);
} else if (result == KMessageBox::No) {
ruleNotDelete.append(r);
} else if (result == KMessageBox::Cancel) {
lst.clear();
break;
......
......@@ -83,10 +83,11 @@ void ConfirmBeforeDeletingManager::saveRules()
}
}
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item &item, QString &checkFound) const
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item &item, QString &checkFound, ConfirmBeforeDeletingRule &rule) const
{
for (const auto &r : std::as_const(mRules)) {
if (r.deletingNeedToConfirm(item, checkFound)) {
rule = r;
return true;
}
}
......
......@@ -25,7 +25,7 @@ public:
void loadRules();
void saveRules();
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &list, QString &checkFound) const;
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &list, QString &checkFound, ConfirmBeforeDeletingRule &rule) const;
Q_REQUIRED_RESULT const QVector<ConfirmBeforeDeletingRule> &rules() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment