QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
textrenderer
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_core.h"
20
#include "
qgis_sip.h
"
21
#include "
qgsstringutils.h
"
22
#include "
qgstextblockformat.h
"
23
#include "
qgstextfragment.h
"
24
25
#include <QVector>
26
37
class
CORE_EXPORT
QgsTextBlock
38
{
39
public
:
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
72
void
reserve
(
int
count );
73
77
void
append
(
const
QgsTextFragment
&fragment );
78
82
void
append
(
QgsTextFragment
&&fragment )
SIP_SKIP
;
83
#ifndef SIP_RUN
84
90
void
insert
(
int
index,
const
QgsTextFragment
&fragment );
91
92
#else
93
// clang-format off
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
// clang-format on
114
#endif
115
121
void
insert(
int
index, QgsTextFragment &&fragment )
SIP_SKIP
;
122
126
void
clear();
127
131
bool
empty()
const
;
132
136
int
size()
const
;
137
145
const
QgsTextBlockFormat
&
blockFormat
()
const
{
return
mBlockFormat; }
146
154
void
setBlockFormat(
const
QgsTextBlockFormat
&format );
155
161
void
applyCapitalization(
Qgis::Capitalization
capitalization );
162
168
bool
hasBackgrounds()
const
;
169
170
#ifdef SIP_RUN
171
// clang-format off
172
int
__len__()
const
;
173
% MethodCode
174
sipRes = sipCpp->size();
175
% End
176
// clang-format on
177
#endif
178
179
#ifndef SIP_RUN
180
184
const
QgsTextFragment
&at(
int
index )
const
SIP_FACTORY
;
185
#else
186
// clang-format off
187
193
const
QgsTextFragment
&at(
int
index )
const
SIP_FACTORY
;
194
% MethodCode
195
if
( a0 < 0 || a0 >= sipCpp->size() )
196
{
197
PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
198
sipIsErr = 1;
199
}
200
else
201
{
202
sipRes =
new
QgsTextFragment( sipCpp->at( a0 ) );
203
}
204
% End
205
// clang-format on
206
#endif
207
211
QgsTextFragment &operator[](
int
index )
SIP_FACTORY
;
212
#ifdef SIP_RUN
213
// clang-format off
214
% MethodCode
215
SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
216
if
( idx < 0 )
217
sipIsErr = 1;
218
else
219
sipRes =
new
QgsTextFragment( sipCpp->operator[]( idx ) );
220
% End
221
// clang-format on
222
#endif
223
224
#ifndef SIP_RUN
226
QVector< QgsTextFragment >::const_iterator begin()
const
;
227
QVector< QgsTextFragment >::const_iterator end()
const
;
229
#endif
230
231
private
:
232
QVector< QgsTextFragment > mFragments;
233
QgsTextBlockFormat mBlockFormat;
234
};
235
236
#endif
// QGSTEXTBLOCK_H
Qgis::Capitalization
Capitalization
String capitalization options.
Definition
qgis.h:3627
QgsTextBlockFormat
Stores information relating to individual block formatting.
Definition
qgstextblockformat.h:44
QgsTextBlock::insert
void insert(int index, const QgsTextFragment &fragment)
Inserts a fragment into the block, at the specified index.
Definition
qgstextblock.cpp:80
QgsTextBlock::toPlainText
QString toPlainText() const
Converts the block to plain text.
Definition
qgstextblock.cpp:55
QgsTextBlock::blockFormat
const QgsTextBlockFormat & blockFormat() const
Returns the block formatting for the fragment.
Definition
qgstextblock.h:145
QgsTextBlock::fromPlainText
static QgsTextBlock fromPlainText(const QString &text, const QgsTextCharacterFormat &format=QgsTextCharacterFormat())
Constructor for QgsTextBlock consisting of a plain text, and optional character format.
Definition
qgstextblock.cpp:27
QgsTextBlock::QgsTextBlock
QgsTextBlock()=default
Constructor for an empty text block.
QgsTextBlock::reserve
void reserve(int count)
Reserves the specified count of fragments for optimised fragment appending.
Definition
qgstextblock.cpp:65
QgsTextBlock::append
void append(const QgsTextFragment &fragment)
Appends a fragment to the block.
Definition
qgstextblock.cpp:70
QgsTextCharacterFormat
Stores information relating to individual character formatting.
Definition
qgstextcharacterformat.h:44
QgsTextFragment
Stores a fragment of document along with formatting overrides to be used when rendering the fragment.
Definition
qgstextfragment.h:42
qgis_sip.h
SIP_SKIP
#define SIP_SKIP
Definition
qgis_sip.h:138
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
qgsstringutils.h
qgstextblockformat.h
qgstextfragment.h
Generated on
for QGIS API Documentation by
1.17.0