KUtils
kemoticonsprovider.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 #ifndef KEMOTICONS_PROVIDER_H
00020 #define KEMOTICONS_PROVIDER_H
00021
00022 #include "kutils_export.h"
00023 #include <QtCore/QObject>
00024 #include <QtCore/QVariant>
00025 #include <QtCore/QStringList>
00026 #include <QtCore/QPair>
00027
00028 class QString;
00029 class KEmoticonsProviderPrivate;
00030 struct Emoticon;
00031
00035 class KUTILS_EXPORT KEmoticonsProvider : public QObject
00036 {
00037 Q_OBJECT
00038 public:
00039 struct Emoticon
00040 {
00041 Emoticon(){}
00042
00043 bool operator < (const Emoticon &e) const { return matchText.length() > e.matchText.length(); }
00044 QString matchText;
00045 QString matchTextEscaped;
00046 QString picPath;
00047 QString picHTMLCode;
00048 };
00049
00053 enum AddEmoticonOption {
00054 DoNotCopy,
00055 Copy
00056 };
00057
00061 explicit KEmoticonsProvider(QObject *parent = 0);
00062
00066 virtual ~KEmoticonsProvider();
00067
00072 virtual bool loadTheme(const QString &path);
00073
00079 virtual bool removeEmoticon(const QString &emo);
00080
00088 virtual bool addEmoticon(const QString &emo, const QString &text, AddEmoticonOption option = DoNotCopy);
00089
00093 virtual void save();
00094
00098 QString themeName() const;
00099
00104 void setThemeName(const QString &name);
00105
00109 QString themePath() const;
00110
00114 QString fileName() const;
00115
00119 QHash<QString, QStringList> emoticonsMap() const;
00120
00124 QHash<QChar, QList<Emoticon> > emoticonsIndex() const;
00125
00129 virtual void createNew();
00130
00131 protected:
00135 void clearEmoticonsMap();
00136
00140 void addEmoticonsMap(QString key, QStringList value);
00141
00145 void removeEmoticonsMap(QString key);
00146
00152 void addEmoticonIndex(const QString &path, const QStringList &emoList);
00153
00159 void removeEmoticonIndex(const QString &path, const QStringList &emoList);
00160
00164 KEmoticonsProviderPrivate * const d;
00165 };
00166
00167 #endif
00168
00169