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

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "discussionsfilterproxymodel.h"
0008 #include "discussionsmodel.h"
0009 DiscussionsFilterProxyModel::DiscussionsFilterProxyModel(DiscussionsModel *model, QObject *parent)
0010     : QSortFilterProxyModel(parent)
0011     , mDiscussionsModel(model)
0012 {
0013     setSourceModel(mDiscussionsModel);
0014 
0015     setFilterCaseSensitivity(Qt::CaseInsensitive);
0016     setFilterRole(DiscussionsModel::Description);
0017     setSortRole(DiscussionsModel::SortByTimeStamp);
0018     sort(0, Qt::DescendingOrder);
0019     connect(mDiscussionsModel, &DiscussionsModel::hasFullListChanged, this, &DiscussionsFilterProxyModel::hasFullListChanged);
0020     connect(mDiscussionsModel, &DiscussionsModel::loadingInProgressChanged, this, &DiscussionsFilterProxyModel::loadingInProgressChanged);
0021 }
0022 
0023 DiscussionsFilterProxyModel::~DiscussionsFilterProxyModel() = default;
0024 
0025 void DiscussionsFilterProxyModel::setFilterString(const QString &string)
0026 {
0027     setFilterFixedString(string);
0028 }
0029 
0030 void DiscussionsFilterProxyModel::clearFilter()
0031 {
0032     setFilterFixedString(QString());
0033 }
0034 
0035 int DiscussionsFilterProxyModel::total() const
0036 {
0037     return mDiscussionsModel->total();
0038 }
0039 
0040 bool DiscussionsFilterProxyModel::hasFullList() const
0041 {
0042     return mDiscussionsModel->hasFullList();
0043 }
0044 
0045 bool DiscussionsFilterProxyModel::loadMoreDiscussionsInProgress() const
0046 {
0047     return mDiscussionsModel->loadMoreDiscussionsInProgress();
0048 }
0049 
0050 void DiscussionsFilterProxyModel::clear()
0051 {
0052     mDiscussionsModel->clear();
0053 }
0054 
0055 #include "moc_discussionsfilterproxymodel.cpp"