Commit 711809a2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

improve api

parent 2e5f25b7
Pipeline #68037 passed with stage
in 52 minutes and 32 seconds
......@@ -5,6 +5,8 @@
*/
#include "confirmbeforedeletinginterface.h"
#include "confirmbeforedeletingmanager.h"
#include <KLocalizedString>
#include <KMessageBox>
ConfirmBeforeDeletingInterface::ConfirmBeforeDeletingInterface(QObject *parent)
: MessageViewer::MessageViewerCheckBeforeDeletingInterface(parent)
......@@ -17,5 +19,17 @@ ConfirmBeforeDeletingInterface::~ConfirmBeforeDeletingInterface()
Akonadi::Item::List ConfirmBeforeDeletingInterface::exec(const Akonadi::Item::List &list)
{
return ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(list);
Akonadi::Item::List lst;
for (const auto &item : list) {
if (ConfirmBeforeDeletingManager::self()->deletingNeedToConfirm(item)) {
// Use subject ?
if (KMessageBox::questionYesNo(parentWidget(), i18n("Do you want to delete this email?"), i18n("Confirm Delete Mail")) == KMessageBox::Yes) {
} else {
lst << item;
}
} else {
lst << item;
}
}
return lst;
}
......@@ -31,18 +31,12 @@ void ConfirmBeforeDeletingManager::saveRules()
// TODO
}
Akonadi::Item::List ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item::List &list) const
bool ConfirmBeforeDeletingManager::deletingNeedToConfirm(const Akonadi::Item &item) const
{
Akonadi::Item::List lst;
for (const auto &item : list) {
for (const auto &r : qAsConst(mRules)) {
if (r.deletingNeedToConfirm(item)) {
// TODO show confirm dialog box
} else {
lst << item;
}
for (const auto &r : qAsConst(mRules)) {
if (r.deletingNeedToConfirm(item)) {
return true;
}
}
return lst;
return false;
}
......@@ -24,7 +24,7 @@ public:
void loadRules();
void saveRules();
Q_REQUIRED_RESULT Akonadi::Item::List deletingNeedToConfirm(const Akonadi::Item::List &list) const;
Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &list) const;
private:
QVector<ConfirmBeforeDeletingRule> mRules;
......
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