~ubuntu-branches/ubuntu/trusty/grantlee/trusty

« back to all changes in this revision

Viewing changes to gui/plaintextmarkupbuilder.h

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2010-06-11 23:41:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100611234145-oas7rhdrbwy8j55c
Tags: upstream-0.1.1
ImportĀ upstreamĀ versionĀ 0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 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
  Library 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_PLAINTEXTMARKUPBUILDER_H
 
22
#define GRANTLEE_PLAINTEXTMARKUPBUILDER_H
 
23
 
 
24
 
 
25
#ifdef Q_OS_WIN
 
26
#pragma warning( disable : 4250 )
 
27
#endif
 
28
 
 
29
#define LETTERSINALPHABET 26
 
30
#define DIGITSOFFSET 10
 
31
 
 
32
#include "abstractmarkupbuilder.h"
 
33
#include "markupdirector.h"
 
34
 
 
35
#include "grantlee_gui_export.h"
 
36
 
 
37
class QBrush;
 
38
 
 
39
namespace Grantlee
 
40
{
 
41
 
 
42
class PlainTextMarkupBuilderPrivate;
 
43
 
 
44
/// @headerfile plaintextmarkupbuilder.h grantlee/plaintextmarkupbuilder.h
 
45
 
 
46
/**
 
47
  @brief The PlainTextHTMLMarkupBuilder creates a simple marked up plain text document.
 
48
 
 
49
  This class creates a simple plain text markup.
 
50
 
 
51
  Text that may be represented as
 
52
 
 
53
  @code
 
54
    A paragraph with <b>bold</b> text, <i>italic</i> text, and <u>underlined</u> text.
 
55
  @endcode
 
56
 
 
57
  would be output as
 
58
 
 
59
  @code
 
60
    A paragraph with *bold* text /italic/ text, and _underlined_ text.
 
61
  @endcode
 
62
 
 
63
  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.
 
64
 
 
65
  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.
 
66
  eg:
 
67
 
 
68
  @code
 
69
    A. One
 
70
    B. Two
 
71
      o Three
 
72
      o Four
 
73
        \* Five
 
74
        \* Six
 
75
    C. Seven
 
76
  @endcode
 
77
 
 
78
  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.
 
79
 
 
80
  Eg,
 
81
  @code
 
82
    Here is a link to <a href="http://www.kde.org">KDE</a> and the <a href="http://pim.kde.org">KDEPIM project</a>.
 
83
  @endcode
 
84
 
 
85
  becomes:
 
86
 
 
87
  @code
 
88
    Here is a link to KDE[1], and the KDEPIM project[2].
 
89
 
 
90
    ---- References ----
 
91
    [1] http://www.kde.org
 
92
    [2] http://pim.kde.org
 
93
  @endcode
 
94
 
 
95
  @author Stephen Kelly <steveire@gmail.com>
 
96
*/
 
97
class GRANTLEE_GUI_EXPORT PlainTextMarkupBuilder : virtual public AbstractMarkupBuilder
 
98
{
 
99
public:
 
100
  /** Construct a new PlainTextHTMLMarkupBuilder. */
 
101
  PlainTextMarkupBuilder();
 
102
 
 
103
  virtual ~PlainTextMarkupBuilder();
 
104
 
 
105
  /* reimp */ void beginStrong();
 
106
  /* reimp */ void endStrong();
 
107
  /* reimp */ void beginEmph();
 
108
  /* reimp */ void endEmph();
 
109
  /* reimp */ void beginUnderline();
 
110
  /* reimp */ void endUnderline();
 
111
  /* reimp */ void beginStrikeout();
 
112
  /* reimp */ void endStrikeout();
 
113
 
 
114
  /* reimp */ void beginAnchor( const QString &href = QString(), const QString &name = QString() );
 
115
 
 
116
  /* reimp */ void endAnchor();
 
117
 
 
118
  /* reimp */ void beginForeground( const QBrush &brush );
 
119
 
 
120
  /* reimp */ void endForeground();
 
121
 
 
122
  /* reimp */ void beginBackground( const QBrush &brush );
 
123
 
 
124
  /* reimp */ void endBackground();
 
125
 
 
126
  /* reimp */ void beginFontFamily( const QString &family );
 
127
 
 
128
  /* reimp */ void endFontFamily();
 
129
 
 
130
  /* reimp */ void beginFontPointSize( int size );
 
131
 
 
132
  /* reimp */ void endFontPointSize();
 
133
 
 
134
  /* reimp */ void beginParagraph( Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0, qreal bottom = 0.0, qreal left = 0.0, qreal right = 0.0 );
 
135
 
 
136
  /* reimp */ void endParagraph();
 
137
  /* reimp */ void addNewline();
 
138
 
 
139
  /* reimp */ void insertHorizontalRule( int width = -1 );
 
140
 
 
141
  /* reimp */ void insertImage( const QString &src, qreal width, qreal height );
 
142
 
 
143
  /* reimp */ void beginList( QTextListFormat::Style style );
 
144
 
 
145
  /* reimp */ void endList();
 
146
 
 
147
  /* reimp */ void beginListItem();
 
148
 
 
149
  /* reimp */ void endListItem();
 
150
 
 
151
  /* reimp */ void beginSuperscript();
 
152
 
 
153
  /* reimp */ void endSuperscript();
 
154
 
 
155
  /* reimp */ void beginSubscript();
 
156
 
 
157
  /* reimp */ void endSubscript();
 
158
 
 
159
  /* reimp */ void beginTable( qreal cellpadding, qreal cellspacing, const QString &width );
 
160
 
 
161
  /* reimp */ void beginTableRow();
 
162
 
 
163
  /* reimp */ void beginTableHeaderCell( const QString &width, int colSpan, int rowSpan );
 
164
 
 
165
  /* reimp */ void beginTableCell( const QString &width, int colSpan, int rowSpan );
 
166
 
 
167
  /* reimp */ void endTable();
 
168
 
 
169
  /* reimp */ void endTableRow();
 
170
 
 
171
  /* reimp */ void endTableHeaderCell();
 
172
 
 
173
  /* reimp */ void endTableCell();
 
174
 
 
175
  /* reimp */ void beginHeader( int level );
 
176
 
 
177
  /* reimp */ void endHeader( int level );
 
178
 
 
179
  /* reimp */ void appendLiteralText( const QString &text );
 
180
 
 
181
  /* reimp */ void appendRawText( const QString &text );
 
182
 
 
183
  /**
 
184
    Adds a reference to @p reference to the internal list of references in the document.
 
185
  */
 
186
  int addReference( const QString &reference );
 
187
 
 
188
  /**
 
189
    Returns the finalised plain text markup, including references at the end.
 
190
  */
 
191
  /* reimp */ QString getResult();
 
192
 
 
193
private:
 
194
  PlainTextMarkupBuilderPrivate * const d_ptr;
 
195
  Q_DECLARE_PRIVATE( PlainTextMarkupBuilder )
 
196
 
 
197
};
 
198
 
 
199
}
 
200
 
 
201
#endif