KEmoticons 5.109.0
Classes | Public Types | Public Member Functions | List of all members
KEmoticonsTheme

This class contains the emoticons theme. More...

#include <kemoticonstheme.h>

Classes

struct  Token
 A token consists of a QString text which is either a regular text or a path to image depending on the type. More...
 

Public Types

typedef QFlags< ParseModeEnumParseMode
 
enum  ParseModeEnum { DefaultParse = 0x0 , StrictParse = 0x1 , RelaxedParse = 0x2 , SkipHTML = 0x4 }
 The possible parse modes. More...
 
enum  TokenType { Undefined , Image , Text }
 TokenType, a token might be an image ( emoticon ) or text. More...
 

Public Member Functions

 KEmoticonsTheme ()
 Default constructor, it creates a null emoticon theme You should probably never use this, use KEmoticons::theme() instead.
 
 KEmoticonsTheme (const KEmoticonsTheme &ket)
 Copy constructor.
 
 KEmoticonsTheme (KEmoticonsProvider *p)
 Another constructor where you set the KEmoticonsProvider p You should probably never use this, use KEmoticons::theme() instead.
 
 ~KEmoticonsTheme ()
 Destructor.
 
QHash< QString, QStringList > emoticonsMap () const
 Returns a QHash that contains the emoticon path as keys and the text as values.
 
QString fileName () const
 Returns the file name of the emoticon theme.
 
bool isNull () const
 Checks if the emoticon theme has a valid provider.
 
KEmoticonsThemeoperator= (const KEmoticonsTheme &ket)
 
QString parseEmoticons (const QString &text, ParseMode mode=DefaultParse, const QStringList &exclude=QStringList()) const
 Parses emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude.
 
void setThemeName (const QString &name)
 Sets the emoticon theme name.
 
QString themeName () const
 Returns the theme name.
 
QString themePath () const
 Returns the emoticon theme path.
 
QList< Tokentokenize (const QString &message, ParseMode mode=DefaultParse) const
 Tokenizes the message message with ParseMode mode.
 

Detailed Description

This class contains the emoticons theme.

Member Enumeration Documentation

◆ ParseModeEnum

The possible parse modes.

Enumerator
DefaultParse 

Use strict or relaxed according to the config

StrictParse 

Strict parsing requires a space between each emoticon.

RelaxedParse 

Parse mode where all possible emoticon matches are allowed.

SkipHTML 

Skip emoticons within HTML.

◆ TokenType

TokenType, a token might be an image ( emoticon ) or text.

Enumerator
Undefined 

Undefined, for completeness only.

Image 

Token contains a path to an image.

Text 

Token contains text.

Constructor & Destructor Documentation

◆ KEmoticonsTheme() [1/3]

KEmoticonsTheme::KEmoticonsTheme ( )

Default constructor, it creates a null emoticon theme You should probably never use this, use KEmoticons::theme() instead.

◆ KEmoticonsTheme() [2/3]

KEmoticonsTheme::KEmoticonsTheme ( const KEmoticonsTheme ket)

Copy constructor.

◆ KEmoticonsTheme() [3/3]

KEmoticonsTheme::KEmoticonsTheme ( KEmoticonsProvider p)

Another constructor where you set the KEmoticonsProvider p You should probably never use this, use KEmoticons::theme() instead.

◆ ~KEmoticonsTheme()

KEmoticonsTheme::~KEmoticonsTheme ( )

Destructor.

Member Function Documentation

◆ emoticonsMap()

QHash< QString, QStringList > KEmoticonsTheme::emoticonsMap ( ) const

Returns a QHash that contains the emoticon path as keys and the text as values.

◆ fileName()

QString KEmoticonsTheme::fileName ( ) const

Returns the file name of the emoticon theme.

◆ isNull()

bool KEmoticonsTheme::isNull ( ) const

Checks if the emoticon theme has a valid provider.

Returns
true if it can't find a valid provider

◆ parseEmoticons()

QString KEmoticonsTheme::parseEmoticons ( const QString &  text,
ParseMode  mode = DefaultParse,
const QStringList &  exclude = QStringList() 
) const

Parses emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude.

QString text = ":D hi :)";
QStringList exclude(":)");
QString parsed = theme.parseEmoticons(text, KEmoticonsTheme::DefaultParse, exclude);
// parsed will be "<img align="center" title=":D" alt=":D" src="/path/to/:D.png" width="24" height="24" /> hi :)"
This class contains the emoticons theme.
Definition kemoticonstheme.h:23
@ DefaultParse
Use strict or relaxed according to the config
Definition kemoticonstheme.h:30
QString parseEmoticons(const QString &text, ParseMode mode=DefaultParse, const QStringList &exclude=QStringList()) const
Parses emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude.
This class can be used to retrieve, install, create emoticons theme.
Definition kemoticons.h:32
KEmoticonsTheme theme() const
Retrieves the current emoticon theme.
Parameters
textthe text to parse
modehow to parse the text
excludea list of emoticons to exclude from the parsing
Returns
the text with emoticons replaced by html images
Note
SkipHTML is forced when using this function

◆ setThemeName()

void KEmoticonsTheme::setThemeName ( const QString &  name)

Sets the emoticon theme name.

Parameters
namename of the theme

◆ themeName()

QString KEmoticonsTheme::themeName ( ) const

Returns the theme name.

◆ themePath()

QString KEmoticonsTheme::themePath ( ) const

Returns the emoticon theme path.

◆ tokenize()

QList< Token > KEmoticonsTheme::tokenize ( const QString &  message,
ParseMode  mode = DefaultParse 
) const

Tokenizes the message message with ParseMode mode.

QString text = "hi :)";
QList<Token> tokens = theme.tokenize(text, KEmoticonsTheme::DefaultParse);
// tokens[0].text = "hi "
// tokens[1].text = ":)"
// tokens[1].picPath = "/path/to/:).png"
// tokens[1].picHTMLCode = "<img align="center" title=":)" alt=":)" src="/path/to/:).png" width="24" height="24" />"
QList< Token > tokenize(const QString &message, ParseMode mode=DefaultParse) const
Tokenizes the message message with ParseMode mode.