Provides methods for text formatting.
More...
Inherits QObject.
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.
- See also
- IrcPalette
This enum describes the supported formats for HTML span-elements.
Enumerator |
---|
SpanStyle |
HTML span-elements with style-attributes.
|
SpanClass |
HTML span-elements with class-attributes.
|
IrcTextFormat::IrcTextFormat |
( |
QObject * |
parent = 0 | ) |
|
|
explicit |
Constructs a new text format with parent.
IrcTextFormat::~IrcTextFormat |
( |
| ) |
|
|
virtual |
Destructs the text format.
void IrcTextFormat::parse |
( |
const QString & |
text | ) |
|
|
slot |
- Since
- 3.2
Parses text converting it to plain text and HTML and detects URLs.
- See also
- plainText, html, urls
- Since
- 3.1
This property holds the format used for HTML span-elements.
IrcTextFormat uses HTML span-elements for converting the IRC-style text formatting to the corresponding HTML formatting. The SpanStyle format generates self contained span-elements with style-attributes, resulting to HTML that is ready to be used with Qt's rich text classes without additional styling. For more flexible styling, the SpanClass generates span-elements with class-attributes that can be styled with additional style sheets.
The default value is SpanStyle. The following table illustrates the difference between SpanStyle and SpanClass HTML formatting:
IRC format | SpanStyle | SpanClass |
Bold ("\02...\0F") | <span style='font-weight: bold'>...</span> | <span class='bold'>...</span> |
Color ("\03fg...\0F") | <span style='color: fg;'>...</span> | <span class='fg'>...</span> |
Background ("\03fgbg...\0F") | <span style='color: fg; background-color: bg'>...</span> | <span class='fg bg-background'>...</span> |
Italic ("\09...\0F") | <span style='font-style: italic'>...</span> | <span class='italic'>...</span> |
Line-through ("\13...\0F") | <span style='text-decoration: line-through'>...</span> | <span class='line-through'>...</span> |
Underline ("\15...\0F" or "\1F...\0F") | <span style='text-decoration: underline'>...</span> | <span class='underline'>...</span> |
Inverse ("\16...\0F") | <span style='text-decoration: inverse'>...</span> | <span class='inverse'>...</span> |
- Access functions:
-
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
- toPlainText(), parse(), palette, urlPattern, spanFormat
Converts text to plain text. This function parses the text and strips away IRC-style formatting (colors, bold, underline etc.)
- See also
- toHtml(), parse()
- Since
- 3.2
This property holds the current HTML content.
- Access function:
-
- See also
- parse(), plainText, urls
This property holds the palette used for color formatting.
- Access function:
-
- Since
- 3.2
This property holds the current plain text content.
- Access function:
-
- See also
- parse(), html, urls
This property holds the regular expression pattern used for matching URLs.
- Access functions:
-
- Since
- 3.2
This property holds the current list of URLs.
- Access function:
-
- See also
- parse(), plainText, html