]> git.sven.stormbind.net Git - sven/vym.git/blob - src/mysortfilterproxymodel.cpp
New upstream version 2.9.22
[sven/vym.git] / src / mysortfilterproxymodel.cpp
1 //#include <QtGui>
2
3 #include "mysortfilterproxymodel.h"
4
5 MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent)
6     : QSortFilterProxyModel(parent)
7 {
8 }
9 //! [0]
10
11 /*
12 //! [1]
13 void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date)
14 {
15     minDate = date;
16     invalidateFilter();
17 }
18 //! [1]
19
20 //! [2]
21 void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date)
22 {
23     maxDate = date;
24     invalidateFilter();
25 }
26 */
27
28 bool MySortFilterProxyModel::filterAcceptsRow(
29     int sourceRow, // FIXME-3 find a way to show _all_ rows which match,
30                    // independent of parent
31     const QModelIndex &sourceParent) const
32 {
33     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
34     QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
35
36     return (sourceModel()->data(index0).toString().contains(filterRegExp()) ||
37             sourceModel()->data(index1).toString().contains(filterRegExp()));
38 }