-
Notifications
You must be signed in to change notification settings - Fork 0
/
customfilterproxymodel.h
41 lines (30 loc) · 1.13 KB
/
customfilterproxymodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef CUSTOMFILTERPROXYMODEL_H
#define CUSTOMFILTERPROXYMODEL_H
#include <QtCore/QSortFilterProxyModel>
using QIntList = QList<int>;
class CustomFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged FINAL)
Q_PROPERTY(int progress READ progress NOTIFY progressChanged FINAL)
public:
explicit CustomFilterProxyModel(QObject *parent = nullptr);
~CustomFilterProxyModel() override;
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const override;
QString filter() const;
int progress() const;
public slots:
void setFilter(const QString &filter);
private slots:
void setProgress(int progress) const;
signals:
void filterChanged(const QString &filter);
void progressChanged(int progress);
protected:
QVariant data(const QModelIndex &index, int role) const override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
private:
class Private;
QScopedPointer<Private> d;
};
#endif // CUSTOMFILTERPROXYMODEL_H