KUtils
kemoticonstheme.h
Go to the documentation of this file.
00001 /********************************************************************************** 00002 * Copyright (C) 2008 by Carlo Segato <brandon.ml@gmail.com> * 00003 * Copyright (c) 2002-2003 by Stefan Gehn <metz@gehn.net> * 00004 * Kopete (c) 2002-2008 by the Kopete developers <kopete-devel@kde.org> * 00005 * Copyright (c) 2005 by Engin AYDOGAN <engin@bzzzt.biz> * 00006 * * 00007 * This library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU Lesser General Public * 00009 * License as published by the Free Software Foundation; either * 00010 * version 2.1 of the License, or (at your option) any later version. * 00011 * * 00012 * This library is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00015 * Lesser General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU Lesser General Public * 00018 * License along with this library. If not, see <http://www.gnu.org/licenses/>.* 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 KEMOTICONS_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 /* KEMOTICONS_THEME_H */ 00221 00222 // kate: space-indent on; indent-width 4; replace-tabs on;
KDE 4.6 API Reference