File indexing completed on 2024-12-01 04:46:45

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "confirmbeforedeletingrule.h"
0010 #include "kmailconfirmbeforedeleting_export.h"
0011 #include <Akonadi/Item>
0012 #include <KSharedConfig>
0013 #include <QList>
0014 #include <QObject>
0015 
0016 class KMAILCONFIRMBEFOREDELETING_EXPORT ConfirmBeforeDeletingManager : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit ConfirmBeforeDeletingManager(QObject *parent = nullptr);
0021     ~ConfirmBeforeDeletingManager() override;
0022 
0023     static ConfirmBeforeDeletingManager *self();
0024 
0025     void loadRules();
0026     void saveRules();
0027 
0028     [[nodiscard]] bool deletingNeedToConfirm(const Akonadi::Item &list, QString &checkFound, ConfirmBeforeDeletingRule &rule) const;
0029 
0030     [[nodiscard]] const QList<ConfirmBeforeDeletingRule> &rules() const;
0031 
0032     void setRules(const QList<ConfirmBeforeDeletingRule> &newRules);
0033 
0034 private:
0035     [[nodiscard]] QString defaultConfigFileName() const;
0036     [[nodiscard]] QStringList ruleGroups(const KSharedConfig::Ptr &config) const;
0037     QList<ConfirmBeforeDeletingRule> mRules;
0038 };