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

Creates a simple marked up plain text document. More...

#include <grantlee/plaintextmarkupbuilder.h>

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

Public Member Functions

void addNewline () override
 
int addReference (const QString &reference)
 
void appendLiteralText (const QString &text) override
 
void appendRawText (const QString &text) override
 
void beginAnchor (const QString &href={}, const QString &name={}) override
 
void beginBackground (const QBrush &brush) override
 
void beginEmph () override
 
void beginFontFamily (const QString &family) override
 
void beginFontPointSize (int size) override
 
void beginForeground (const QBrush &brush) override
 
void beginHeader (int level) override
 
void beginList (QTextListFormat::Style style) override
 
void beginListItem () override
 
void beginParagraph (Qt::Alignment a=Qt::AlignLeft, qreal top=0.0, qreal bottom=0.0, qreal left=0.0, qreal right=0.0) override
 
void beginStrikeout () override
 
void beginStrong () override
 
void beginSubscript () override
 
void beginSuperscript () override
 
void beginTable (qreal cellpadding, qreal cellspacing, const QString &width) override
 
void beginTableCell (const QString &width, int colSpan, int rowSpan) override
 
void beginTableHeaderCell (const QString &width, int colSpan, int rowSpan) override
 
void beginTableRow () override
 
void beginUnderline () override
 
void endAnchor () override
 
void endBackground () override
 
void endEmph () override
 
void endFontFamily () override
 
void endFontPointSize () override
 
void endForeground () override
 
void endHeader (int level) override
 
void endList () override
 
void endListItem () override
 
void endParagraph () override
 
void endStrikeout () override
 
void endStrong () override
 
void endSubscript () override
 
void endSuperscript () override
 
void endTable () override
 
void endTableCell () override
 
void endTableHeaderCell () override
 
void endTableRow () override
 
void endUnderline () override
 
QString getResult () override
 
void insertHorizontalRule (int width=-1) override
 
void insertImage (const QString &src, qreal width, qreal height) override
 
- 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 104 of file plaintextmarkupbuilder.h.

Member Function Documentation

◆ addNewline()

void Grantlee::PlainTextMarkupBuilder::addNewline ( )
overridevirtual

Add a newline to the markup.

Implements Grantlee::AbstractMarkupBuilder.

◆ addReference()

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

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

◆ appendLiteralText()

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

Append the plain text text to the markup

Parameters
textThe text to append.

Implements Grantlee::AbstractMarkupBuilder.

◆ appendRawText()

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

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

Implements Grantlee::AbstractMarkupBuilder.

◆ beginAnchor()

void Grantlee::PlainTextMarkupBuilder::beginAnchor ( const QString &  href = {},
const QString &  name = {} 
)
overridevirtual

Begin a url anchor element in the markup

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

Implements Grantlee::AbstractMarkupBuilder.

◆ beginBackground()

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

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

Implements Grantlee::AbstractMarkupBuilder.

◆ beginEmph()

void Grantlee::PlainTextMarkupBuilder::beginEmph ( )
overridevirtual

Begin an emphasised element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ beginFontFamily()

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

Begin a new font familiy element in the markup

Parameters
familyThe name of the font family to begin.

Implements Grantlee::AbstractMarkupBuilder.

◆ beginFontPointSize()

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

Begin a new font point size element in the markup

Parameters
sizeThe point size to begin.

Implements Grantlee::AbstractMarkupBuilder.

◆ beginForeground()

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

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

Implements Grantlee::AbstractMarkupBuilder.

◆ beginHeader()

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

Begin a level level header

Parameters
levelAn integer between 1 and 6

Implements Grantlee::AbstractMarkupBuilder.

◆ beginList()

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

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.

◆ beginListItem()

void Grantlee::PlainTextMarkupBuilder::beginListItem ( )
overridevirtual

Begin a new list item in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ beginParagraph()

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 
)
overridevirtual

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.

◆ beginStrikeout()

void Grantlee::PlainTextMarkupBuilder::beginStrikeout ( )
overridevirtual

Begin a struck out element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ beginStrong()

void Grantlee::PlainTextMarkupBuilder::beginStrong ( )
overridevirtual

Begin a bold element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ beginSubscript()

void Grantlee::PlainTextMarkupBuilder::beginSubscript ( )
overridevirtual

Begin a subscript element

Implements Grantlee::AbstractMarkupBuilder.

