summary refs log tree commit diff
path: root/src/emoji/EmojiModel.h
blob: 679563f1fbcca535408246fa343e9ead1421c9a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QAbstractListModel>
#include <QSet>
#include <QSortFilterProxyModel>
#include <QVector>

#include "Provider.h"

namespace emoji {

/*
 * Provides access to the emojis in Provider.h to QML
 */
class EmojiModel : public QAbstractListModel
{
        Q_OBJECT
public:
        enum Roles
        {
                Unicode = Qt::UserRole, // unicode of emoji
                Category,               // category of emoji
                ShortName,              // shortext of the emoji
                Emoji,                  // Contains everything from the Emoji
        };

        using QAbstractListModel::QAbstractListModel;

        Q_INVOKABLE int categoryToIndex(int category);

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