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

KUtils

Classes | Public Types | Public Member Functions
KEmoticonsTheme Class Reference

#include <kemoticonstheme.h>

List of all members.

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

enum  ParseModeEnum { DefaultParse = 0x0, StrictParse = 0x1, RelaxedParse = 0x2, SkipHTML = 0x4 }
enum  TokenType { Undefined, Image, Text }

Public Member Functions

 KEmoticonsTheme ()
 KEmoticonsTheme (const KEmoticonsTheme &ket)
 KEmoticonsTheme (KEmoticonsProvider *p)
 ~KEmoticonsTheme ()
bool addEmoticon (const QString &emo, const QString &text, KEmoticonsProvider::AddEmoticonOption option=KEmoticonsProvider::DoNotCopy)
void createNew ()
QHash< QString, QStringList > emoticonsMap () const
QString fileName () const
bool isNull () const
bool loadTheme (const QString &path)
KEmoticonsTheme & operator= (const KEmoticonsTheme &ket)
QString parseEmoticons (const QString &text, ParseMode mode=DefaultParse, const QStringList &exclude=QStringList()) const
bool removeEmoticon (const QString &emo)
void save ()
void setThemeName (const QString &name)
QString themeName () const
QString themePath () const
QList< Token > tokenize (const QString &message, ParseMode mode=DefaultParse) const

Detailed Description

This class contains the emoticons theme.

Definition at line 34 of file kemoticonstheme.h.


Member Enumeration Documentation

enum KEmoticonsTheme::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.

Definition at line 41 of file kemoticonstheme.h.

enum KEmoticonsTheme::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.

Definition at line 53 of file kemoticonstheme.h.


Constructor & Destructor Documentation

KEmoticonsTheme::KEmoticonsTheme ( )

Default constructor, it creates a null emoticons theme you should probably never use this, instead use KEmoticons::theme()

Definition at line 53 of file kemoticonstheme.cpp.

KEmoticonsTheme::KEmoticonsTheme ( const KEmoticonsTheme &  ket)

Copy constructor.

Definition at line 58 of file kemoticonstheme.cpp.

KEmoticonsTheme::KEmoticonsTheme ( KEmoticonsProvider *  p)

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

Definition at line 63 of file kemoticonstheme.cpp.

KEmoticonsTheme::~KEmoticonsTheme ( )

Destructor.

Definition at line 69 of file kemoticonstheme.cpp.


Member Function Documentation

bool KEmoticonsTheme::addEmoticon ( const QString &  emo,
const QString &  text,
KEmoticonsProvider::AddEmoticonOption  option = KEmoticonsProvider::DoNotCopy 
)

Add the emoticon emo with text text.

KEmoticonsTheme theme = KEmoticons().theme();
theme.addEmoticon("/path/to/smiley.png", ":) :-)");
Parameters:
emopath to the emoticon image
textthe text of the emoticon separated by space for multiple text
copywhether or not copy emo into the theme directory
Returns:
true if it can add the emoticon

Definition at line 91 of file kemoticonstheme.cpp.

void KEmoticonsTheme::createNew ( )

Create a new theme.

Definition at line 154 of file kemoticonstheme.cpp.

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

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

Definition at line 145 of file kemoticonstheme.cpp.

QString KEmoticonsTheme::fileName ( ) const

Returns the file name of the theme.

Definition at line 136 of file kemoticonstheme.cpp.

bool KEmoticonsTheme::isNull ( ) const

Check if the theme has a valid provider and it returns true if it can't find it.

Definition at line 362 of file kemoticonstheme.cpp.

bool KEmoticonsTheme::loadTheme ( const QString &  path)

Load the theme inside the directory path.

Parameters:
pathpath to the directory

Definition at line 73 of file kemoticonstheme.cpp.

KEmoticonsTheme & KEmoticonsTheme::operator= ( const KEmoticonsTheme &  ket)

Definition at line 367 of file kemoticonstheme.cpp.

QString KEmoticonsTheme::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.

KEmoticonsTheme theme = KEmoticons().theme();
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 :)"
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

Definition at line 163 of file kemoticonstheme.cpp.

bool KEmoticonsTheme::removeEmoticon ( const QString &  emo)

Remove the emoticon emo, this will not delete the image file too.

KEmoticonsTheme theme = KEmoticons().theme();
theme.removeEmoticon(":)");
Parameters:
emothe emoticon text to remove
Returns:
true if it can delete the emoticon

Definition at line 82 of file kemoticonstheme.cpp.

void KEmoticonsTheme::save ( )

Save the emoticon theme.

Definition at line 100 of file kemoticonstheme.cpp.

void KEmoticonsTheme::setThemeName ( const QString &  name)

Set the theme name.

Parameters:
namename of the theme

Definition at line 118 of file kemoticonstheme.cpp.

QString KEmoticonsTheme::themeName ( ) const

Returns the theme name.

Definition at line 109 of file kemoticonstheme.cpp.

QString KEmoticonsTheme::themePath ( ) const

Returns the theme path.

Definition at line 127 of file kemoticonstheme.cpp.

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

Tokenize the message message with ParseMode mode.

KEmoticonsTheme theme = KEmoticons().theme();
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" />"

Definition at line 201 of file kemoticonstheme.cpp.


The documentation for this class was generated from the following files:
  • kemoticonstheme.h
  • kemoticonstheme.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jun 1 2013 12:09:18 by doxygen 1.8.1.1 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.10.4 API Reference

Skip menu "kdelibs-4.10.4 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