File indexing completed on 2024-05-12 15:33:46

0001 /*
0002     SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #ifndef KPLUGINPROXYMODEL_H
0007 #define KPLUGINPROXYMODEL_H
0008 
0009 #include "kcmutilscore_export.h"
0010 
0011 #include <KCategorizedSortFilterProxyModel>
0012 
0013 class Q_DECL_HIDDEN KPluginProxyModel : public KCategorizedSortFilterProxyModel
0014 {
0015     Q_OBJECT
0016     Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
0017     Q_PROPERTY(QAbstractListModel *model WRITE setModel)
0018 public:
0019     explicit KPluginProxyModel(QObject *parent = nullptr);
0020     ~KPluginProxyModel() override;
0021 
0022     QString query() const;
0023     void setQuery(const QString &query);
0024     void setModel(QAbstractListModel *model)
0025     {
0026         setSourceModel(model);
0027     }
0028 
0029 Q_SIGNALS:
0030     void queryChanged();
0031 
0032 protected:
0033     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0034     bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override;
0035 
0036 private:
0037     QString m_query;
0038 };
0039 
0040 #endif