Grantlee  5.0.0
Public Member Functions | List of all members
Grantlee::PlainTextMarkupBuilder Class Reference

The PlainTextHTMLMarkupBuilder creates a simple marked up plain text document. More...

#include <grantlee/plaintextmarkupbuilder.h>

Inheritance diagram for Grantlee::PlainTextMarkupBuilder:
Inheritance graph
[legend]

Public Member Functions

 PlainTextMarkupBuilder ()
 
void addNewline ()
 
int addReference (const QString &reference)
 
void appendLiteralText (const QString &text)
 
void appendRawText (const QString &text)
 
void beginAnchor (const QString &href=QString(), const QString &name=QString())
 
void beginBackground (const QBrush &brush)
 
void beginEmph ()
 
void beginFontFamily (const QString &family)
 
void beginFontPointSize (int size)
 
void beginForeground (const QBrush &brush)
 
void beginHeader (int level)
 
void beginList (QTextListFormat::Style style)
 
void beginListItem ()
 
void beginParagraph (Qt::Alignment a=Qt::AlignLeft, qreal top=0.0, qreal bottom=0.0, qreal left=0.0, qreal right=0.0)
 
void beginStrikeout ()
 
void beginStrong ()
 
void beginSubscript ()
 
void beginSuperscript ()
 
void beginTable (qreal cellpadding, qreal cellspacing, const QString &width)
 
void beginTableCell (const QString &width, int colSpan, int rowSpan)
 
void beginTableHeaderCell (const QString &width, int colSpan, int rowSpan)
 
void beginTableRow ()
 
void beginUnderline ()
 
void endAnchor ()
 
void endBackground ()
 
void endEmph ()
 
void endFontFamily ()
 
void endFontPointSize ()
 
void endForeground ()
 
void endHeader (int level)
 
void endList ()
 
void endListItem ()
 
void endParagraph ()
 
void endStrikeout ()
 
void endStrong ()
 
void endSubscript ()
 
void endSuperscript ()
 
void endTable ()
 
void endTableCell ()
 
void endTableHeaderCell ()
 
void endTableRow ()
 
void endUnderline ()
 
QString getResult ()
 
void insertHorizontalRule (int width=-1)
 
void insertImage (const QString &src, qreal width, qreal height)
 
- Public Member Functions inherited from Grantlee::AbstractMarkupBuilder
virtual ~AbstractMarkupBuilder ()
 

Detailed Description

This class creates a simple plain text markup.

Text that may be represented as

A paragraph with <b>bold</b> text, <i>italic</i> text, and <u>underlined</u> text.

would be output as

A paragraph with *bold* text /italic/ text, and _underlined_ text.

The markup is intended to be simple, plain and easily human readable. No markup is created for different font-familiy, font-size, foreground or background colors.

Lists are marked up by preceding the list element with '*' for disc, 'o' for circle, 'X' for square, or a letter or number. Lists are also indented if nested. eg:

A. One
B. Two
o Three
o Four
\* Five
\* Six
C. Seven

External references such as external urls and images are represented in the body text as a reference, and references are maintained at the bottom of the output.

Eg,

Here is a link to <a href="http://www.kde.org">KDE</a> and the <a href="http://pim.kde.org">KDEPIM project</a>.

becomes:

Here is a link to KDE[1], and the KDEPIM project[2].
---- References ----
[1] http://www.kde.org
[2] http://pim.kde.org
Author
Stephen Kelly steve.nosp@m.ire@.nosp@m.gmail.nosp@m..com

Definition at line 96 of file plaintextmarkupbuilder.h.

Constructor & Destructor Documentation

Grantlee::PlainTextMarkupBuilder::PlainTextMarkupBuilder ( )

Construct a new PlainTextHTMLMarkupBuilder.

Member Function Documentation

void Grantlee::PlainTextMarkupBuilder::addNewline ( )
virtual

Add a newline to the markup.

Implements Grantlee::AbstractMarkupBuilder.

int Grantlee::PlainTextMarkupBuilder::addReference ( const QString &  reference)

Adds a reference to reference to the internal list of references in the document.

void Grantlee::PlainTextMarkupBuilder::appendLiteralText ( const QString &  text)
virtual

Append the plain text text to the markup.

Parameters
textThe text to append.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::appendRawText ( const QString &  text)
virtual

Appends the raw text text to the markup. text is added unescaped.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginAnchor ( const QString &  href = QString(),
const QString &  name = QString() 
)
virtual

