Debian Codegraph @

src/emoji/Emoji.h

raw symbols SCIP
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 #pragma once
6
7 #include <QObject>
8
9 namespace emoji {
10 Q_NAMESPACE
11
12 struct Emoji
13 {
14 Q_GADGET
15 public:
16 enum class Category
17 {
18 People,
19 Nature,
20 Food,
21 Activity,
22 Travel,
23 Objects,
24 Symbols,
25 Flags,
26 Search
27 };
28 Q_ENUM(Category)
29
30 Q_PROPERTY(QString unicode READ unicode CONSTANT)
31 Q_PROPERTY(QString shortName READ shortName CONSTANT)
32 Q_PROPERTY(QString unicodeName READ unicodeName CONSTANT)
33 Q_PROPERTY(emoji::Emoji::Category category MEMBER category)
34
35 public:
36 constexpr Emoji(std::u16string_view unicode,
37 std::u16string_view shortName,
38 std::u16string_view unicodeName,
39 Category cat)
40 : unicode_(unicode)
41 , shortName_(shortName)
42 , unicodeName_(unicodeName)
43 , category(cat)
44 {
45 }
46
47 constexpr Emoji()
48 : unicode_(u"", 0)
49 , shortName_(u"", 0)
50 , unicodeName_(u"", 0)
51 , category(Category::Search)
52 {
53 }
54
55 constexpr Emoji(const Emoji &) = default;
56 constexpr Emoji(Emoji &&) = default;
57
58 constexpr Emoji &operator=(const Emoji &) = default;
59 constexpr Emoji &operator=(Emoji &&) = default;
60
61 QString unicode() const
62 {
63 return QString::fromRawData(reinterpret_cast<const QChar *>(unicode_.data()),
64 unicode_.size());
65 }
66 QString shortName() const
67 {
68 return QString::fromRawData(reinterpret_cast<const QChar *>(shortName_.data()),
69 shortName_.size());
70 }
71 QString unicodeName() const
72 {
73 return QString::fromRawData(reinterpret_cast<const QChar *>(unicodeName_.data()),
74 unicodeName_.size());
75 }
76
77 private:
78 std::u16string_view unicode_;
79 std::u16string_view shortName_;
80 std::u16string_view unicodeName_;
81
82 public:
83 Category category;
84 };
85
86 QString
87 categoryToName(emoji::Emoji::Category cat);
88 } // namespace emoji