1 /* 2 SPDX-FileCopyrightText: 2018-2021 Laurent Montel <montel@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "emoticons/customemoji.h" 10 #include "emoticons/unicodeemoticon.h" 11 #include "libruqolacore_export.h" 12 #include <QAbstractListModel> 13 14 // Model showing all emojis 15 class LIBRUQOLACORE_EXPORT EmoticonModel : public QAbstractListModel 16 { 17 Q_OBJECT 18 public: 19 enum EmoticonsRoles { 20 UnicodeEmoji = Qt::UserRole + 1, 21 CompleterName, // keep value in sync with InputCompleterModel 22 Identifier, 23 Category 24 }; 25 Q_ENUM(EmoticonsRoles) 26 27 explicit EmoticonModel(QObject *parent = nullptr); 28 ~EmoticonModel() override; 29 30 Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override; 31 Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role) const override; 32 33 Q_REQUIRED_RESULT QVector<UnicodeEmoticon> unicodeEmoticons() const; 34 35 void setUnicodeEmoticons(const QVector<UnicodeEmoticon> &emoticons); 36 37 Q_REQUIRED_RESULT const QVector<CustomEmoji> &customEmojiList() const; 38 void setCustomEmojiList(const QVector<CustomEmoji> &newCustomEmojiList); 39 40 void deleteEmojiCustom(const QStringList &lst); 41 42 void addEmojiCustomList(const QVector<CustomEmoji> &newCustomEmojiList); 43 44 private: 45 Q_REQUIRED_RESULT QIcon createCustomIcon(const QString &name) const; 46 Q_DISABLE_COPY(EmoticonModel) 47 QVector<UnicodeEmoticon> mEmoticons; 48 QVector<CustomEmoji> mCustomEmojiList; 49 // first int is an index into mEmoticons 50 // second is -1 for the emoticon identifier or otherwise an index into the alias list 51 QVector<QPair<int, int>> mUnicodeRows; 52 QVector<QPair<int, int>> mCustomRows; 53 }; 54 55