File indexing completed on 2024-05-26 05:16:10
0001 /* 0002 SPDX-FileCopyrightText: 2014 Jonathan Marten <jjm@keelhaul.me.uk> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QSortFilterProxyModel> 0010 0011 #include <Akonadi/Tag> 0012 0013 #include <memory> 0014 0015 class CategoryFilterProxyModelPrivate; 0016 0017 /** 0018 * @short A proxy model to filter contacts by categories (tags). 0019 * 0020 * @since 4.14 0021 * @author Jonathan Marten 0022 **/ 0023 0024 class CategoryFilterProxyModel : public QSortFilterProxyModel 0025 { 0026 Q_OBJECT 0027 Q_DECLARE_PRIVATE(CategoryFilterProxyModel) 0028 0029 public: 0030 /** 0031 * Constructor. 0032 * 0033 * @param parent The parent object 0034 **/ 0035 explicit CategoryFilterProxyModel(QObject *parent = nullptr); 0036 0037 /** 0038 * Destructor. 0039 **/ 0040 ~CategoryFilterProxyModel() override; 0041 0042 public Q_SLOTS: 0043 /** 0044 * Set the categories to be accepted by the filter. 0045 * 0046 * @param idList A list of @c Akonadi::Tag::Id's of the categories 0047 * which are to be accepted by the filter. 0048 * @see CategorySelectModel::filterChanged 0049 **/ 0050 void setFilterCategories(const QList<Akonadi::Tag> &idList); 0051 0052 /** 0053 * Enable or disable the filter. 0054 * 0055 * @param enable If @c true, enable the filter to accept only those categories 0056 * set by @c setFilterCategories(). If false, disable the filter so that all 0057 * entries are accepted. 0058 * 0059 * The default state is that the filter is disabled. 0060 **/ 0061 void setFilterEnabled(bool enable); 0062 0063 protected: 0064 /** 0065 * @reimp 0066 **/ 0067 bool filterAcceptsRow(int row, const QModelIndex &parent) const override; 0068 0069 private: 0070 std::unique_ptr<CategoryFilterProxyModelPrivate> const d_ptr; 0071 };