Commit f1d17f7b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add item directly

parent 0a43bfe9
......@@ -4,6 +4,7 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "confirmbeforedeletinginterface.h"
#include "confirmbeforedeletingmanager.h"
ConfirmBeforeDeletingInterface::ConfirmBeforeDeletingInterface(QObject *parent)
: MessageViewer::MessageViewerCheckBeforeDeletingInterface(parent)
......@@ -16,6 +17,5 @@ ConfirmBeforeDeletingInterface::~ConfirmBeforeDeletingInterface()
bool ConfirmBeforeDeletingInterface::exec(Akonadi::Item::List &list)
{
// TODO
return false;
return ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(list);
}
......@@ -31,11 +31,14 @@ void ConfirmBeforeDeletingManager::saveRules()
// TODO
}
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm() const
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item::List &list) const
{
for (const auto &r : qAsConst(mRules)) {
if (r.deletingNeedToConfirm()) {
return true;
for (const auto &item : list) {
for (const auto &r : qAsConst(mRules)) {
if (r.deletingNeedToConfirm(item)) {
// TODO show confirm dialog box
return true;
}
}
}
return false;
......
......@@ -8,6 +8,7 @@
#include "confirmbeforedeletingrule.h"
#include "kmailconfirmbeforedeleting_export.h"
#include <AkonadiCore/Item>
#include <QObject>
#include <QVector>
......@@ -23,7 +24,7 @@ public:
void loadRules();
void saveRules();
Q_REQUIRED_RESULT bool deletingNeedToConfirm() const;
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item::List &list) const;
private:
QVector<ConfirmBeforeDeletingRule> mRules;
......
......@@ -35,7 +35,7 @@ void ConfirmBeforeDeletingRule::setRuleType(RuleType newRuleType)
mRuleType = newRuleType;
}
bool ConfirmBeforeDeletingRule::deletingNeedToConfirm() const
bool ConfirmBeforeDeletingRule::deletingNeedToConfirm(const Akonadi::Item &item) const
{
switch (mRuleType) {
case Body:
......
......@@ -6,6 +6,7 @@
#pragma once
#include "kmailconfirmbeforedeleting_export.h"
#include <AkonadiCore/Item>
#include <QDebug>
#include <QString>
class KMAILCONFIRMBEFOREDELETING_EXPORT ConfirmBeforeDeletingRule
......@@ -31,7 +32,7 @@ public:
Q_REQUIRED_RESULT RuleType ruleType() const;
void setRuleType(RuleType newRuleType);
Q_REQUIRED_RESULT bool deletingNeedToConfirm() const;
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &item) const;
private:
QString mPattern;
......
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