7#include "unicodeemoticon.h"
8#include "emoticonunicodeutils.h"
10using namespace TextEmoticonsCore;
11UnicodeEmoticon::UnicodeEmoticon() =
default;
13bool UnicodeEmoticon::isValid()
const
15 return !mIdentifier.isEmpty() && !mUnicode.isEmpty();
18QString UnicodeEmoticon::identifier()
const
23void UnicodeEmoticon::setIdentifier(
const QString &name)
28QString UnicodeEmoticon::unicode()
const
33QString UnicodeEmoticon::unicodeDisplay()
const
35 if (!mUnicode.isEmpty()) {
36 if (mCachedHtml.isEmpty()) {
37 mCachedHtml = QStringLiteral(
"<span style=\"font: x-large %3\" title=\"%2\">%1</span>")
38 .arg(mUnicode, mIdentifier, TextEmoticonsCore::EmoticonUnicodeUtils::emojiFontName());
46QString UnicodeEmoticon::escapeUnicodeEmoji(
const QString &pString)
50 const QList<QStringView> parts = QStringView(pString).
split(QLatin1Char(
'-'));
51 for (
const QStringView &item : parts) {
53 const int part = item.toInt(&ok, 16);
59 retString += QChar(part);
66QString UnicodeEmoticon::key()
const
71void UnicodeEmoticon::setKey(
const QString &key)
78 return (mAliases == other.aliases()) && (mIdentifier == other.identifier()) && (mUnicode == other.unicode()) && (mCategory == other.category())
79 && (mKey == other.key()) && (mOrder == other.order());
82int UnicodeEmoticon::order()
const
87void UnicodeEmoticon::setOrder(
int order)
92void UnicodeEmoticon::setUnicode(
const QString &unicode)
94 mUnicode = escapeUnicodeEmoji(unicode);
97QString UnicodeEmoticon::category()
const
102void UnicodeEmoticon::setCategory(
const QString &category)
104 mCategory = category;
107QStringList UnicodeEmoticon::aliases()
const
112void UnicodeEmoticon::setAliases(
const QStringList &aliases)
117bool UnicodeEmoticon::hasEmoji(
const QString &identifier)
const
119 return (mIdentifier == identifier) || (mUnicode == identifier) || mAliases.contains(identifier);
124 d <<
"Identifier : " << t.identifier();
125 d <<
"Unicode: " << t.unicode();
126 d <<
"Category: " << t.category();
127 d <<
"Aliases: " << t.aliases();
128 d <<
"Order: " << t.order();
129 d <<
"Key:" << t.key();
133#include "moc_unicodeemoticon.cpp"
The UnicodeEmoticon class.
QString name(StandardAction id)
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
char16_t highSurrogate(char32_t ucs4)
char16_t lowSurrogate(char32_t ucs4)
bool requiresSurrogates(char32_t ucs4)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const