Cutelee 6.1.0
Cutelee::BBCodeBuilder Class Reference

Builder to create BBCode from a QTextDocument. More...

#include <bbcodebuilder.h>

Inheritance diagram for Cutelee::BBCodeBuilder:

Public Member Functions

 BBCodeBuilder ()
void addNewline () override
void appendLiteralText (const QString &text) override
void beginAnchor (const QString &href={}, const QString &name={}) override
void beginEmph () override
void beginFontPointSize (int size) override
void beginForeground (const QBrush &brush) override
void beginList (QTextListFormat::Style type) 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, qreal, const QString &) override
void beginTableRow () override
void beginUnderline () override
void endAnchor () override
void endEmph () override
void endFontPointSize () override
void endForeground () override
void endList () override
void endParagraph () override
void endStrikeout () override
void endStrong () override
void endSubscript () override
void endSuperscript () override
void endUnderline () override
const QString escape (const QString &text) const
QString getResult () override
void insertImage (const QString &src, qreal width, qreal height) override
Public Member Functions inherited from Cutelee::AbstractMarkupBuilder
virtual ~AbstractMarkupBuilder ()
virtual void appendRawText (const QString &text)=0
virtual void beginBackground (const QBrush &brush)=0
virtual void beginFontFamily (const QString &family)=0
virtual void beginHeader (int level)=0
virtual void beginTableCell (const QString &width, int colSpan, int rowSpan)=0
virtual void beginTableHeaderCell (const QString &width, int colSpan, int rowSpan)=0
virtual void endBackground ()=0
virtual void endFontFamily ()=0
virtual void endHeader (int level)=0
virtual void endListItem ()=0
virtual void endTable ()=0
virtual void endTableCell ()=0
virtual void endTableHeaderCell ()=0
virtual void endTableRow ()=0
virtual void insertHorizontalRule (int width=-1)=0

Detailed Description

Definition at line 32 of file bbcodebuilder.h.

Constructor & Destructor Documentation

◆ BBCodeBuilder()

BBCodeBuilder::BBCodeBuilder ( )

Creates a new BBCodeBuilder.

Definition at line 25 of file bbcodebuilder.cpp.

◆ ~BBCodeBuilder()

BBCodeBuilder::~BBCodeBuilder ( )
override

Definition at line 27 of file bbcodebuilder.cpp.

Member Function Documentation

◆ addNewline()

void BBCodeBuilder::addNewline ( )
overridevirtual

Add a newline to the markup.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 94 of file bbcodebuilder.cpp.

◆ appendLiteralText()

void BBCodeBuilder::appendLiteralText ( const QString & text)
overridevirtual

Append the plain text text to the markup

Parameters
textThe text to append.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 154 of file bbcodebuilder.cpp.

References escape().

◆ beginAnchor()

void BBCodeBuilder::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 Cutelee::AbstractMarkupBuilder.

Definition at line 48 of file bbcodebuilder.cpp.

◆ beginEmph()

void BBCodeBuilder::beginEmph ( )
overridevirtual

Begin an emphasised element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 31 of file bbcodebuilder.cpp.

◆ beginFontPointSize()

void BBCodeBuilder::beginFontPointSize ( int size)
overridevirtual

Begin an element of font size size. Note that this size is in pixels, and must be converted before it is suitable for use in BBCode.

Parameters
sizeThe size of font to begin.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 57 of file bbcodebuilder.cpp.

References QString::number().

◆ beginForeground()

void BBCodeBuilder::beginForeground ( const QBrush & brush)
overridevirtual

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

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 37 of file bbcodebuilder.cpp.

References QBrush::color(), and QColor::name().

◆ beginList()

void BBCodeBuilder::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 Cutelee::AbstractMarkupBuilder.

Definition at line 103 of file bbcodebuilder.cpp.

References QTextListFormat::ListCircle, QTextListFormat::ListDecimal, QTextListFormat::ListDisc, QTextListFormat::ListLowerAlpha, QTextListFormat::ListSquare, and QTextListFormat::ListUpperAlpha.

◆ beginListItem()

void BBCodeBuilder::beginListItem ( )
overridevirtual

