• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KUtils

  • kutils
  • kemoticons
kemoticonstheme.h
Go to the documentation of this file.
1/**********************************************************************************
2 * Copyright (C) 2008 by Carlo Segato <brandon.ml@gmail.com> *
3 * Copyright (c) 2002-2003 by Stefan Gehn <metz@gehn.net> *
4 * Kopete (c) 2002-2008 by the Kopete developers <kopete-devel@kde.org> *
5 * Copyright (c) 2005 by Engin AYDOGAN <engin@bzzzt.biz> *
6 * *
7 * This library is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU Lesser General Public *
9 * License as published by the Free Software Foundation; either *
10 * version 2.1 of the License, or (at your option) any later version. *
11 * *
12 * This library is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.*
19 * *
20 **********************************************************************************/
21
22#ifndef KEMOTICONS_THEME_H
23#define KEMOTICONS_THEME_H
24
25#include "kemoticonsprovider.h"
26
27#include <QtCore/QSharedDataPointer>
28
29class QString;
30
34class KEMOTICONS_EXPORT KEmoticonsTheme
35{
36public:
37
41 enum ParseModeEnum {
42 DefaultParse = 0x0,
43 StrictParse = 0x1,
44 RelaxedParse = 0x2,
45 SkipHTML = 0x4
46 };
47
48 Q_DECLARE_FLAGS(ParseMode, ParseModeEnum)
49
50
53 enum TokenType {
54 Undefined,
55 Image,
56 Text
57 };
58
65 struct Token {
66 Token() : type(Undefined) {}
70 Token(TokenType t, const QString &m) : type(t), text(m) {}
74 Token(TokenType t, const QString &m, const QString &p, const QString &html)
75 : type(t), text(m), picPath(p), picHTMLCode(html) {}
76 TokenType type;
77 QString text;
78 QString picPath;
79 QString picHTMLCode;
80 };
81
86 KEmoticonsTheme();
87
91 KEmoticonsTheme(const KEmoticonsTheme &ket);
92
97 KEmoticonsTheme(KEmoticonsProvider *p);
98
102 ~KEmoticonsTheme();
103
119 QString parseEmoticons(const QString &text, ParseMode mode = DefaultParse, const QStringList &exclude = QStringList()) const;
120
133 QList<Token> tokenize(const QString &message, ParseMode mode = DefaultParse) const;
134
139 bool loadTheme(const QString &path);
140
150 bool removeEmoticon(const QString &emo);
151
163 bool addEmoticon(const QString &emo, const QString &text, KEmoticonsProvider::AddEmoticonOption option = KEmoticonsProvider::DoNotCopy);
164
168 void save();
169
173 QString themeName() const;
174
179 void setThemeName(const QString &name);
180
184 QString themePath() const;
185
189 QString fileName() const;
190
194 QHash<QString, QStringList> emoticonsMap() const;
195
199 void createNew();
200
204 bool isNull() const;
205
209 KEmoticonsTheme& operator=(const KEmoticonsTheme &ket);
210private:
211 class KEmoticonsThemeData;
215 QSharedDataPointer<KEmoticonsThemeData> d;
216};
217
218Q_DECLARE_OPERATORS_FOR_FLAGS(KEmoticonsTheme::ParseMode)
219
220#endif /* KEMOTICONS_THEME_H */
221
222// kate: space-indent on; indent-width 4; replace-tabs on;
KEmoticonsProvider
This is the base class for the emoticons provider plugins.
Definition kemoticonsprovider.h:36
KEmoticonsProvider::AddEmoticonOption
AddEmoticonOption
Options to pass to addEmoticon.
Definition kemoticonsprovider.h:53
KEmoticonsProvider::DoNotCopy
@ DoNotCopy
< Don't copy the emoticon file into the theme directory
Definition kemoticonsprovider.h:54
KEmoticonsTheme::setThemeName
void setThemeName(const QString &name)
Set the theme name.
Definition kemoticonstheme.cpp:118
KEmoticonsTheme::fileName
QString fileName() const
Returns the file name of the theme.
Definition kemoticonstheme.cpp:136
KEmoticonsTheme::removeEmoticon
bool removeEmoticon(const QString &emo)
Remove the emoticon emo, this will not delete the image file too.
Definition kemoticonstheme.cpp:82
KEmoticonsTheme::emoticonsMap
QHash< QString, QStringList > emoticonsMap() const
Returns a QHash that contains the emoticons path as keys and the text as values.
Definition kemoticonstheme.cpp:145
KEmoticonsTheme::ParseModeEnum
ParseModeEnum
The possible parse modes.
Definition kemoticonstheme.h:41
KEmoticonsTheme::DefaultParse
@ DefaultParse
Use strict or relaxed according to the config.
Definition kemoticonstheme.h:42
KEmoticonsTheme::SkipHTML
@ SkipHTML
Skip emoticons within HTML.
Definition kemoticonstheme.h:45
KEmoticonsTheme::StrictParse
@ StrictParse
Strict parsing requires a space between each emoticon.
Definition kemoticonstheme.h:43
KEmoticonsTheme::RelaxedParse
@ RelaxedParse
Parse mode where all possible emoticon matches are allowed.
Definition kemoticonstheme.h:44
KEmoticonsTheme::themeName
QString themeName() const
Returns the theme name.
Definition kemoticonstheme.cpp:109
KEmoticonsTheme::tokenize
QList< Token > tokenize(const QString &message, ParseMode mode=DefaultParse) const
Tokenize the message message with ParseMode mode.
Definition kemoticonstheme.cpp:201
KEmoticonsTheme::themePath
QString themePath() const
Returns the theme path.
Definition kemoticonstheme.cpp:127
KEmoticonsTheme::TokenType
TokenType
TokenType, a token might be an image ( emoticon ) or text.
Definition kemoticonstheme.h:53
KEmoticonsTheme::Text
@ Text
Token contains text.
Definition kemoticonstheme.h:56
KEmoticonsTheme::Image
@ Image
Token contains a path to an image.
Definition kemoticonstheme.h:55
KEmoticonsTheme::Undefined
@ Undefined
Undefined, for completeness only.
Definition kemoticonstheme.h:54
KEmoticonsTheme::addEmoticon
bool addEmoticon(const QString &emo, const QString &text, KEmoticonsProvider::AddEmoticonOption option=KEmoticonsProvider::DoNotCopy)
Add the emoticon emo with text text.
Definition kemoticonstheme.cpp:91
KEmoticonsTheme::parseEmoticons
QString parseEmoticons(const QString &text, ParseMode mode=DefaultParse, const QStringList &exclude=QStringList()) const
Parse emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude.
Definition kemoticonstheme.cpp:163
KEmoticonsTheme::loadTheme
bool loadTheme(const QString &path)
Load the theme inside the directory path.
Definition kemoticonstheme.cpp:73
KEmoticonsTheme::isNull
bool isNull() const
Check if the theme has a valid provider and it returns true if it can't find it.
Definition kemoticonstheme.cpp:362
KEmoticonsTheme::save
void save()
Save the emoticon theme.
Definition kemoticonstheme.cpp:100
KEmoticonsTheme::createNew
void createNew()
Create a new theme.
Definition kemoticonstheme.cpp:154
KEmoticonsTheme::KEmoticonsTheme
KEmoticonsTheme()
Default constructor, it creates a null emoticons theme you should probably never use this,...
Definition kemoticonstheme.cpp:53
KEmoticonsTheme::operator=
KEmoticonsTheme & operator=(const KEmoticonsTheme &ket)
Definition kemoticonstheme.cpp:367
QHash
QList
kemoticonsprovider.h
KEmoticonsTheme::Token::text
QString text
text
Definition kemoticonstheme.h:77
KEmoticonsTheme::Token::Token
Token(TokenType t, const QString &m, const QString &p, const QString &html)
Create a Token of type t, text m, image path p and html code html.
Definition kemoticonstheme.h:74
KEmoticonsTheme::Token::picHTMLCode
QString picHTMLCode
<img> html code
Definition kemoticonstheme.h:79
KEmoticonsTheme::Token::Token
Token()
Definition kemoticonstheme.h:66
KEmoticonsTheme::Token::picPath
QString picPath
path to the image
Definition kemoticonstheme.h:78
KEmoticonsTheme::Token::Token
Token(TokenType t, const QString &m)
Create a Token of type t, and text m.
Definition kemoticonstheme.h:70
KEmoticonsTheme::Token::type
TokenType type
type
Definition kemoticonstheme.h:76
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUtils

Skip menu "KUtils"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal