File indexing completed on 2024-09-08 04:54:27
0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #include <QObject> 0005 0006 namespace Akonadi 0007 { 0008 class CollectionFilterProxyModel; 0009 class Session; 0010 } 0011 0012 class QItemSelectionModel; 0013 0014 class MailModel; 0015 0016 /// Class responsible for exposing the email folder selected by the user 0017 class MailManager : public QObject 0018 { 0019 Q_OBJECT 0020 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) 0021 Q_PROPERTY(Akonadi::CollectionFilterProxyModel *foldersModel READ foldersModel CONSTANT) 0022 Q_PROPERTY(MailModel *folderModel READ folderModel NOTIFY folderModelChanged) 0023 Q_PROPERTY(QString selectedFolderName READ selectedFolderName NOTIFY selectedFolderNameChanged) 0024 0025 public: 0026 MailManager(QObject *parent = nullptr); 0027 ~MailManager() override = default; 0028 0029 bool loading() const; 0030 Akonadi::CollectionFilterProxyModel *foldersModel() const; 0031 MailModel *folderModel() const; 0032 Akonadi::Session *session() const; 0033 QString selectedFolderName() const; 0034 0035 Q_INVOKABLE void loadMailCollection(const QModelIndex &index); 0036 0037 Q_SIGNALS: 0038 void loadingChanged(); 0039 void folderModelChanged(); 0040 void selectedFolderNameChanged(); 0041 0042 private: 0043 bool m_loading; 0044 Akonadi::Session *m_session; 0045 Akonadi::CollectionFilterProxyModel *m_foldersModel; 0046 0047 // folders 0048 QItemSelectionModel *m_collectionSelectionModel; 0049 MailModel *m_folderModel; 0050 QString m_selectedFolderName; 0051 };