Begin a new list item in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 128 of file bbcodebuilder.cpp.

◆ beginParagraph()

void BBCodeBuilder::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 Cutelee::AbstractMarkupBuilder.

Definition at line 66 of file bbcodebuilder.cpp.

References Qt::AlignHCenter, Qt::Alignment, and Qt::AlignRight.

◆ beginStrikeout()

void BBCodeBuilder::beginStrikeout ( )
overridevirtual

Begin a struck out element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 35 of file bbcodebuilder.cpp.

◆ beginStrong()

void BBCodeBuilder::beginStrong ( )
overridevirtual

Begin a bold element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 29 of file bbcodebuilder.cpp.

◆ beginSubscript()

void BBCodeBuilder::beginSubscript ( )
overridevirtual

Begin a subscript element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 140 of file bbcodebuilder.cpp.

◆ beginSuperscript()

void BBCodeBuilder::beginSuperscript ( )
overridevirtual

Begin a superscript element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 130 of file bbcodebuilder.cpp.

◆ beginTable()

void BBCodeBuilder::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 Cutelee::AbstractMarkupBuilder.

Definition at line 144 of file bbcodebuilder.cpp.

◆ beginTableRow()

void BBCodeBuilder::beginTableRow ( )
overridevirtual

Begin a new table row

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 149 of file bbcodebuilder.cpp.

◆ beginUnderline()

void BBCodeBuilder::beginUnderline ( )
overridevirtual

Begin an underlined element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 33 of file bbcodebuilder.cpp.

◆ endAnchor()

void BBCodeBuilder::endAnchor ( )
overridevirtual

Close the anchor element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 53 of file bbcodebuilder.cpp.

◆ endEmph()

void BBCodeBuilder::endEmph ( )
overridevirtual

Close the emphasised element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 32 of file bbcodebuilder.cpp.

◆ endFontPointSize()

void BBCodeBuilder::endFontPointSize ( )
overridevirtual

End font point size element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 61 of file bbcodebuilder.cpp.

◆ endForeground()

void BBCodeBuilder::endForeground ( )
overridevirtual

Close the decorarated foreground element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 41 of file bbcodebuilder.cpp.

◆ endList()

void BBCodeBuilder::endList ( )
overridevirtual

Close the list.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 126 of file bbcodebuilder.cpp.

◆ endParagraph()

void BBCodeBuilder::endParagraph ( )
overridevirtual

Close the paragraph in the markup.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 82 of file bbcodebuilder.cpp.

References Qt::AlignHCenter, Qt::AlignLeft, and Qt::AlignRight.

◆ endStrikeout()

void BBCodeBuilder::endStrikeout ( )
overridevirtual

Close the struck out element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 36 of file bbcodebuilder.cpp.

◆ endStrong()

void BBCodeBuilder::endStrong ( )
overridevirtual

Close the bold element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 30 of file bbcodebuilder.cpp.

◆ endSubscript()

void BBCodeBuilder::endSubscript ( )
overridevirtual

End subscript element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 142 of file bbcodebuilder.cpp.

◆ endSuperscript()

void BBCodeBuilder::endSuperscript ( )
overridevirtual

End superscript element

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 135 of file bbcodebuilder.cpp.

◆ endUnderline()

void BBCodeBuilder::endUnderline ( )
overridevirtual

Close the underlined element in the markup

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 34 of file bbcodebuilder.cpp.

◆ escape()

const QString BBCodeBuilder::escape ( const QString & text) const

Escapes text appropriately for BBCode.

Definition at line 159 of file bbcodebuilder.cpp.

References QString::contains().

Referenced by appendLiteralText().

◆ getResult()

QString BBCodeBuilder::getResult ( )
overridevirtual

Return the fully marked up result of the building process.

This may contain metadata etc, such as a head element in html.

Returns
The fully marked up text.

Implements Cutelee::AbstractMarkupBuilder.

Definition at line 167 of file bbcodebuilder.cpp.

References QString::clear().

◆ insertImage()

void BBCodeBuilder::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 Cutelee::AbstractMarkupBuilder.

Definition at line 96 of file bbcodebuilder.cpp.