blob: 077d72a8fed15670ba13226f88def152f2a81c7f (
plain)
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
|
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
*/
#include "mappingtreeproxy.h"
#include "mappingtreemodel.h"
MappingTreeProxy::MappingTreeProxy(QObject *parent) : QSortFilterProxyModel(parent) {}
void MappingTreeProxy::setFilter(const QString &filter){
mFilter = QRegExp(filter);
invalidateFilter();
}
bool MappingTreeProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{
if(mFilter.isEmpty()){
return true;
}
QModelIndex nameIdx = sourceModel()->index(sourceRow, MappingTreeModel::Name, sourceParent);
MappingTreeModel *model = qobject_cast<MappingTreeModel*>(sourceModel());
return model->matchRecursive(nameIdx, mFilter);
}
|