#ifndef EMOJIMODEL_H
#define EMOJIMODEL_H

#include <QObject>
#include <QAbstractListModel>
#include <QStringList>
#include <QVariant>
#include <QMap>
#include <QQmlEngine>
#include <QMetaType>

class EmojiModel : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(QVariantMap categories READ getCategories NOTIFY categoriesChanged)
    Q_PROPERTY(int recentCount READ getRecentCount NOTIFY recentChanged)
public:
    enum Roles { Emoji = Qt::UserRole + 1, Variants };

    EmojiModel(QObject *parent = nullptr);

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QHash<int, QByteArray> roleNames() const override;
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    Q_INVOKABLE void insertRecent(int i, QString emoji);
    Q_INVOKABLE void setRecent(int i, QString emoji);

    QVariantMap getCategories() const;
    int getRecentCount() const;

    static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine)
    {
        Q_UNUSED(engine);
        Q_UNUSED(scriptEngine);

        return new EmojiModel();
    }

Q_SIGNALS:
    void categoriesChanged();
    void recentChanged();

private:
    QStringList m_recent;
    QStringList m_bases;
    QMap<QString, QStringList> m_variants;
    QVariantMap m_categories;
};

#endif // EMOJIMODEL_H
