QGIS API Documentation 3.38.0-Grenoble (exported)
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
77 void append( const QgsTextBlock &block );
78
82 void append( QgsTextBlock &&block ) SIP_SKIP;
83
87 void reserve( int count );
88
89#ifndef SIP_RUN
90
94 const QgsTextBlock &at( int index ) const SIP_FACTORY;
95#else
96
102 const QgsTextBlock &at( int index ) const SIP_FACTORY;
103 % MethodCode
104 if ( a0 < 0 || a0 >= sipCpp->size() )
105 {
106 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
107 sipIsErr = 1;
108 }
109 else
110 {
111 sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
112 }
113 % End
114#endif
115
119 QgsTextBlock &operator[]( int index ) SIP_FACTORY;
120#ifdef SIP_RUN
121 % MethodCode
122 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
123 if ( idx < 0 )
124 sipIsErr = 1;
125 else
126 sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
127 % End
128#endif
129
133 int size() const;
134
135#ifdef SIP_RUN
136 int __len__() const;
137 % MethodCode
138 sipRes = sipCpp->size();
139 % End
140#endif
141
145 QStringList toPlainText() const;
146
156 void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
157
163 void applyCapitalization( Qgis::Capitalization capitalization );
164
165#ifndef SIP_RUN
167 QVector< QgsTextBlock >::const_iterator begin() const;
168 QVector< QgsTextBlock >::const_iterator end() const;
170#endif
171
172 private:
173
174 QVector< QgsTextBlock > mBlocks;
175
176};
177
178#endif // QGSTEXTDOCUMENT_H
Capitalization
String capitalization options.
Definition qgis.h:2884
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 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