File indexing completed on 2024-12-22 04:56:52
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include "newmailnotifier_export.h" 0009 #include <Akonadi/Item> 0010 #include <QDebug> 0011 #include <QObject> 0012 0013 class NEWMAILNOTIFIER_EXPORT NewMailNotificationHistoryManager : public QObject 0014 { 0015 Q_OBJECT 0016 public: 0017 struct NEWMAILNOTIFIER_EXPORT HistoryMailInfo { 0018 QString message; 0019 Akonadi::Item::Id identifier; 0020 }; 0021 0022 struct NEWMAILNOTIFIER_EXPORT HistoryFolderInfo { 0023 QString message; 0024 Akonadi::Collection::Id identifier; 0025 }; 0026 0027 explicit NewMailNotificationHistoryManager(QObject *parent = nullptr); 0028 ~NewMailNotificationHistoryManager() override; 0029 0030 static NewMailNotificationHistoryManager *self(); 0031 0032 [[nodiscard]] QStringList history() const; 0033 void setHistory(const QStringList &newHistory); 0034 0035 void clear(); 0036 0037 void addEmailInfoNotificationHistory(const NewMailNotificationHistoryManager::HistoryMailInfo &info); 0038 void addFoldersInfoNotificationHistory(const QList<NewMailNotificationHistoryManager::HistoryFolderInfo> &infos); 0039 0040 void setTestModeEnabled(bool test); 0041 [[nodiscard]] QString joinHistory() const; 0042 0043 Q_SIGNALS: 0044 void historyAdded(const QString &str); 0045 0046 private: 0047 [[nodiscard]] static NEWMAILNOTIFIER_NO_EXPORT QString generateOpenMailStr(Akonadi::Item::Id id); 0048 [[nodiscard]] static NEWMAILNOTIFIER_NO_EXPORT QString generateOpenFolderStr(Akonadi::Collection::Id id); 0049 NEWMAILNOTIFIER_NO_EXPORT void addHeader(); 0050 QStringList mHistory; 0051 // Only for autotest 0052 bool mTestEnabled = false; 0053 }; 0054 Q_DECLARE_TYPEINFO(NewMailNotificationHistoryManager::HistoryMailInfo, Q_RELOCATABLE_TYPE); 0055 Q_DECLARE_TYPEINFO(NewMailNotificationHistoryManager::HistoryFolderInfo, Q_RELOCATABLE_TYPE); 0056 QDebug operator<<(QDebug d, const NewMailNotificationHistoryManager::HistoryFolderInfo &id); 0057 QDebug operator<<(QDebug d, const NewMailNotificationHistoryManager::HistoryMailInfo &id);