Grantlee  5.1.0
bbcodebuilder.h
1 /*
2  This file is part of the Grantlee template system.
3 
4  Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef GRANTLEE_BBCODEBUILDER_H
22 #define GRANTLEE_BBCODEBUILDER_H
23 
24 #include "abstractmarkupbuilder.h"
25 
26 namespace Grantlee
27 {
28 
33 {
34 public:
38  BBCodeBuilder();
39 
40  ~BBCodeBuilder() override;
41 
42  void beginStrong() override;
43  void endStrong() override;
44  void beginEmph() override;
45  void endEmph() override;
46  void beginUnderline() override;
47  void endUnderline() override;
48  void beginStrikeout() override;
49  void endStrikeout() override;
50  void beginForeground(const QBrush &brush) override;
51  void endForeground() override;
52 
53  // Background colour not supported by BBCode.
54 
55  void beginAnchor(const QString &href = QString(),
56  const QString &name = QString()) override;
57  void endAnchor() override;
58 
59  // Font family not supported by BBCode.
60 
68  void beginFontPointSize(int size) override;
69  void endFontPointSize() override;
70 
71  void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0,
72  qreal bottom = 0.0, qreal left = 0.0,
73  qreal right = 0.0) override;
74 
75  void endParagraph() override;
76  void addNewline() override;
77 
78  void insertImage(const QString &src, qreal width, qreal height) override;
79 
80  void beginList(QTextListFormat::Style type) override;
81 
82  void endList() override;
83 
84  void beginListItem() override;
85 
86  void beginSuperscript() override;
87 
88  void endSuperscript() override;
89 
90  void beginSubscript() override;
91 
92  void endSubscript() override;
93 
94  void beginTable(qreal, qreal, const QString &) override;
95 
96  void beginTableRow() override;
97 
98  void appendLiteralText(const QString &text) override;
99 
103  const QString escape(const QString &text) const;
104 
105  QString getResult() override;
106 
107 private:
108  QList<QTextListFormat::Style> m_currentListItemStyles;
109 
110  QString m_text;
111 
112  Qt::Alignment m_currentAlignment;
113 };
114 }
115 
116 #endif
Builder to create BBCode from a QTextDocument.
Definition: bbcodebuilder.h:32
void beginSuperscript() override
void beginForeground(const QBrush &brush) override
void beginTableRow() 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 insertImage(const QString &src, qreal width, qreal height) override
void endForeground() override
void appendLiteralText(const QString &text) override
QString getResult() override
void beginEmph() override
void endList() override
void endStrikeout() override
void beginFontPointSize(int size) override
void endParagraph() override
void beginStrikeout() override
void beginAnchor(const QString &href=QString(), const QString &name=QString()) override
void beginStrong() override
void beginSubscript() override
void endAnchor() override
void beginListItem() override
void endSubscript() override
void endFontPointSize() override
void beginUnderline() override
void endEmph() override
void endSuperscript() override
void addNewline() override
const QString escape(const QString &text) const
void endStrong() override
void beginTable(qreal, qreal, const QString &) override
The AbstractMarkupBuilder class serves as a base class for creating marked up plain text output...
void beginList(QTextListFormat::Style type) override
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7
void endUnderline() override