Grantlee  0.4.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:
35 
39  BBCodeBuilder();
40 
41  virtual ~BBCodeBuilder();
42 
43  /* reimp */ void beginStrong();
44  /* reimp */ void endStrong();
45  /* reimp */ void beginEmph();
46  /* reimp */ void endEmph();
47  /* reimp */ void beginUnderline();
48  /* reimp */ void endUnderline();
49  /* reimp */ void beginStrikeout();
50  /* reimp */ void endStrikeout();
51  /* reimp */ void beginForeground( const QBrush &brush );
52  /* reimp */ void endForeground();
53 
54  // Background colour not supported by BBCode.
55 
56  /* reimp */ void beginAnchor( const QString &href = QString(), const QString &name = QString() );
57  /* reimp */ void endAnchor();
58 
59  // Font family not supported by BBCode.
60 
66  /* reimp */ void beginFontPointSize( int size );
67  /* reimp */ void endFontPointSize();
68 
69  /* reimp */ void beginParagraph( Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0, qreal bottom = 0.0, qreal left = 0.0, qreal right = 0.0 );
70 
71  /* reimp */ void endParagraph();
72  /* reimp */ void addNewline();
73 
74  /* reimp */ void insertImage( const QString &src, qreal width, qreal height );
75 
76  /* reimp */ void beginList( QTextListFormat::Style type );
77 
78  /* reimp */ void endList();
79 
80 
81  /* reimp */ void beginListItem();
82 
83  /* reimp */ void beginSuperscript();
84 
85  /* reimp */ void endSuperscript();
86 
87  /* reimp */ void beginSubscript();
88 
89  /* reimp */ void endSubscript();
90 
91 
92  /* reimp */ void beginTable( qreal, qreal, const QString & );
93 
94  /* reimp */ void beginTableRow();
95 
96 
97  /* reimp */ void appendLiteralText( const QString &text );
98 
102  const QString escape( const QString &text ) const;
103 
104  /* reimp */ QString getResult();
105 
106 private:
107  QList<QTextListFormat::Style> m_currentListItemStyles;
108 
109  QString m_text;
110 
111  Qt::Alignment m_currentAlignment;
112 
113 };
114 
115 }
116 
117 #endif
Builder to create BBCode from a QTextDocument.
Definition: bbcodebuilder.h:32
void insertImage(const QString &src, qreal width, qreal height)
void beginAnchor(const QString &href=QString(), const QString &name=QString())
void beginTable(qreal, qreal, const QString &)
void beginFontPointSize(int size)
void appendLiteralText(const QString &text)
void beginList(QTextListFormat::Style type)
const QString escape(const QString &text) const
void beginParagraph(Qt::Alignment a=Qt::AlignLeft, qreal top=0.0, qreal bottom=0.0, qreal left=0.0, qreal right=0.0)
The AbstractMarkupBuilder class serves as a base class for creating marked up plain text output...
void beginForeground(const QBrush &brush)
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7