File indexing completed on 2024-11-24 04:50:44
0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include "mailmodel.h" 0007 #include <Akonadi/CollectionFilterProxyModel> 0008 #include <MailCommon/EntityCollectionOrderProxyModel> 0009 #include <QObject> 0010 0011 namespace Akonadi 0012 { 0013 class CollectionFilterProxyModel; 0014 class Session; 0015 } 0016 0017 namespace MailCommon 0018 { 0019 class EntityCollectionOrderProxyModel; 0020 } 0021 0022 class QItemSelectionModel; 0023 0024 /// Class responsible for exposing the email folder selected by the user 0025 class MailManager : public QObject 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) 0029 Q_PROPERTY(MailCommon::EntityCollectionOrderProxyModel *foldersModel READ foldersModel CONSTANT) 0030 Q_PROPERTY(MailModel *folderModel READ folderModel NOTIFY folderModelChanged) 0031 Q_PROPERTY(QString selectedFolderName READ selectedFolderName NOTIFY selectedFolderNameChanged) 0032 0033 public: 0034 explicit MailManager(QObject *parent = nullptr); 0035 ~MailManager() override = default; 0036 0037 void loadConfig(); 0038 void saveConfig(); 0039 0040 bool loading() const; 0041 MailCommon::EntityCollectionOrderProxyModel *foldersModel() const; 0042 MailModel *folderModel() const; 0043 Akonadi::Session *session() const; 0044 QString selectedFolderName() const; 0045 0046 Q_INVOKABLE void loadMailCollection(const QModelIndex &index); 0047 Q_INVOKABLE void moveToTrash(Akonadi::Item item); 0048 Q_INVOKABLE void updateCollection(const QModelIndex &index); 0049 Q_INVOKABLE void addCollection(const QModelIndex &index, const QVariant &name); 0050 Q_INVOKABLE void deleteCollection(const QModelIndex &index); 0051 Q_INVOKABLE void editCollection(const QModelIndex &index); 0052 Q_INVOKABLE QString resourceIdentifier(const QModelIndex &index); 0053 Q_INVOKABLE void saveMail(const QUrl &fileUrl, const Akonadi::Item &item); 0054 0055 Q_SIGNALS: 0056 void loadingChanged(); 0057 void folderModelChanged(); 0058 void selectedFolderNameChanged(); 0059 0060 private: 0061 bool m_loading; 0062 Akonadi::Session *m_session; 0063 MailCommon::EntityCollectionOrderProxyModel *m_foldersModel; 0064 0065 // folders 0066 QItemSelectionModel *m_collectionSelectionModel; 0067 MailModel *m_folderModel; 0068 QString m_selectedFolderName; 0069 };