KEmoticons 5.109.0
kemoticonstheme.h
1/*
2 SPDX-FileCopyrightText: 2002-2008 The Kopete developers <kopete-devel@kde.org>
3 SPDX-FileCopyrightText: 2008 Carlo Segato <brandon.ml@gmail.com>
4 SPDX-FileCopyrightText: 2002-2003 Stefan Gehn <metz@gehn.net>
5 SPDX-FileCopyrightText: 2005 Engin AYDOGAN <engin@bzzzt.biz>
6
7 SPDX-License-Identifier: LGPL-2.1-or-later
8*/
9
10#ifndef KEMOTICONS_THEME_H
11#define KEMOTICONS_THEME_H
12
13#include "kemoticonsprovider.h"
14
15#include <QSharedDataPointer>
16
17class QString;
18
22class KEMOTICONS_EXPORT KEmoticonsTheme
23{
24public:
25
30 DefaultParse = 0x0,
31 StrictParse = 0x1,
32 RelaxedParse = 0x2,
33 SkipHTML = 0x4
34 };
35
36 Q_DECLARE_FLAGS(ParseMode, ParseModeEnum)
37
38
41 enum TokenType {
44 Text
45 };
46
53 struct Token {
54 Token() : type(Undefined) {}
58 Token(TokenType t, const QString &m) : type(t), text(m) {}
62 Token(TokenType t, const QString &m, const QString &p, const QString &html)
63 : type(t), text(m), picPath(p), picHTMLCode(html) {}
65 QString text;
66 QString picPath;
67 QString picHTMLCode;
68 };
69
75
80
86
91
107 QString parseEmoticons(const QString &text, ParseMode mode = DefaultParse, const QStringList &exclude = QStringList()) const;
108
121 QList<Token> tokenize(const QString &message, ParseMode mode = DefaultParse) const;
122
123#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
131 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Subclass KEmoticonsProvider")
132 bool loadTheme(const QString &path);
133#endif
134
135#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
147 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Subclass KEmoticonsProvider")
148 bool removeEmoticon(const QString &emo);
149#endif
150
151#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
166 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Subclass KEmoticonsProvider")
167 bool addEmoticon(const QString &emo,
168 const QString &text,
169 KEmoticonsProvider::AddEmoticonOption option = KEmoticonsProvider::DoNotCopy);
170#endif
171
172#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
178 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Subclass KEmoticonsProvider")
179 void save();
180#endif
181
185 QString themeName() const;
186
191 void setThemeName(const QString &name);
192
196 QString themePath() const;
197
201 QString fileName() const;
202
206 QHash<QString, QStringList> emoticonsMap() const;
207
208#if KEMOTICONS_ENABLE_DEPRECATED_SINCE(5, 0)
214 KEMOTICONS_DEPRECATED_VERSION(5, 0, "Subclass KEmoticonsProvider")
215 void createNew();
216#endif
217
222 bool isNull() const;
223
227 KEmoticonsTheme &operator=(const KEmoticonsTheme &ket);
228private:
229 class KEmoticonsThemeData;
233 QSharedDataPointer<KEmoticonsThemeData> d;
234};
235
236Q_DECLARE_OPERATORS_FOR_FLAGS(KEmoticonsTheme::ParseMode)
237
238#endif /* KEMOTICONS_THEME_H */
239
This is the base abstract class for the emoticon provider plugins.
Definition kemoticonsprovider.h:22
This class contains the emoticons theme.
Definition kemoticonstheme.h:23
void setThemeName(const QString &name)
Sets the emoticon theme name.
QString fileName() const
Returns the file name of the emoticon theme.
QHash< QString, QStringList > emoticonsMap() const
Returns a QHash that contains the emoticon path as keys and the text as values.
KEmoticonsTheme(KEmoticonsProvider *p)
Another constructor where you set the KEmoticonsProvider p You should probably never use this,...
ParseModeEnum
The possible parse modes.
Definition kemoticonstheme.h:29
QString themeName() const
Returns the theme name.
KEmoticonsTheme(const KEmoticonsTheme &ket)
Copy constructor.
QString themePath() const
Returns the emoticon theme path.
QList< Token > tokenize(const QString &message, ParseMode mode=DefaultParse) const
Tokenizes the message message with ParseMode mode.
TokenType
TokenType, a token might be an image ( emoticon ) or text.
Definition kemoticonstheme.h:41
@ Image
Token contains a path to an image.
Definition kemoticonstheme.h:43
@ Undefined
Undefined, for completeness only.
Definition kemoticonstheme.h:42
QString parseEmoticons(const QString &text, ParseMode mode=DefaultParse, const QStringList &exclude=QStringList()) const
Parses emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude.
~KEmoticonsTheme()
Destructor.
bool isNull() const
Checks if the emoticon theme has a valid provider.
KEmoticonsTheme()
Default constructor, it creates a null emoticon theme You should probably never use this,...
A token consists of a QString text which is either a regular text or a path to image depending on the...
Definition kemoticonstheme.h:53
QString text
text
Definition kemoticonstheme.h:65
Token(TokenType t, const QString &m, const QString &p, const QString &html)
Creates a Token of type t, text m, image path p and html code html.
Definition kemoticonstheme.h:62
QString picHTMLCode
<img> html code
Definition kemoticonstheme.h:67
QString picPath
path to the image
Definition kemoticonstheme.h:66
Token(TokenType t, const QString &m)
Creates a Token of type t, and text m.
Definition kemoticonstheme.h:58
TokenType type
type
Definition kemoticonstheme.h:64