KUtils
kemoticonstheme.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KEMOTICONS_THEME_H
00023 #define KEMOTICONS_THEME_H
00024
00025 #include "kemoticonsprovider.h"
00026
00027 #include <QtCore/QSharedDataPointer>
00028
00029 class QString;
00030
00034 class KUTILS_EXPORT KEmoticonsTheme
00035 {
00036 public:
00037
00041 enum ParseModeEnum {
00042 DefaultParse = 0x0,
00043 StrictParse = 0x1,
00044 RelaxedParse = 0x2,
00045 SkipHTML = 0x4
00046 };
00047
00048 Q_DECLARE_FLAGS(ParseMode, ParseModeEnum)
00049
00050
00053 enum TokenType {
00054 Undefined,
00055 Image,
00056 Text
00057 };
00058
00065 struct Token {
00066 Token() : type(Undefined) {}
00070 Token(TokenType t, const QString &m) : type(t), text(m) {}
00074 Token(TokenType t, const QString &m, const QString &p, const QString &html)
00075 : type(t), text(m), picPath(p), picHTMLCode(html) {}
00076 TokenType type;
00077 QString text;
00078 QString picPath;
00079 QString picHTMLCode;
00080 };
00081
00086 KEmoticonsTheme();
00087
00091 KEmoticonsTheme(const KEmoticonsTheme &ket);
00092
00097 KEmoticonsTheme(KEmoticonsProvider *p);
00098
00102 ~KEmoticonsTheme();
00103
00119 QString parseEmoticons(const QString &text, ParseMode mode = DefaultParse, const QStringList &exclude = QStringList()) const;
00120
00133 QList<Token> tokenize(const QString &message, ParseMode mode = DefaultParse) const;
00134
00139 bool loadTheme(const QString &path);
00140
00150 bool removeEmoticon(const QString &emo);
00151
00163 bool addEmoticon(const QString &emo, const QString &text, KEmoticonsProvider::AddEmoticonOption option = KEmoticonsProvider::DoNotCopy);
00164
00168 void save();
00169
00173 QString themeName() const;
00174
00179 void setThemeName(const QString &name);
00180
00184 QString themePath() const;
00185
00189 QString fileName() const;
00190
00194 QHash<QString, QStringList> emoticonsMap() const;
00195
00199 void createNew();
00200
00204 bool isNull() const;
00205
00209 KEmoticonsTheme& operator=(const KEmoticonsTheme &ket);
00210 private:
00211 class KEmoticonsThemeData;
00215 QSharedDataPointer<KEmoticonsThemeData> d;
00216 };
00217
00218 Q_DECLARE_OPERATORS_FOR_FLAGS(KEmoticonsTheme::ParseMode)
00219
00220 #endif
00221
00222