7#include "emojimodelmanager.h"
9#include "unicodeemoticonmanager.h"
10#include <KConfigGroup>
11#include <KSharedConfig>
12#include <TextEmoticonsCore/EmojiModel>
13using namespace TextEmoticonsCore;
15class EmojiModelManager::EmojiModelManagerPrivate
19 : mEmojiModel(new TextEmoticonsCore::
EmojiModel(q))
21 mEmojiModel->setUnicodeEmoticonList(TextEmoticonsCore::UnicodeEmoticonManager::self()->unicodeEmojiList());
27 if (group.hasKey(
"Recents")) {
28 mRecentIdentifier = group.readEntry(
"Recents",
QStringList());
30 group.deleteEntry(
"Recents");
35 mRecentIdentifier = group.readEntry(
"LastUsedEmojis",
QStringList());
39 void writeRecentUsed()
42 group.writeEntry(
"LastUsedEmojis", mRecentIdentifier);
46 QString mSettingsGroupName = QStringLiteral(
"EmoticonRecentUsed");
52EmojiModelManager::EmojiModelManager(
QObject *parent)
54 , d(new EmojiModelManagerPrivate(this))
59EmojiModelManager::~EmojiModelManager()
72 return d->mEmojiModel;
77 d->mSettingsGroupName = key;
81const QStringList &EmojiModelManager::recentIdentifier()
const
83 return d->mRecentIdentifier;
86void EmojiModelManager::setRecentIdentifier(
const QStringList &newRecentIdentifier)
88 d->mRecentIdentifier = newRecentIdentifier;
90 Q_EMIT usedIdentifierChanged(d->mRecentIdentifier);
93void EmojiModelManager::addIdentifier(
const QString &identifier)
95 if (
int i = d->mRecentIdentifier.indexOf(identifier)) {
98 d->mRecentIdentifier.removeAt(i);
101 d->mRecentIdentifier.prepend(identifier);
102 d->writeRecentUsed();
103 Q_EMIT usedIdentifierChanged(d->mRecentIdentifier);
108 return d->mEmojiModel->customEmojiIconManager();
113 d->mEmojiModel->setCustomEmojiIconManager(newCustomEmojiIconManager);
116QStringList EmojiModelManager::excludeEmoticons()
const
118 return d->mExcludeEmoticons;
121void EmojiModelManager::setExcludeEmoticons(
const QStringList &emoticons)
123 if (d->mExcludeEmoticons != emoticons) {
124 d->mExcludeEmoticons = emoticons;
125 d->mEmojiModel->setExcludeEmoticons(d->mExcludeEmoticons);
126 Q_EMIT excludeEmoticonsChanged();
130#include "moc_emojimodelmanager.cpp"
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
The CustomEmojiIconManager class.
The EmojiModelManager class.
void setRecentSettingsGroupName(const QString &key)
Set the settings group name used to store the recent identifiers.