QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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_core.h"
20#include "qgis_sip.h"
21#include "qgsstringutils.h"
22#include "qgstextblock.h"
23
24#include <QSizeF>
25#include <QVector>
26
27class QgsTextFragment;
28class QgsTextFormat;
29
40class CORE_EXPORT QgsTextDocument
41{
42
43 public:
44
46 QgsTextDocument( const QgsTextDocument &other );
50
52
56 explicit QgsTextDocument( const QgsTextBlock &block );
57
61 explicit QgsTextDocument( const QgsTextFragment &fragment );
62
69 static QgsTextDocument fromPlainText( const QStringList &lines );
70
77 static QgsTextDocument fromHtml( const QStringList &lines );
78
86 static QgsTextDocument fromTextAndFormat( const QStringList &lines, const QgsTextFormat &format );
87
91 void append( const QgsTextBlock &block );
92
96 void append( QgsTextBlock &&block ) SIP_SKIP;
97
98#ifndef SIP_RUN
99
105 void insert( int index, const QgsTextBlock &block );
106#else
107
115 void insert( int index, const QgsTextBlock &block );
116 % MethodCode
117 if ( a0 < 0 || a0 > sipCpp->size() )
118 {
119 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
120 sipIsErr = 1;
121 }
122 else
123 {
124 sipCpp->insert( a0, *a1 );
125 }
126 % End
127#endif
128
134 void insert( int index, QgsTextBlock &&block ) SIP_SKIP;
135
139 void reserve( int count );
140
141#ifndef SIP_RUN
142
146 const QgsTextBlock &at( int index ) const SIP_FACTORY;
147#else
148
154 const QgsTextBlock &at( int index ) const SIP_FACTORY;
155 % MethodCode
156 if ( a0 < 0 || a0 >= sipCpp->size() )
157 {
158 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
159 sipIsErr = 1;
160 }
161 else
162 {
163 sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
164 }
165 % End
166#endif
167
171 QgsTextBlock &operator[]( int index ) SIP_FACTORY;
172#ifdef SIP_RUN
173 % MethodCode
174 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
175 if ( idx < 0 )
176 sipIsErr = 1;
177 else
178 sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
179 % End
180#endif
181
185 int size() const;
186
187#ifdef SIP_RUN
188 int __len__() const;
189 % MethodCode
190 sipRes = sipCpp->size();
191 % End
192#endif
193
197 QStringList toPlainText() const;
198
208 void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
209
215 void applyCapitalization( Qgis::Capitalization capitalization );
216
222 bool hasBackgrounds() const;
223
224#ifndef SIP_RUN
226 QVector< QgsTextBlock >::const_iterator begin() const;
227 QVector< QgsTextBlock >::const_iterator end() const;
229#endif
230
231 private:
232
233 QVector< QgsTextBlock > mBlocks;
234
235};
236
237#endif // QGSTEXTDOCUMENT_H
Capitalization
String capitalization options.
Definition qgis.h:3389
Represents a block of text consisting of one or more QgsTextFragment objects.
QgsTextDocument & operator=(const QgsTextDocument &other)
static QgsTextDocument fromHtml(const QStringList &lines)
Constructor for QgsTextDocument consisting of a set of HTML formatted lines.
static QgsTextDocument fromPlainText(const QStringList &lines)
Constructor for QgsTextDocument consisting of a set of plain text lines.
void append(const QgsTextBlock &block)
Appends a block to the document.
void insert(int index, const QgsTextBlock &block)
Inserts a block into the document, at the specified index.
static QgsTextDocument fromTextAndFormat(const QStringList &lines, const QgsTextFormat &format)
Constructor for QgsTextDocument consisting of a set of lines, respecting settings from a text format.
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:134
#define SIP_FACTORY
Definition qgis_sip.h:84