-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathproxymodel.cpp
More file actions
30 lines (24 loc) · 766 Bytes
/
proxymodel.cpp
File metadata and controls
30 lines (24 loc) · 766 Bytes
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
#include "proxymodel.h"
ProxyModel::ProxyModel(QObject* parent):QSortFilterProxyModel(parent),textFilter(QString())
{
}
void ProxyModel::setFilter(QString textFilter)
{
if (this->textFilter != textFilter)
{
this->textFilter = textFilter;
invalidateFilter();
}
}
bool ProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
QModelIndex ind= sourceModel()->index(source_row,1,source_parent);
if (sourceModel()->data(ind).toString().contains(textFilter))
return true;
return false;
}
QVariant ProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
{
return sourceModel()->headerData(section, orientation,
role);
}