File indexing completed on 2024-05-12 16:25:45

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "custombasemodel.h"
0010 #include "emoticons/customemojisinfo.h"
0011 #include "libruqolacore_export.h"
0012 class RocketChatAccount;
0013 
0014 class LIBRUQOLACORE_EXPORT AdminCustomEmojiModel : public CustomBaseModel
0015 {
0016     Q_OBJECT
0017 public:
0018     enum CustomEmojiRoles {
0019         Name,
0020         Identifier,
0021         Aliases,
0022         Icon,
0023         LastColumn = Icon,
0024     };
0025     Q_ENUM(CustomEmojiRoles)
0026 
0027     explicit AdminCustomEmojiModel(RocketChatAccount *account, QObject *parent = nullptr);
0028     ~AdminCustomEmojiModel() override;
0029 
0030     [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0031     [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
0032     [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0033     [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0034 
0035     [[nodiscard]] int total() const override;
0036     void parseElements(const QJsonObject &obj) override;
0037     void addMoreElements(const QJsonObject &obj) override;
0038     [[nodiscard]] QList<int> hideColumns() const override;
0039 
0040     const CustomEmojisInfo &customEmojis() const;
0041     void setCustomEmojis(const CustomEmojisInfo &newCustomEmojis);
0042 
0043     [[nodiscard]] QIcon createCustomIcon(const QString &name) const;
0044 
0045 protected:
0046     void removeElement(const QString &identifier) override;
0047 
0048 private:
0049     LIBRUQOLACORE_NO_EXPORT void checkFullList() override;
0050     LIBRUQOLACORE_NO_EXPORT void clear();
0051     CustomEmojisInfo mCustomEmojiList;
0052     RocketChatAccount *const mRocketChatAccount;
0053 };