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

Add support for Important/unread mails

parent af3cb097
Pipeline #109487 passed with stage
in 14 minutes and 38 seconds
......@@ -6,7 +6,7 @@
#include "confirmbeforedeletingrule.h"
#include "confirmbeforedeletingplugin_debug.h"
#include <Akonadi/KMime/MessageStatus>
#include <KLocalizedString>
ConfirmBeforeDeletingRule::ConfirmBeforeDeletingRule() = default;
......@@ -163,11 +163,21 @@ bool ConfirmBeforeDeletingRule::deletingNeedToConfirm(const Akonadi::Item &item,
break;
}
case Unread: {
// TODO
Akonadi::MessageStatus status;
status.setStatusFromFlags(item.flags());
if (!status.isRead()) {
needToConfirm = true;
generateConfirmMessageInfoFromStatus(msg, checkFoundInfo, i18n("Unread"));
}
break;
}
case Important: {
// TODO
Akonadi::MessageStatus status;
status.setStatusFromFlags(item.flags());
if (status.isImportant()) {
needToConfirm = true;
generateConfirmMessageInfoFromStatus(msg, checkFoundInfo, i18n("Important"));
}
break;
}
......@@ -189,6 +199,15 @@ void ConfirmBeforeDeletingRule::generateConfirmMessageInfo(const KMime::Message:
checkFoundInfo = i18n("The message with subject \'%2\' contains \'%1\'", pattern(), subjectStr);
}
void ConfirmBeforeDeletingRule::generateConfirmMessageInfoFromStatus(const KMime::Message::Ptr &msg, QString &checkFoundInfo, const QString &statusStr) const
{
QString subjectStr;
if (auto subject = msg->subject(false)) {
subjectStr = subject->asUnicodeString();
}
checkFoundInfo = i18n("The message with subject \'%1\' is ", subjectStr, statusStr);
}
QDebug operator<<(QDebug d, const ConfirmBeforeDeletingRule &t)
{
d << "Pattern " << t.pattern();
......
......@@ -49,6 +49,7 @@ public:
private:
void generateConfirmMessageInfo(const KMime::Message::Ptr &msg, QString &checkFoundInfo) const;
void generateConfirmMessageInfoFromStatus(const KMime::Message::Ptr &msg, QString &checkFoundInfo, const QString &statusStr) const;
QString mPattern;
RuleType mRuleType = RuleType::Unknown;
};
......
Supports Markdown
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