File indexing completed on 2025-01-05 04:53:59

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include <Akonadi/Tag>
0010 #include <QObject>
0011 #include <mailcommon/tag.h>
0012 namespace Akonadi
0013 {
0014 class Monitor;
0015 }
0016 class KJob;
0017 
0018 class TagMonitorManager : public QObject
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit TagMonitorManager(QObject *parent = nullptr);
0023     ~TagMonitorManager() override;
0024 
0025     static TagMonitorManager *self();
0026 
0027     [[nodiscard]] QList<MailCommon::Tag::Ptr> tags() const;
0028 
0029 Q_SIGNALS:
0030     void tagAdded();
0031     void tagChanged();
0032     void tagRemoved();
0033     void fetchTagDone();
0034 
0035 private:
0036     void createActions();
0037     void finishedTagListing(KJob *job);
0038     void onTagAdded(const Akonadi::Tag &akonadiTag);
0039     void onTagRemoved(const Akonadi::Tag &akonadiTag);
0040     void onTagChanged(const Akonadi::Tag &akonadiTag);
0041 
0042     // A sorted list of all tags
0043     QList<MailCommon::Tag::Ptr> mTags;
0044 
0045     Akonadi::Monitor *const mMonitor;
0046 };