File indexing completed on 2024-12-22 05:28:43
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kdeapplicationloggingcategoryproxymodel.h" 0008 #include "kdeapplicationloggingcategorymodel.h" 0009 0010 KDEApplicationLoggingCategoryProxyModel::KDEApplicationLoggingCategoryProxyModel(QObject *parent) 0011 : QSortFilterProxyModel{parent} 0012 { 0013 } 0014 0015 KDEApplicationLoggingCategoryProxyModel::~KDEApplicationLoggingCategoryProxyModel() = default; 0016 0017 bool KDEApplicationLoggingCategoryProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const 0018 { 0019 if (mFilterText.isEmpty()) { 0020 return true; 0021 } 0022 const QModelIndex sourceIndex = sourceModel()->index(source_row, KDEApplicationLoggingCategoryModel::CategoryRole, source_parent); 0023 const auto category = sourceIndex.data().value<LoggingCategory>(); 0024 if (category.description.contains(mFilterText) || category.categoryName.contains(mFilterText) || category.identifierName.contains(mFilterText)) { 0025 return true; 0026 } 0027 return false; 0028 } 0029 0030 QString KDEApplicationLoggingCategoryProxyModel::filterText() const 0031 { 0032 return mFilterText; 0033 } 0034 0035 void KDEApplicationLoggingCategoryProxyModel::setFilterText(const QString &newFilterText) 0036 { 0037 if (mFilterText != newFilterText) { 0038 mFilterText = newFilterText; 0039 invalidateFilter(); 0040 Q_EMIT filterTextChanged(); 0041 } 0042 } 0043 0044 #include "moc_kdeapplicationloggingcategoryproxymodel.cpp"