QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgstextdocument.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextdocument.h
3 -----------------
4 begin : May 2020
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEXTDOCUMENT_H
17#define QGSTEXTDOCUMENT_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgsstringutils.h"
22#include "qgstextblock.h"
23
24#include <QVector>
25#include <QSizeF>
26
27class QgsTextFragment;
28class QgsTextFormat;
29
40class CORE_EXPORT QgsTextDocument
41{
42
43 public:
44
47
51 explicit QgsTextDocument( const QgsTextBlock &block );
52
56 explicit QgsTextDocument( const QgsTextFragment &fragment );
57
64 static QgsTextDocument fromPlainText( const QStringList &lines );
65
72 static QgsTextDocument fromHtml( const QStringList &lines );
73
81 static QgsTextDocument fromTextAndFormat( const QStringList &lines, const QgsTextFormat &format );
82
86 void append( const QgsTextBlock &block );
87
91 void append( QgsTextBlock &&block ) SIP_SKIP;
92
93#ifndef SIP_RUN
94
100 void insert( int index, const QgsTextBlock &block );
101#else
102
110 void insert( int index, const QgsTextBlock &block );
111 % MethodCode
112 if ( a0 < 0 || a0 > sipCpp->size() )
113 {
114 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
115 sipIsErr = 1;
116 }
117 else
118 {
119 sipCpp->insert( a0, *a1 );
120 }
121 % End
122#endif
123
129 void insert( int index, QgsTextBlock &&block ) SIP_SKIP;
130
134 void reserve( int count );
135
136#ifndef SIP_RUN
137
141 const QgsTextBlock &at( int index ) const SIP_FACTORY;
142#else
143
149 const QgsTextBlock &at( int index ) const SIP_FACTORY;
150 % MethodCode
151 if ( a0 < 0 || a0 >= sipCpp->size() )
152 {
153 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
154 sipIsErr = 1;
155 }
156 else
157 {
158 sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
159 }
160 % End
161#endif
162
166 QgsTextBlock &operator[]( int index ) SIP_FACTORY;
167#ifdef SIP_RUN
168 % MethodCode
169 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
170 if ( idx < 0 )
171 sipIsErr = 1;
172 else
173 sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
174 % End
175#endif
176
180 int size() const;
181
182#ifdef SIP_RUN
183 int __len__() const;
184 % MethodCode
185 sipRes = sipCpp->size();
186 % End
187#endif
188
192 QStringList toPlainText() const;
193
203 void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
204
210 void applyCapitalization( Qgis::Capitalization capitalization );
211
217 bool hasBackgrounds() const;
218
219#ifndef SIP_RUN
221 QVector< QgsTextBlock >::const_iterator begin() const;
222 QVector< QgsTextBlock >::const_iterator end() const;
224#endif
225
226 private:
227
228 QVector< QgsTextBlock > mBlocks;
229
230};
231
232#endif // QGSTEXTDOCUMENT_H
Capitalization
String capitalization options.
Definition qgis.h:3185
Represents a block of text consisting of one or more QgsTextFragment objects.
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Stores a fragment of document along with formatting overrides to be used when rendering the fragment.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76