QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
55 QString toPlainText() const;
56
60 void append( const QgsTextFragment &fragment );
61
65 void append( QgsTextFragment &&fragment ) SIP_SKIP;
66
70 void clear();
71
75 bool empty() const;
76
80 int size() const;
81
87 void applyCapitalization( Qgis::Capitalization capitalization );
88
89#ifdef SIP_RUN
90 int __len__() const;
91 % MethodCode
92 sipRes = sipCpp->size();
93 % End
94#endif
95
96#ifndef SIP_RUN
97
101 const QgsTextFragment &at( int index ) const SIP_FACTORY;
102#else
103
109 const QgsTextFragment &at( int index ) const SIP_FACTORY;
110 % MethodCode
111 if ( a0 < 0 || a0 >= sipCpp->size() )
112 {
113 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
114 sipIsErr = 1;
115 }
116 else
117 {
118 sipRes = new QgsTextFragment( sipCpp->at( a0 ) );
119 }
120 % End
121#endif
122
126 QgsTextFragment &operator[]( int index ) SIP_FACTORY;
127#ifdef SIP_RUN
128 % MethodCode
129 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
130 if ( idx < 0 )
131 sipIsErr = 1;
132 else
133 sipRes = new QgsTextFragment( sipCpp->operator[]( idx ) );
134 % End
135#endif
136
137#ifndef SIP_RUN
139 QVector< QgsTextFragment >::const_iterator begin() const;
140 QVector< QgsTextFragment >::const_iterator end() const;
142#endif
143
144 private:
145
146 QVector< QgsTextFragment > mFragments;
147
148};
149
150#endif // QGSTEXTBLOCK_H
Capitalization
String capitalization options.
Definition: qgis.h:2747
Represents a block of text consisting of one or more QgsTextFragment objects.
Definition: qgstextblock.h:36
QgsTextBlock()=default
Constructor for an empty text block.
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