File indexing completed on 2024-04-21 15:02:49

0001 /*
0002     SPDX-FileCopyrightText: 2015 Aleix Pol i Gonzalez <aleixpol@blue-systems.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef PERSONSSORTFILTERPROXYMODEL_H
0008 #define PERSONSSORTFILTERPROXYMODEL_H
0009 
0010 #include <QScopedPointer>
0011 #include <QSortFilterProxyModel>
0012 #include <kpeople/kpeople_export.h>
0013 
0014 namespace KPeople
0015 {
0016 class PersonsSortFilterProxyModelPrivate;
0017 
0018 /**
0019  * Helps filtering and sorting PersonsModel
0020  *
0021  * Especially useful for creating interfaces around specific properties rather
0022  * than the complete set as a whole.
0023  *
0024  * @sa PersonsModel
0025  * @since 5.12
0026  */
0027 class KPEOPLE_EXPORT PersonsSortFilterProxyModel : public QSortFilterProxyModel
0028 {
0029     Q_OBJECT
0030     /** Specifies the properties that should be provided by the contact for the contact to be shown. */
0031     Q_PROPERTY(QStringList requiredProperties READ requiredProperties WRITE setRequiredProperties)
0032 public:
0033     explicit PersonsSortFilterProxyModel(QObject *parent = nullptr);
0034     ~PersonsSortFilterProxyModel() override;
0035 
0036     QStringList requiredProperties() const;
0037     void setRequiredProperties(const QStringList &props);
0038 
0039     bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
0040 
0041     Q_INVOKABLE void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
0042 
0043 private:
0044     Q_DISABLE_COPY(PersonsSortFilterProxyModel)
0045 
0046     QScopedPointer<PersonsSortFilterProxyModelPrivate> const d_ptr;
0047     Q_DECLARE_PRIVATE(PersonsSortFilterProxyModel)
0048 };
0049 
0050 }
0051 
0052 #endif // PERSONSSORTFILTERPROXYMODEL_H