QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
20 {
21  mFragments.append( fragment );
22 }
23 
25 {
26  QString res;
27  for ( const QgsTextFragment &fragment : mFragments )
28  {
29  res.append( fragment.text() );
30  }
31  return res;
32 }
33 
34 void QgsTextBlock::append( const QgsTextFragment &fragment )
35 {
36  mFragments.append( fragment );
37 }
38 
40 {
41  mFragments.push_back( fragment );
42 }
43 
45 {
46  mFragments.clear();
47 }
48 
49 bool QgsTextBlock::empty() const
50 {
51  return mFragments.empty();
52 }
53 
54 int QgsTextBlock::size() const
55 {
56  return mFragments.size();
57 }
58 
60 {
61  for ( QgsTextFragment &fragment : mFragments )
62  {
63  fragment.applyCapitalization( capitalization );
64  }
65 }
66 
67 const QgsTextFragment &QgsTextBlock::at( int index ) const
68 {
69  return mFragments.at( index );
70 }
71 
73 {
74  return mFragments[ index ];
75 }
76 
78 QVector< QgsTextFragment >::const_iterator QgsTextBlock::begin() const
79 {
80  return mFragments.begin();
81 }
82 
83 QVector< QgsTextFragment >::const_iterator QgsTextBlock::end() const
84 {
85  return mFragments.end();
86 }
Capitalization
String capitalization options.
Definition: qgis.h:1236
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.