confirmbeforedeletingrule.h 1.33 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
3
4
5
6
7
   SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once
Laurent Montel's avatar
Laurent Montel committed
8
#include "kmailconfirmbeforedeleting_export.h"
Laurent Montel's avatar
Laurent Montel committed
9
#include <AkonadiCore/Item>
Laurent Montel's avatar
Laurent Montel committed
10
#include <KConfigGroup>
Laurent Montel's avatar
Laurent Montel committed
11
#include <QDebug>
Laurent Montel's avatar
Laurent Montel committed
12
#include <QString>
Laurent Montel's avatar
Laurent Montel committed
13
class KMAILCONFIRMBEFOREDELETING_EXPORT ConfirmBeforeDeletingRule
Laurent Montel's avatar
Laurent Montel committed
14
{
Laurent Montel's avatar
Laurent Montel committed
15
    Q_GADGET
Laurent Montel's avatar
Laurent Montel committed
16
public:
Laurent Montel's avatar
Laurent Montel committed
17
18
19
20
21
22
23
24
25
    enum RuleType {
        Unknown = 0,
        Body,
        Subject,
        To,
        Cc,
    };
    Q_ENUM(RuleType)

Laurent Montel's avatar
Laurent Montel committed
26
27
    ConfirmBeforeDeletingRule();
    ~ConfirmBeforeDeletingRule();
Laurent Montel's avatar
Laurent Montel committed
28
29
30
31

    Q_REQUIRED_RESULT const QString &pattern() const;
    void setPattern(const QString &newPattern);

Laurent Montel's avatar
Laurent Montel committed
32
33
34
    Q_REQUIRED_RESULT RuleType ruleType() const;
    void setRuleType(RuleType newRuleType);

Laurent Montel's avatar
Laurent Montel committed
35
    Q_REQUIRED_RESULT bool deletingNeedToConfirm(const Akonadi::Item &item) const;
Laurent Montel's avatar
Laurent Montel committed
36

Laurent Montel's avatar
Laurent Montel committed
37
    void save(KConfigGroup &group) const;
Laurent Montel's avatar
Laurent Montel committed
38
39
    void load(const KConfigGroup &group);

40
41
    Q_REQUIRED_RESULT bool isValid() const;

Laurent Montel's avatar
Laurent Montel committed
42
private:
43
44
    Q_REQUIRED_RESULT QString ruleTypeToString() const;
    Q_REQUIRED_RESULT ConfirmBeforeDeletingRule::RuleType stringToRuleType(const QString &str) const;
Laurent Montel's avatar
Laurent Montel committed
45
    QString mPattern;
Laurent Montel's avatar
Laurent Montel committed
46
    RuleType mRuleType = RuleType::Unknown;
Laurent Montel's avatar
Laurent Montel committed
47
};
Laurent Montel's avatar
Laurent Montel committed
48
49
Q_DECLARE_TYPEINFO(ConfirmBeforeDeletingRule, Q_MOVABLE_TYPE);
KMAILCONFIRMBEFOREDELETING_EXPORT QDebug operator<<(QDebug d, const ConfirmBeforeDeletingRule &t);