QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
61 static QgsTextDocument fromPlainText( const QStringList &lines );
62
66 static QgsTextDocument fromHtml( const QStringList &lines );
67
71 void append( const QgsTextBlock &block );
72
76 void append( QgsTextBlock &&block ) SIP_SKIP;
77
81 void reserve( int count );
82
83#ifndef SIP_RUN
84
88 const QgsTextBlock &at( int index ) const SIP_FACTORY;
89#else
90
96 const QgsTextBlock &at( int index ) const SIP_FACTORY;
97 % MethodCode
98 if ( a0 < 0 || a0 >= sipCpp->size() )
99 {
100 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
101 sipIsErr = 1;
102 }
103 else
104 {
105 sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
106 }
107 % End
108#endif
109
113 QgsTextBlock &operator[]( int index ) SIP_FACTORY;
114#ifdef SIP_RUN
115 % MethodCode
116 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
117 if ( idx < 0 )
118 sipIsErr = 1;
119 else
120 sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
121 % End
122#endif
123
127 int size() const;
128
129#ifdef SIP_RUN
130 int __len__() const;
131 % MethodCode
132 sipRes = sipCpp->size();
133 % End
134#endif
135
139 QStringList toPlainText() const;
140
150 void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
151
157 void applyCapitalization( Qgis::Capitalization capitalization );
158
159#ifndef SIP_RUN
161 QVector< QgsTextBlock >::const_iterator begin() const;
162 QVector< QgsTextBlock >::const_iterator end() const;
164#endif
165
166 private:
167
168 QVector< QgsTextBlock > mBlocks;
169
170};
171
172#endif // QGSTEXTDOCUMENT_H
Capitalization
String capitalization options.
Definition: qgis.h:1762
Represents a block of text consisting of one or more QgsTextFragment objects.
Definition: qgstextblock.h:36
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
Stores a fragment of text 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