6#include "emojiproxymodel.h"
8#include "emoticonunicodeutils.h"
10using namespace TextEmoticonsCore;
12class EmojiProxyModel::EmojiProxyModelPrivate
21 q->setSearchIdentifier(
QString());
29EmojiProxyModel::EmojiProxyModel(
QObject *parent)
34 setFilterRole(EmojiModel::Identifier);
38EmojiProxyModel::~EmojiProxyModel() =
default;
40bool EmojiProxyModel::filterAcceptsRow(
int source_row,
const QModelIndex &source_parent)
const
42 if (d->mCategory.isEmpty()) {
46 if (!d->mSearchIdentifier.isEmpty()) {
49 if (identifier.
contains(d->mSearchIdentifier)) {
54 if (d->mCategory == TextEmoticonsCore::EmoticonUnicodeUtils::recentIdentifier()) {
57 if (d->mRecentEmoticons.contains(identifier)) {
62 const auto category = sourceIndex.
data(EmojiModel::Category).
toString();
63 if (d->mCategory == category) {
70QString EmojiProxyModel::searchIdentifier()
const
72 return d->mSearchIdentifier;
75void EmojiProxyModel::setSearchIdentifier(
const QString &newSearchIdentifier)
77 if (d->mSearchIdentifier != newSearchIdentifier) {
78 d->mSearchIdentifier = newSearchIdentifier;
85 return d->mRecentEmoticons;
88void EmojiProxyModel::setRecentEmoticons(
const QStringList &newRecentEmoticons)
90 if (d->mRecentEmoticons != newRecentEmoticons) {
91 d->mRecentEmoticons = newRecentEmoticons;
92 if (TextEmoticonsCore::EmoticonUnicodeUtils::recentIdentifier() == d->mCategory) {
98QString EmojiProxyModel::category()
const
103void EmojiProxyModel::setCategory(
const QString &newCategorie)
105 if (d->mCategory != newCategorie) {
106 d->mCategory = newCategorie;
107 if (!d->mSearchIdentifier.isEmpty()) {
112 if ((TextEmoticonsCore::EmoticonUnicodeUtils::recentIdentifier() == d->mCategory)
113 || (TextEmoticonsCore::EmoticonUnicodeUtils::customIdentifier() == d->mCategory)) {
123 if (TextEmoticonsCore::EmoticonUnicodeUtils::recentIdentifier() == d->mCategory) {
126 const int positionIdentifierLeft = d->mRecentEmoticons.indexOf(leftIdentifier);
127 const int positionIdentifierRight = d->mRecentEmoticons.indexOf(rightIdentifier);
132 return positionIdentifierLeft < positionIdentifierRight;
134 const int leftOrder =
sourceModel()->data(left, EmojiModel::Order).toInt();
135 const int rightOrder =
sourceModel()->data(right, EmojiModel::Order).toInt();
137 return leftOrder < rightOrder;
141#include "moc_emojiproxymodel.cpp"
The EmojiProxyModel class.
QVariant data(int role) const const
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString toString() const const