KEmoticons 5.109.0
kemoticonsprovider.h
1/*
2 SPDX-FileCopyrightText: 2008 Carlo Segato <brandon.ml@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef KEMOTICONS_PROVIDER_H
8#define KEMOTICONS_PROVIDER_H
9
10#include <kemoticons_export.h>
11
12#include <QObject>
13#include <QStringList>
14
15class KEmoticonsProviderPrivate;
16struct Emoticon;
17
21class KEMOTICONS_EXPORT KEmoticonsProvider : public QObject
22{
23 Q_OBJECT
24public:
25 struct Emoticon {
26 Emoticon() {}
27 /* sort by longest to shortest matchText */
28 bool operator < (const Emoticon &e) const
29 {
30 return matchText.length() > e.matchText.length();
31 }
32 QString matchText;
33 QString matchTextEscaped;
34 QString picPath;
35 QString picHTMLCode;
36 };
37
43 Copy
44 };
45
49 explicit KEmoticonsProvider(QObject *parent = nullptr);
50
55
61 virtual bool loadTheme(const QString &path) = 0;
62
68 virtual bool removeEmoticon(const QString &emo) = 0;
69
78 virtual bool addEmoticon(const QString &emo, const QString &text, AddEmoticonOption option = DoNotCopy) = 0;
79
80#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
86 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::saveTheme()")
87 void save();
88#endif
89
94 virtual void saveTheme() = 0;
95
99 QString themeName() const;
100
105 void setThemeName(const QString &name);
106
110 QString themePath() const;
111
115 QString fileName() const;
116
120 QHash<QString, QStringList> emoticonsMap() const;
121
125 QHash<QChar, QList<Emoticon> > emoticonsIndex() const;
126
127#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
133 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::newTheme()")
134 void createNew();
135#endif
136
141 virtual void newTheme() = 0;
142
150 void setPreferredEmoticonSize(const QSize &size);
151
161
162protected:
168 void setThemePath(const QString &path);
169
176 bool copyEmoticon(const QString &emo);
177
182
183#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
189 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::addMapItem(QString, QStringList)")
190 void addEmoticonsMap(QString key, QStringList value);
191#endif
192
198 //FIXME kf6: use const'ref here
199 void addMapItem(QString key, QStringList value);
200
201#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
207 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::removeMapItem(QString)")
208 void removeEmoticonsMap(QString key);
209#endif
215 void removeMapItem(QString key);
216
217#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
225 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::addIndexItem(const QString &, const QStringList &)")
226 void addEmoticonIndex(const QString &path, const QStringList &emoList);
227#endif
235 void addIndexItem(const QString &path, const QStringList &emoList);
236
237#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
245 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Use KEmoticonsProvider::removeIndexItem(const QString &, const QStringList &)")
246 void removeEmoticonIndex(const QString &path, const QStringList &emoList);
247#endif
255 void removeIndexItem(const QString &path, const QStringList &emoList);
256
257private:
261 const QScopedPointer<KEmoticonsProviderPrivate> d;
262};
263
264#endif /* KEMOTICONS_PROVIDER_H */
265
This is the base abstract class for the emoticon provider plugins.
Definition kemoticonsprovider.h:22
virtual void newTheme()=0
Creates a new theme.
void setThemePath(const QString &path)
Sets the theme inside the directory path.
AddEmoticonOption
Options to pass to addEmoticon.
Definition kemoticonsprovider.h:41
@ DoNotCopy
< Don't copy the emoticon file into the theme directory
Definition kemoticonsprovider.h:42
QString themePath() const
Returns the emoticon theme path.
~KEmoticonsProvider() override
Destructor.
void removeIndexItem(const QString &path, const QStringList &emoList)
Removes an emoticon from the index.
QSize preferredEmoticonSize() const
Returns size in which parsed emoticons will be returned.
QString fileName() const
Returns the file name of the emoticon theme.
void addIndexItem(const QString &path, const QStringList &emoList)
Adds an emoticon to the index.
virtual void saveTheme()=0
Saves the emoticon theme.
void removeMapItem(QString key)
Removes an item from the emoticon map.
KEmoticonsProvider(QObject *parent=nullptr)
Default constructor.
void addMapItem(QString key, QStringList value)
Inserts a new item in the emoticon map.
void setPreferredEmoticonSize(const QSize &size)
If a preferred size is set, all parsed emoticons will be returned with the size.
QString themeName() const
Returns the theme name.
QHash< QChar, QList< Emoticon > > emoticonsIndex() const
Returns a QHash that contains emoticons indexed by the first char.
virtual bool addEmoticon(const QString &emo, const QString &text, AddEmoticonOption option=DoNotCopy)=0
Adds the emoticon emo with text text.
virtual bool removeEmoticon(const QString &emo)=0
Removes the emoticon emo.
bool copyEmoticon(const QString &emo)
Copies the emoticon image to the theme directory.
virtual bool loadTheme(const QString &path)=0
Loads the emoticon theme inside the directory path.
QHash< QString, QStringList > emoticonsMap() const
Returns a QHash that contains the emoticon path as keys and the text as values.
void setThemeName(const QString &name)
Sets the emoticon theme name.
void clearEmoticonsMap()
Clears the emoticons map.