File indexing completed on 2024-12-08 07:33:47

0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 #include "userfiltermodel.h"
0005 
0006 #include "userlistmodel.h"
0007 
0008 bool UserFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
0009 {
0010     Q_UNUSED(sourceParent);
0011     if (m_filterText.length() < 1) {
0012         return false;
0013     }
0014     return sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::DisplayNameRole).toString().contains(m_filterText, Qt::CaseInsensitive)
0015         || sourceModel()->data(sourceModel()->index(sourceRow, 0), UserListModel::UserIdRole).toString().contains(m_filterText, Qt::CaseInsensitive);
0016 }
0017 
0018 QString UserFilterModel::filterText() const
0019 {
0020     return m_filterText;
0021 }
0022 
0023 void UserFilterModel::setFilterText(const QString &filterText)
0024 {
0025     m_filterText = filterText;
0026     Q_EMIT filterTextChanged();
0027     invalidateFilter();
0028 }
0029 
0030 #include "moc_userfiltermodel.cpp"