/* 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){ if(!filter.isEmpty()){ mFilter = QRegularExpression(filter); }else{ mFilter = QRegularExpression(); } invalidateFilter(); } bool MappingTreeProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ if(mFilter == QRegularExpression()){ return true; } QModelIndex nameIdx = sourceModel()->index(sourceRow, MappingTreeModel::Name, sourceParent); MappingTreeModel *model = qobject_cast(sourceModel()); return model->matchRecursive(nameIdx, mFilter); }