QGIS API Documentation 3.39.0-Master (d85f3c2a281)
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
71 void append( const QgsTextFragment &fragment );
72
76 void append( QgsTextFragment &&fragment ) SIP_SKIP;
77
81 void clear();
82
86 bool empty() const;
87
91 int size() const;
92
100 const QgsTextBlockFormat &blockFormat() const { return mBlockFormat; }
101
109 void setBlockFormat( const QgsTextBlockFormat &format );
110
116 void applyCapitalization( Qgis::Capitalization capitalization );
117
118#ifdef SIP_RUN
119 int __len__() const;
120 % MethodCode
121 sipRes = sipCpp->size();
122 % End
123#endif
124
125#ifndef SIP_RUN
126
130 const QgsTextFragment &at( int index ) const SIP_FACTORY;
131#else
132
138 const QgsTextFragment &at( int index ) const SIP_FACTORY;
139 % MethodCode
140 if ( a0 < 0 || a0 >= sipCpp->size() )
141 {
142 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
143 sipIsErr = 1;
144 }
145 else
146 {
147 sipRes = new QgsTextFragment( sipCpp->at( a0 ) );
148 }
149 % End
150#endif
151
155 QgsTextFragment &operator[]( int index ) SIP_FACTORY;
156#ifdef SIP_RUN
157 % MethodCode
158 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
159 if ( idx < 0 )
160 sipIsErr = 1;
161 else
162 sipRes = new QgsTextFragment( sipCpp->operator[]( idx ) );
163 % End
164#endif
165
166#ifndef SIP_RUN
168 QVector< QgsTextFragment >::const_iterator begin() const;
169 QVector< QgsTextFragment >::const_iterator end() const;
171#endif
172
173 private:
174
175 QVector< QgsTextFragment > mFragments;
176 QgsTextBlockFormat mBlockFormat;
177};
178
179#endif // QGSTEXTBLOCK_H
Capitalization
String capitalization options.
Definition qgis.h:3130
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 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