KTextAddons

textautogeneratehistorysortfilterproxymodel.cpp
1/*
2 SPDX-FileCopyrightText: 2025 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#include "textautogeneratehistorysortfilterproxymodel.h"
7#include "textautogeneratechatmodel.h"
8#include "textautogeneratemessage.h"
9
10using namespace TextAutogenerateText;
11TextAutoGenerateHistorySortFilterProxyModel::TextAutoGenerateHistorySortFilterProxyModel(QObject *parent)
12 : QSortFilterProxyModel{parent}
13{
14 setFilterCaseSensitivity(Qt::CaseInsensitive);
15 setSortRole(TextAutoGenerateChatModel::DateTimeRole);
16 setFilterRole(TextAutoGenerateChatModel::MessageRole);
17 sort(0);
18}
19
20TextAutoGenerateHistorySortFilterProxyModel::~TextAutoGenerateHistorySortFilterProxyModel() = default;
21
22bool TextAutoGenerateHistorySortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
23{
24 const TextAutoGenerateMessage::Sender sender =
25 sourceModel()->index(source_row, 0).data(TextAutoGenerateChatModel::SenderRole).value<TextAutoGenerateMessage::Sender>();
26 if (sender != TextAutoGenerateMessage::Sender::User) {
27 return false;
28 }
29 return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
30}
31
32#include "moc_textautogeneratehistorysortfilterproxymodel.cpp"
QObject * sender() const const
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const const
CaseInsensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 12:06:03 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.