QGIS API Documentation 3.39.0-Master (47f7b3a4989)
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 "qgsstringutils.h"
23#include <QVector>
24
35class CORE_EXPORT QgsTextBlock
36{
37
38 public:
39
43 QgsTextBlock() = default;
44
48 explicit QgsTextBlock( const QgsTextFragment &fragment );
49
58 static QgsTextBlock fromPlainText( const QString &text, const QgsTextCharacterFormat &format = QgsTextCharacterFormat() );
59
65 QString toPlainText() const;
66
70 void append( const QgsTextFragment &fragment );
71
75 void append( QgsTextFragment &&fragment ) SIP_SKIP;
76
80 void clear();
81
85 bool empty() const;
86
90 int size() const;
91
97 void applyCapitalization( Qgis::Capitalization capitalization );
98
99#ifdef SIP_RUN
100 int __len__() const;
101 % MethodCode
102 sipRes = sipCpp->size();
103 % End
104#endif
105
106#ifndef SIP_RUN
107
111 const QgsTextFragment &at( int index ) const SIP_FACTORY;
112#else
113
119 const QgsTextFragment &at( int index ) const SIP_FACTORY;
120 % MethodCode
121 if ( a0 < 0 || a0 >= sipCpp->size() )
122 {
123 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
124 sipIsErr = 1;
125 }
126 else
127 {
128 sipRes = new QgsTextFragment( sipCpp->at( a0 ) );
129 }
130 % End
131#endif
132
136 QgsTextFragment &operator[]( int index ) SIP_FACTORY;
137#ifdef SIP_RUN
138 % MethodCode
139 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
140 if ( idx < 0 )
141 sipIsErr = 1;
142 else
143 sipRes = new QgsTextFragment( sipCpp->operator[]( idx ) );
144 % End
145#endif
146
147#ifndef SIP_RUN
149 QVector< QgsTextFragment >::const_iterator begin() const;
150 QVector< QgsTextFragment >::const_iterator end() const;
152#endif
153
154 private:
155
156 QVector< QgsTextFragment > mFragments;
157
158};
159
160#endif // QGSTEXTBLOCK_H
Capitalization
String capitalization options.
Definition qgis.h:2889
Represents a block of text consisting of one or more QgsTextFragment objects.
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