QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgstextblock.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstextblock.cpp
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#include "qgstextblock.h"
17#include "qgstextfragment.h"
18
19#include <QSizeF>
20
22{
23 mFragments.append( fragment );
24}
25
27{
28 QString res;
29 for ( const QgsTextFragment &fragment : mFragments )
30 {
31 res.append( fragment.text() );
32 }
33 return res;
34}
35
37{
38 mFragments.append( fragment );
39}
40
42{
43 mFragments.push_back( fragment );
44}
45
47{
48 mFragments.clear();
49}
50
52{
53 return mFragments.empty();
54}
55
57{
58 return mFragments.size();
59}
60
62{
63 for ( QgsTextFragment &fragment : mFragments )
64 {
65 fragment.applyCapitalization( capitalization );
66 }
67}
68
69const QgsTextFragment &QgsTextBlock::at( int index ) const
70{
71 return mFragments.at( index );
72}
73
75{
76 return mFragments[ index ];
77}
78
80QVector< QgsTextFragment >::const_iterator QgsTextBlock::begin() const
81{
82 return mFragments.begin();
83}
84
85QVector< QgsTextFragment >::const_iterator QgsTextBlock::end() const
86{
87 return mFragments.end();
88}
Capitalization
String capitalization options.
Definition qgis.h:2493
int size() const
Returns the number of fragments in the block.
void applyCapitalization(Qgis::Capitalization capitalization)
Applies a capitalization style to the block's text.
QString toPlainText() const
Converts the block to plain text.
QgsTextFragment & operator[](int index)
Returns the fragment at the specified index.
void clear()
Clears the block, removing all its contents.
QgsTextBlock()=default
Constructor for an empty text block.
void append(const QgsTextFragment &fragment)
Appends a fragment to the block.
const QgsTextFragment & at(int index) const
Returns the fragment at the specified index.
bool empty() const
Returns true if the block is empty.
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.