File indexing completed on 2024-05-12 17:08:24
0001 /* 0002 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <QSortFilterProxyModel> 0008 0009 namespace CuttleFish 0010 { 0011 class SortFilterModel : public QSortFilterProxyModel 0012 { 0013 Q_OBJECT 0014 Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) 0015 Q_PROPERTY(QString category READ category WRITE setCategory NOTIFY categoryChanged) 0016 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) 0017 public: 0018 SortFilterModel(QObject *parent); 0019 0020 void setCategory(const QString &category); 0021 QString category() const; 0022 0023 void setFilter(const QString &filter); 0024 QString filter() const; 0025 0026 void setCurrentIndex(int index); 0027 int currentIndex(); 0028 0029 Q_SIGNALS: 0030 void filterChanged(); 0031 void categoryChanged(); 0032 void currentIndexChanged(); 0033 0034 private: 0035 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0036 0037 QString m_category; 0038 QString m_filter; 0039 QModelIndex m_currentSourceIndex; 0040 }; 0041 0042 }