File indexing completed on 2024-02-25 16:44:35

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "commonmessagefilterproxymodel.h"
0008 #include "commonmessagesmodel.h"
0009 
0010 CommonMessageFilterProxyModel::CommonMessageFilterProxyModel(CommonMessagesModel *model, QObject *parent)
0011     : QSortFilterProxyModel(parent)
0012     , mCommonMessagesModel(model)
0013 {
0014     setSourceModel(mCommonMessagesModel);
0015 
0016     setFilterCaseSensitivity(Qt::CaseInsensitive);
0017     setFilterRole(CommonMessagesModel::Timestamp);
0018     sort(0, Qt::DescendingOrder);
0019     connect(mCommonMessagesModel, &CommonMessagesModel::stringNotFoundChanged, this, &CommonMessageFilterProxyModel::stringNotFoundChanged);
0020     connect(mCommonMessagesModel, &CommonMessagesModel::loadingInProgressChanged, this, &CommonMessageFilterProxyModel::loadingInProgressChanged);
0021 }
0022 
0023 CommonMessageFilterProxyModel::~CommonMessageFilterProxyModel() = default;
0024 
0025 bool CommonMessageFilterProxyModel::loadCommonMessagesInProgress() const
0026 {
0027     return mCommonMessagesModel->loadCommonMessagesInProgress();
0028 }
0029 
0030 void CommonMessageFilterProxyModel::clearModel()
0031 {
0032     mCommonMessagesModel->clearModel();
0033 }
0034 
0035 void CommonMessageFilterProxyModel::setSearchText(const QString &str)
0036 {
0037     mCommonMessagesModel->setSearchText(str);
0038 }
0039 
0040 #include "moc_commonmessagefilterproxymodel.cpp"