QGIS API Documentation 3.27.0-Master (9c08adf5ef)
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
26class QgsTextFragment;
27
38class CORE_EXPORT QgsTextDocument
39{
40
41 public:
42
45
49 explicit QgsTextDocument( const QgsTextBlock &block );
50
54 explicit QgsTextDocument( const QgsTextFragment &fragment );
55
59 static QgsTextDocument fromPlainText( const QStringList &lines );
60
64 static QgsTextDocument fromHtml( const QStringList &lines );
65
69 void append( const QgsTextBlock &block );
70
74 void append( QgsTextBlock &&block ) SIP_SKIP;
75
79 void reserve( int count );
80
81#ifndef SIP_RUN
82
86 const QgsTextBlock &at( int index ) const SIP_FACTORY;
87#else
88
94 const QgsTextBlock &at( int index ) const SIP_FACTORY;
95 % MethodCode
96 if ( a0 < 0 || a0 >= sipCpp->size() )
97 {
98 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
99 sipIsErr = 1;
100 }
101 else
102 {
103 sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
104 }
105 % End
106#endif
107
111 QgsTextBlock &operator[]( int index ) SIP_FACTORY;
112#ifdef SIP_RUN
113 % MethodCode
114 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
115 if ( idx < 0 )
116 sipIsErr = 1;
117 else
118 sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
119 % End
120#endif
121
125 int size() const;
126
127#ifdef SIP_RUN
128 int __len__() const;
129 % MethodCode
130 sipRes = sipCpp->size();
131 % End
132#endif
133
137 QStringList toPlainText() const;
138
148 void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
149
155 void applyCapitalization( Qgis::Capitalization capitalization );
156
157#ifndef SIP_RUN
159 QVector< QgsTextBlock >::const_iterator begin() const;
160 QVector< QgsTextBlock >::const_iterator end() const;
162#endif
163
164 private:
165
166 QVector< QgsTextBlock > mBlocks;
167
168};
169
170#endif // QGSTEXTDOCUMENT_H
Capitalization
String capitalization options.
Definition: qgis.h:1653
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.
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