author | skyhusker <skyhusker> | 2005-01-14 20:53:08 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-01-14 20:53:08 (UTC) |
commit | b6c5c3b8b1ab130217678ec789db573ffc52c3eb (patch) (side-by-side diff) | |
tree | 67e8ef2f6e447b7795d2ec3c10c896d56069e727 /noncore/net/opieirc/ircoutput.cpp | |
parent | f572b6a41ab3576957b29d73b54bfc34adeea07c (diff) | |
download | opie-b6c5c3b8b1ab130217678ec789db573ffc52c3eb.zip opie-b6c5c3b8b1ab130217678ec789db573ffc52c3eb.tar.gz opie-b6c5c3b8b1ab130217678ec789db573ffc52c3eb.tar.bz2 |
Added bold and underline display support
Diffstat (limited to 'noncore/net/opieirc/ircoutput.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircoutput.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircoutput.cpp b/noncore/net/opieirc/ircoutput.cpp index 4822fc4..d2c730f 100644 --- a/noncore/net/opieirc/ircoutput.cpp +++ b/noncore/net/opieirc/ircoutput.cpp @@ -1,7 +1,17 @@ +#include <qtopia/stringutil.h> + #include "ircoutput.h" + +IRCOutputEscapeSecuences IRCOutput::m_escapeSecuences[] = { + { '', "<b>", "</b>"}, + { '', "<u>", "</u>"}, + { 0, 0, 0}, +}; + IRCOutput::IRCOutput(IRCOutputType type, QString message) { m_type = type; - m_message = message; + /* Filter color, bold and underline escape sequences, since they aren't implemented yet */ + m_message = message.replace(QRegExp("[1-9]*,*[1-9]*"), ""); } @@ -14,12 +24,36 @@ QString IRCOutput::message() { } +void IRCOutput::setType(IRCOutputType type) { + m_type = type; +} + +void IRCOutput::setMessage(const QString &message) { + m_message = message; +} + QString IRCOutput::htmlMessage() { return toHTML(m_message); } -QString IRCOutput::toHTML(QString message) { - QString htmlMessage =message.replace(QRegExp("&"), "&"); - htmlMessage = htmlMessage.replace(QRegExp(">"), ">"); - htmlMessage = htmlMessage.replace(QRegExp("<"), "<"); +QString IRCOutput::toHTML(const QString &message) { + QString htmlMessage = Qtopia::escapeString(message); + + for(int i=0; m_escapeSecuences[i].escape != 0;++i) { + int pos = 0; + bool isOpen = false; + while( (pos = htmlMessage.find(m_escapeSecuences[i].escape, pos)) != -1) { + htmlMessage.remove(pos, 1); + if(isOpen) + htmlMessage.insert(pos, m_escapeSecuences[i].close); + else + htmlMessage.insert(pos, m_escapeSecuences[i].open); + + isOpen = !isOpen; + } + if(isOpen) + htmlMessage.append(m_escapeSecuences[i].close); + } + + htmlMessage = htmlMessage.replace(QRegExp("\n"), "<br>"); return htmlMessage; } @@ -32,2 +66,3 @@ void *IRCOutput::getParam(int index) { return m_parameters.at(index); } + |