File indexing completed on 2024-12-22 04:56:53

0001 /*
0002     SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <Akonadi/Collection>
0010 #include <QIdentityProxyModel>
0011 #include <QModelIndex>
0012 #include <QWidget>
0013 class QSortFilterProxyModel;
0014 namespace Akonadi
0015 {
0016 class EntityTreeModel;
0017 class ChangeRecorder;
0018 }
0019 class QTreeView;
0020 class KJob;
0021 
0022 class NewMailNotifierCollectionProxyModel : public QIdentityProxyModel
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit NewMailNotifierCollectionProxyModel(QObject *parent = nullptr);
0027 
0028     QVariant data(const QModelIndex &index, int role) const override;
0029 
0030     bool setData(const QModelIndex &index, const QVariant &_data, int role) override;
0031     Qt::ItemFlags flags(const QModelIndex &index) const override;
0032 
0033     QHash<Akonadi::Collection, bool> notificationCollection() const;
0034 
0035 private:
0036     QHash<Akonadi::Collection, bool> mNotificationCollection;
0037 };
0038 
0039 class NewMailNotifierSelectCollectionWidget : public QWidget
0040 {
0041     Q_OBJECT
0042 public:
0043     explicit NewMailNotifierSelectCollectionWidget(QWidget *parent = nullptr);
0044     ~NewMailNotifierSelectCollectionWidget() override;
0045 
0046     void updateCollectionsRecursive();
0047 
0048 private:
0049     void slotSelectAllCollections();
0050     void slotUnselectAllCollections();
0051     void slotModifyJobDone(KJob *job);
0052     void slotSetCollectionFilter(const QString &);
0053 
0054     void slotCollectionTreeFetched();
0055     void forceStatus(const QModelIndex &parent, bool status);
0056     QTreeView *const mFolderView;
0057     Akonadi::EntityTreeModel *mModel = nullptr;
0058     Akonadi::ChangeRecorder *const mChangeRecorder;
0059     QSortFilterProxyModel *const mCollectionFilter;
0060     NewMailNotifierCollectionProxyModel *const mNewMailNotifierProxyModel;
0061 };