◆ beginSuperscript()

void Grantlee::PlainTextMarkupBuilder::beginSuperscript ( )
overridevirtual

Begin a superscript element

Implements Grantlee::AbstractMarkupBuilder.

◆ beginTable()

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

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.

◆ beginTableCell()

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

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.

◆ beginTableHeaderCell()

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

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.

◆ beginTableRow()

void Grantlee::PlainTextMarkupBuilder::beginTableRow ( )
overridevirtual

Begin a new table row

Implements Grantlee::AbstractMarkupBuilder.

◆ beginUnderline()

void Grantlee::PlainTextMarkupBuilder::beginUnderline ( )
overridevirtual

Begin an underlined element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endAnchor()

void Grantlee::PlainTextMarkupBuilder::endAnchor ( )
overridevirtual

Close the anchor element

Implements Grantlee::AbstractMarkupBuilder.

◆ endBackground()

void Grantlee::PlainTextMarkupBuilder::endBackground ( )
overridevirtual

Close the decorarated background element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endEmph()

void Grantlee::PlainTextMarkupBuilder::endEmph ( )
overridevirtual

Close the emphasised element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endFontFamily()

void Grantlee::PlainTextMarkupBuilder::endFontFamily ( )
overridevirtual

End font family element

Implements Grantlee::AbstractMarkupBuilder.

◆ endFontPointSize()

void Grantlee::PlainTextMarkupBuilder::endFontPointSize ( )
overridevirtual

End font point size element

Implements Grantlee::AbstractMarkupBuilder.

◆ endForeground()

void Grantlee::PlainTextMarkupBuilder::endForeground ( )
overridevirtual

Close the decorarated foreground element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endHeader()

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

End a level level header

Parameters
levelAn integer between 1 and 6

Implements Grantlee::AbstractMarkupBuilder.

◆ endList()

void Grantlee::PlainTextMarkupBuilder::endList ( )
overridevirtual

Close the list.

Implements Grantlee::AbstractMarkupBuilder.

◆ endListItem()

void Grantlee::PlainTextMarkupBuilder::endListItem ( )
overridevirtual

End the list item

Implements Grantlee::AbstractMarkupBuilder.

◆ endParagraph()

void Grantlee::PlainTextMarkupBuilder::endParagraph ( )
overridevirtual

Close the paragraph in the markup.

Implements Grantlee::AbstractMarkupBuilder.

◆ endStrikeout()

void Grantlee::PlainTextMarkupBuilder::endStrikeout ( )
overridevirtual

Close the struck out element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endStrong()

void Grantlee::PlainTextMarkupBuilder::endStrong ( )
overridevirtual

Close the bold element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ endSubscript()

void Grantlee::PlainTextMarkupBuilder::endSubscript ( )
overridevirtual

End subscript element

Implements Grantlee::AbstractMarkupBuilder.

◆ endSuperscript()

void Grantlee::PlainTextMarkupBuilder::endSuperscript ( )
overridevirtual

End superscript element

Implements Grantlee::AbstractMarkupBuilder.

◆ endTable()

void Grantlee::PlainTextMarkupBuilder::endTable ( )
overridevirtual

End a table element

Implements Grantlee::AbstractMarkupBuilder.

◆ endTableCell()

void Grantlee::PlainTextMarkupBuilder::endTableCell ( )
overridevirtual

End a table cell

Implements Grantlee::AbstractMarkupBuilder.

◆ endTableHeaderCell()

void Grantlee::PlainTextMarkupBuilder::endTableHeaderCell ( )
overridevirtual

End a table header cell

Implements Grantlee::AbstractMarkupBuilder.

◆ endTableRow()

void Grantlee::PlainTextMarkupBuilder::endTableRow ( )
overridevirtual

End a table row

Implements Grantlee::AbstractMarkupBuilder.

◆ endUnderline()

void Grantlee::PlainTextMarkupBuilder::endUnderline ( )
overridevirtual

Close the underlined element in the markup

Implements Grantlee::AbstractMarkupBuilder.

◆ getResult()

QString Grantlee::PlainTextMarkupBuilder::getResult ( )
overridevirtual

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

Implements Grantlee::AbstractMarkupBuilder.

◆ insertHorizontalRule()

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

Insert a horizontal rule into the markup.

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

Implements Grantlee::AbstractMarkupBuilder.

◆ insertImage()

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

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.