File indexing completed on 2024-05-12 05:12:47
0001 /* 0002 * SPDX-FileCopyrightText: 2018 David Faure <faure@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 <QSortFilterProxyModel> 0010 0011 #include <Akonadi/ChangeNotification> 0012 0013 #include <QSet> 0014 #include <QTimer> 0015 0016 namespace KPIM 0017 { 0018 class KCheckComboBox; 0019 } 0020 0021 /** 0022 * Filtering for NotificationModel 0023 */ 0024 class NotificationFilterModel : public QSortFilterProxyModel 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit NotificationFilterModel(QObject *parent = nullptr); 0029 0030 ~NotificationFilterModel() override; 0031 0032 void setTypeFilter(KPIM::KCheckComboBox *typeFilter); 0033 0034 void setSourceModel(QAbstractItemModel *model) override; 0035 0036 protected: 0037 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0038 0039 private: 0040 void slotRowsInserted(const QModelIndex &source_parent, int start, int end); 0041 0042 KPIM::KCheckComboBox *mTypeFilter = nullptr; 0043 QSet<Akonadi::ChangeNotification::Type> mCheckedTypes; 0044 0045 QSet<QString> mTypes; 0046 QTimer mInvalidateTimer; 0047 };