diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/irc/ksparser.h | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/irc/ksparser.h')
-rw-r--r-- | kopete/protocols/irc/ksparser.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kopete/protocols/irc/ksparser.h b/kopete/protocols/irc/ksparser.h new file mode 100644 index 00000000..dda7b7c1 --- /dev/null +++ b/kopete/protocols/irc/ksparser.h @@ -0,0 +1,56 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Simon Hausmann <hausmann@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the Artistic License. +*/ +#ifndef __ksparser_h__ +#define __ksparser_h__ + +#include <qcolor.h> +#include <qmap.h> +#include <qregexp.h> +#include <qstring.h> +#include <qvaluestack.h> + +/* + * Helper class to parse IRC color/style codes and convert them to + * richtext. The parser maintains an internal stack of the styles + * applied because the IRC message could contain sequences as + * (bold)Hello (red)World(endbold)! (blue)blue text + * which needs to be converted to + * <b>Hello </b><font color="red"><b>World</b>! </font><font color="blue">blue text</font> + * to get correctly nested tags. (malte) + */ +class KSParser +{ +public: + static QCString parse(const QCString &); + static int colorForHTML( const QString &html ); + + static QColor ircColor(const QString &color); + static QColor ircColor(unsigned int color); + + ~KSParser(); +private: + KSParser(); + + QCString _parse(const QCString &); + QString pushTag(const QString &, const QString & = QString::null); + QString pushColorTag(const QColor &fgColor, const QColor &bgColor); + QString popTag(const QString &); + QString toggleTag(const QString &); + QString popAll(); + +private: + static KSParser m_parser; + static const QColor IRC_Colors[17]; + static const QRegExp sm_colorsModeRegexp; + + QValueStack<QString> m_tags; + QMap<QString, QString> m_attributes; +}; + +#endif + + |