File indexing completed on 2024-04-28 05:49:12

0001 /*
0002     SPDX-FileCopyrightText: 2022 Waqar Ahmed <waqar.17a@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #include "MatchProxyModel.h"
0007 #include "MatchModel.h"
0008 
0009 void MatchProxyModel::setFilterText(const QString &text)
0010 {
0011     beginResetModel();
0012     auto *matchModel = static_cast<MatchModel *>(sourceModel());
0013     matchModel->setFilterText(text);
0014     endResetModel();
0015 }
0016 
0017 bool MatchProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const
0018 {
0019     // root item always visible
0020     if (!parent.isValid()) {
0021         return true;
0022     }
0023 
0024     const auto index = sourceModel()->index(sourceRow, 0, parent);
0025     if (!index.isValid()) {
0026         return false;
0027     }
0028 
0029     // match text;
0030     auto *matchModel = static_cast<MatchModel *>(sourceModel());
0031     bool matches = matchModel->matchesFilter(index);
0032 
0033     return matches;
0034 }
0035 
0036 #include "moc_MatchProxyModel.cpp"