QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgstextblock.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextblock.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 QGSTEXTBLOCK_H
17#define QGSTEXTBLOCK_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgstextfragment.h"
22#include "qgstextblockformat.h"
23#include "qgsstringutils.h"
24#include <QVector>
25
36class CORE_EXPORT QgsTextBlock
37{
38
39 public:
40
44 QgsTextBlock() = default;
45
49 explicit QgsTextBlock( const QgsTextFragment &fragment );
50
59 static QgsTextBlock fromPlainText( const QString &text, const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
60
66 QString toPlainText() const;
67
73 void reserve( int count );
74
78 void append( const QgsTextFragment &fragment );
79
83 void append( QgsTextFragment &&fragment ) SIP_SKIP;
84#ifndef SIP_RUN
85
91 void insert( int index, const QgsTextFragment &fragment );
92
93#else
101 void insert( int index, const QgsTextFragment &fragment );
102 % MethodCode
103 if ( a0 < 0 || a0 > sipCpp->size() )
104 {
105 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
106 sipIsErr = 1;
107 }
108 else
109 {
110 sipCpp->insert( a0, *a1 );
111 }
112 % End
113#endif
114
120 void insert( int index, QgsTextFragment &&fragment ) SIP_SKIP;
121
125 void clear();
126
130 bool empty() const;
131
135 int size() const;
136
144 const QgsTextBlockFormat &blockFormat() const { return mBlockFormat; }
145
153 void setBlockFormat( const QgsTextBlockFormat &format );
154
160 void applyCapitalization( Qgis::Capitalization capitalization );
161
162#ifdef SIP_RUN
163 int __len__() const;
164 % MethodCode
165 sipRes = sipCpp->size();
166 % End
167#endif
168
169#ifndef SIP_RUN
170
174 const QgsTextFragment &at( int index ) const SIP_FACTORY;
175#else
176
182 const QgsTextFragment &at( int index ) const SIP_FACTORY;
183 % MethodCode
184 if ( a0 < 0 || a0 >= sipCpp->size() )
185 {
186 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
187 sipIsErr = 1;
188 }
189 else
190 {
191 sipRes = new QgsTextFragment( sipCpp->at( a0 ) );
192 }
193 % End
194#endif
195
199 QgsTextFragment &operator[]( int index ) SIP_FACTORY;
200#ifdef SIP_RUN
201 % MethodCode
202 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
203 if ( idx < 0 )
204 sipIsErr = 1;
205 else
206 sipRes = new QgsTextFragment( sipCpp->operator[]( idx ) );
207 % End
208#endif
209
210#ifndef SIP_RUN
212 QVector< QgsTextFragment >::const_iterator begin() const;
213 QVector< QgsTextFragment >::const_iterator end() const;
215#endif
216
217 private:
218
219 QVector< QgsTextFragment > mFragments;
220 QgsTextBlockFormat mBlockFormat;
221};
222
223#endif // QGSTEXTBLOCK_H
Capitalization
String capitalization options.
Definition qgis.h:3132
Stores information relating to individual block formatting.
Represents a block of text consisting of one or more QgsTextFragment objects.
const QgsTextBlockFormat & blockFormat() const
Returns the block formatting for the fragment.
QgsTextBlock()=default
Constructor for an empty text block.
Stores information relating to individual character formatting.
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