23 mFragments.append( fragment );
28 if ( text.contains(
'\t' ) )
33 const QStringList tabSplit = text.split(
'\t' );
35 for (
const QString &part : tabSplit )
37 if ( !part.isEmpty() )
39 if ( index != tabSplit.size() - 1 )
59 res.append( fragment.text() );
66 mFragments.reserve( count );
71 mFragments.append( fragment );
76 mFragments.push_back( fragment );
81 mFragments.insert( index, fragment );
86 mFragments.insert( index, fragment );
96 return mFragments.empty();
101 return mFragments.size();
106 mBlockFormat = format;
113 fragment.applyCapitalization( capitalization );
120 || std::any_of( mFragments.begin(), mFragments.end(), [](
const QgsTextFragment & fragment ) { return fragment.characterFormat().hasBackground(); } );
125 return mFragments.at( index );
130 return mFragments[ index ];
134QVector< QgsTextFragment >::const_iterator QgsTextBlock::begin()
const
136 return mFragments.begin();
139QVector< QgsTextFragment >::const_iterator QgsTextBlock::end()
const
141 return mFragments.end();
Capitalization
String capitalization options.
Stores information relating to individual block formatting.
bool hasBackground() const
Returns true if the block has a background set.
Represents a block of text consisting of one or more QgsTextFragment objects.
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.
void insert(int index, const QgsTextFragment &fragment)
Inserts a fragment into the block, at the specified index.
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.
static QgsTextBlock fromPlainText(const QString &text, const QgsTextCharacterFormat &format=QgsTextCharacterFormat())
Constructor for QgsTextBlock consisting of a plain text, and optional character format.
QgsTextBlock()=default
Constructor for an empty text block.
void reserve(int count)
Reserves the specified count of fragments for optimised fragment appending.
void setBlockFormat(const QgsTextBlockFormat &format)
Sets the block format for the fragment.
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.
bool hasBackgrounds() const
Returns true if the block or any of the fragments in the block have background brushes set.
Stores information relating to individual character formatting.
Stores a fragment of document along with formatting overrides to be used when rendering the fragment.