Begin a url anchor element in the markup

Parameters
hrefThe href of the anchor.
nameThe name of the anchor.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginBackground ( const QBrush &  brush)
virtual

Begin a decorarated background element in the markup (A text background color) using brush

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginEmph ( )
virtual

Begin an emphasised element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginFontFamily ( const QString &  family)
virtual

Begin a new font familiy element in the markup

Parameters
familyThe name of the font family to begin.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginFontPointSize ( int  size)
virtual

Begin a new font point size element in the markup

Parameters
sizeThe point size to begin.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginForeground ( const QBrush &  brush)
virtual

Begin a decorarated foreground element in the markup (A text color) using brush

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginHeader ( int  level)
virtual

Begin a level level header.

Parameters
levelAn integer between 1 and 6

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginList ( QTextListFormat::Style  style)
virtual

Begin a new list element in the markup. A list element contains list items, and may contain other lists.

Parameters
styleThe style of list to create.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginListItem ( )
virtual

Begin a new list item in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginParagraph ( Qt::Alignment  a = Qt::AlignLeft,
qreal  top = 0.0,
qreal  bottom = 0.0,
qreal  left = 0.0,
qreal  right = 0.0 
)
virtual

Begin a new paragraph in the markup

Parameters
aThe alignment of the new paragraph.
topThe top margin of the new paragraph.
bottomThe bottom margin of the new paragraph.
leftThe left margin of the new paragraph.
rightThe right margin of the new paragraph.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginStrikeout ( )
virtual

Begin a struck out element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginStrong ( )
virtual

Begin a bold element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginSubscript ( )
virtual

Begin a subscript element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginSuperscript ( )
virtual

Begin a superscript element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginTable ( qreal  cellpadding,
qreal  cellspacing,
const QString &  width 
)
virtual

Begin a table element.

Parameters
cellpaddingThe padding attribute for the table.
cellspacingThe spacing attribute for the table.
widthThe width of the table. May be either an integer, or a percentage value.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginTableCell ( const QString &  width,
int  colSpan,
int  rowSpan 
)
virtual

Begin a new table cell.

Parameters
widthThe width of the cell.
colSpanThe column span of the cell.
rowSpanThe row span of the cell.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginTableHeaderCell ( const QString &  width,
int  colSpan,
int  rowSpan 
)
virtual

Begin a new table header cell.

Parameters
widthThe width of the cell.
colSpanThe column span of the cell.
rowSpanThe row span of the cell.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginTableRow ( )
virtual

Begins a new table row.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::beginUnderline ( )
virtual

Begin an underlined element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endAnchor ( )
virtual

Close the anchor element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endBackground ( )
virtual

Close the decorarated background element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endEmph ( )
virtual

Close the emphasised element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endFontFamily ( )
virtual

End font family element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endFontPointSize ( )
virtual

End font point size element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endForeground ( )
virtual

Close the decorarated foreground element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endHeader ( int  level)
virtual

End a level level header.

Parameters
levelAn integer between 1 and 6

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endList ( )
virtual

Close the list.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endListItem ( )
virtual

End the list item

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endParagraph ( )
virtual

Close the paragraph in the markup.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endStrikeout ( )
virtual

Close the struck out element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endStrong ( )
virtual

Close the bold element in the markup

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endSubscript ( )
virtual

End subscript element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endSuperscript ( )
virtual

End superscript element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endTable ( )
virtual

End a table element

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endTableCell ( )
virtual

End a table cell

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endTableHeaderCell ( )
virtual

End a table header cell

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endTableRow ( )
virtual

End a table row

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::endUnderline ( )
virtual

Close the underlined element in the markup

Implements Grantlee::AbstractMarkupBuilder.

QString Grantlee::PlainTextMarkupBuilder::getResult ( )
virtual

Returns the finalised plain text markup, including references at the end.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::insertHorizontalRule ( int  width = -1)
virtual

Insert a horizontal rule into the markup.

Parameters
widthThe width of the rule. Default is full width.

Implements Grantlee::AbstractMarkupBuilder.

void Grantlee::PlainTextMarkupBuilder::insertImage ( const QString &  url,
qreal  width,
qreal  height 
)
virtual

Insert a new image element into the markup.

Parameters
urlThe url of the image
widthThe width of the image
heightThe height of the image.

Implements Grantlee::AbstractMarkupBuilder.