-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortfilterproxymodel.h
46 lines (32 loc) · 1.07 KB
/
sortfilterproxymodel.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
42
43
44
45
46
#ifndef SORTFILTERPROXYMODEL_H
#define SORTFILTERPROXYMODEL_H
#include <QDate>
#include <QSortFilterProxyModel>
#include <QAction>
class SortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
SortFilterProxyModel(QObject *parent = 0);
QDate filterMinimumDate() const { return minDate; }
void setFilterMinimumDate(const QDate &date);
QDate filterMaximumDate() const { return maxDate; }
void setFilterMaximumDate(const QDate &date);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
public slots:
inline void setCaseSensitivity(bool b)
{
setFilterCaseSensitivity(b?Qt::CaseSensitive:Qt::CaseInsensitive);
}
inline void setRole(QAction *a)
{
setFilterRole(a->data().toInt());
}
private:
bool dateInRange(const QDate &date) const;
QDate minDate;
QDate maxDate;
};
#endif // SORTFILTERPROXYMODEL_H