Communi  3.0.0
A cross-platform IRC framework written with Qt
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Macros Groups Pages
Public Member Functions | Properties | List of all members
IrcTextFormat Class Reference

Provides methods for text formatting. More...

Inherits QObject.

Public Member Functions

 IrcTextFormat (QObject *parent=0)
 
virtual ~IrcTextFormat ()
 
Q_INVOKABLE QString toHtml (const QString &text) const
 
Q_INVOKABLE QString toPlainText (const QString &text) const
 

Properties

IrcPalette palette
 
QString urlPattern
 

Detailed Description

IrcTextFormat is used to convert IRC-style formatted messages to either plain text or HTML. When converting to plain text, the IRC-style formatting (colors, bold, underline etc.) are simply stripped away. When converting to HTML, the IRC-style formatting is converted to the corresponding HTML formatting.

QString text = format.toPlainText(message);
format.palette()->setColorName(Irc::Red, "#ff3333");
format.palette()->setColorName(Irc::Green, "#33ff33");
format.palette()->setColorName(Irc::Blue, "#3333ff");
// ...
QString html = format.toHtml(message);
See Also
IrcPalette

Constructor & Destructor Documentation

IrcTextFormat::IrcTextFormat ( QObject parent = 0)
explicit

Constructs a new text format with parent.

IrcTextFormat::~IrcTextFormat ( )
virtual

Destructs the text format.

Member Function Documentation

QString IrcTextFormat::toHtml ( const QString text) const

Converts text to HTML. This function parses the text and replaces IRC-style formatting (colors, bold, underline etc.) to the corresponding HTML formatting. Furthermore, this function detects URLs and replaces them with appropriate HTML hyperlinks.

Note
URL detection can be disabled by setting an empty regular expression pattern used for matching URLs.
See Also
palette, urlPattern, toPlainText()
QString IrcTextFormat::toPlainText ( const QString text) const

Converts text to plain text. This function parses the text and strips away IRC-style formatting (colors, bold, underline etc.)

See Also
toHtml()

Property Documentation

IrcPalette * IrcTextFormat::palette
read

This property holds the palette used for color formatting.

Access function:
QString IrcTextFormat::urlPattern
readwrite

This property holds the regular expression pattern used for matching URLs.

Access functions:
  • QString urlPattern() const
  • void setUrlPattern(const QString& pattern)