KUtils
kemoticonsprovider.h
Go to the documentation of this file.00001 /********************************************************************************** 00002 * Copyright (C) 2008 by Carlo Segato <brandon.ml@gmail.com> * 00003 * * 00004 * This library is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU Lesser General Public * 00006 * License as published by the Free Software Foundation; either * 00007 * version 2.1 of the License, or (at your option) any later version. * 00008 * * 00009 * This library is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00012 * Lesser General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU Lesser General Public * 00015 * License along with this library. If not, see <http://www.gnu.org/licenses/>.* 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 /* sort by longest to shortest matchText */ 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 /* KEMOTICONS_PROVIDER_H */ 00168 00169 // kate: space-indent on; indent-width 4; replace-tabs on;