File indexing completed on 2024-10-27 04:39:16
0001 0002 // SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #include "emoticonFilterModel.h" 0006 0007 EmoticonFilterModel::EmoticonFilterModel(QObject *parent) 0008 : QSortFilterProxyModel(parent) 0009 { 0010 } 0011 0012 bool EmoticonFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const 0013 { 0014 Q_UNUSED(sourceParent); 0015 auto stickerUsage = sourceModel()->data(sourceModel()->index(sourceRow, 0), m_stickerRole).toBool(); 0016 auto emojiUsage = sourceModel()->data(sourceModel()->index(sourceRow, 0), m_emojiRole).toBool(); 0017 return (stickerUsage && m_showStickers) || (emojiUsage && m_showEmojis); 0018 } 0019 0020 bool EmoticonFilterModel::showStickers() const 0021 { 0022 return m_showStickers; 0023 } 0024 0025 void EmoticonFilterModel::setShowStickers(bool showStickers) 0026 { 0027 beginResetModel(); 0028 m_showStickers = showStickers; 0029 endResetModel(); 0030 Q_EMIT showStickersChanged(); 0031 } 0032 0033 bool EmoticonFilterModel::showEmojis() const 0034 { 0035 return m_showEmojis; 0036 } 0037 0038 void EmoticonFilterModel::setShowEmojis(bool showEmojis) 0039 { 0040 beginResetModel(); 0041 m_showEmojis = showEmojis; 0042 endResetModel(); 0043 Q_EMIT showEmojisChanged(); 0044 } 0045 0046 #include "moc_emoticonFilterModel.cpp"