QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
QgsTextDocument Class Reference

Represents a document consisting of one or more QgsTextBlock objects. More...

#include <qgstextdocument.h>

Public Member Functions

 QgsTextDocument ()
 
 QgsTextDocument (const QgsTextBlock &block)
 Constructor for a QgsTextDocument consisting of a single text block.
 
 QgsTextDocument (const QgsTextFragment &fragment)
 Constructor for a QgsTextDocument consisting of a single text fragment.
 
 ~QgsTextDocument ()
 
void append (const QgsTextBlock &block)
 Appends a block to the document.
 
void append (QgsTextBlock &&block)
 Appends a block to the document.
 
void applyCapitalization (Qgis::Capitalization capitalization)
 Applies a capitalization style to the document's text.
 
const QgsTextBlockat (int index) const
 Returns the block at the specified index.
 
bool hasBackgrounds () const
 Returns true if any blocks or fragments in the document have background brushes set.
 
void insert (int index, const QgsTextBlock &block)
 Inserts a block into the document, at the specified index.
 
void insert (int index, QgsTextBlock &&block)
 Inserts a block into the document, at the specified index.
 
QgsTextBlockoperator[] (int index)
 Returns the block at the specified index.
 
void reserve (int count)
 Reserves the specified count of blocks for optimised block appending.
 
int size () const
 Returns the number of blocks in the document.
 
void splitLines (const QString &wrapCharacter, int autoWrapLength=0, bool useMaxLineLengthWhenAutoWrapping=true)
 Splits lines of text in the document to separate lines, using a specified wrap character (wrapCharacter) or newline characters.
 
QStringList toPlainText () const
 Returns a list of plain text lines of text representing the document.
 

Static Public Member Functions

static QgsTextDocument fromHtml (const QStringList &lines)
 Constructor for QgsTextDocument consisting of a set of HTML formatted lines.
 
static QgsTextDocument fromPlainText (const QStringList &lines)
 Constructor for QgsTextDocument consisting of a set of plain text lines.
 
static QgsTextDocument fromTextAndFormat (const QStringList &lines, const QgsTextFormat &format)
 Constructor for QgsTextDocument consisting of a set of lines, respecting settings from a text format.
 

Detailed Description

Represents a document consisting of one or more QgsTextBlock objects.

Warning
This API is not considered stable and may change in future QGIS versions.
Since
QGIS 3.14

Definition at line 40 of file qgstextdocument.h.

Constructor & Destructor Documentation

◆ QgsTextDocument() [1/3]

QgsTextDocument::QgsTextDocument ( )
default

◆ ~QgsTextDocument()

QgsTextDocument::~QgsTextDocument ( )
default

◆ QgsTextDocument() [2/3]

QgsTextDocument::QgsTextDocument ( const QgsTextBlock block)
explicit

Constructor for a QgsTextDocument consisting of a single text block.

Definition at line 31 of file qgstextdocument.cpp.

◆ QgsTextDocument() [3/3]

QgsTextDocument::QgsTextDocument ( const QgsTextFragment fragment)
explicit

Constructor for a QgsTextDocument consisting of a single text fragment.

Definition at line 36 of file qgstextdocument.cpp.

Member Function Documentation

◆ append() [1/2]

void QgsTextDocument::append ( const QgsTextBlock block)

Appends a block to the document.

Definition at line 270 of file qgstextdocument.cpp.

◆ append() [2/2]

void QgsTextDocument::append ( QgsTextBlock &&  block)

Appends a block to the document.

Definition at line 275 of file qgstextdocument.cpp.

◆ applyCapitalization()

void QgsTextDocument::applyCapitalization ( Qgis::Capitalization  capitalization)

Applies a capitalization style to the document's text.

Since
QGIS 3.16

Definition at line 388 of file qgstextdocument.cpp.

◆ at()

const QgsTextBlock & QgsTextDocument::at ( int  index) const

Returns the block at the specified index.

Definition at line 295 of file qgstextdocument.cpp.

◆ fromHtml()

QgsTextDocument QgsTextDocument::fromHtml ( const QStringList &  lines)
static

Constructor for QgsTextDocument consisting of a set of HTML formatted lines.

If the HTML contains tab characters they will be appended as separate text fragments within the document, consisting of just the tab character.

Definition at line 57 of file qgstextdocument.cpp.

◆ fromPlainText()

QgsTextDocument QgsTextDocument::fromPlainText ( const QStringList &  lines)
static

Constructor for QgsTextDocument consisting of a set of plain text lines.

If any line contains tab characters they will be appended as separate text fragments within the document, consisting of just the tab character.

Definition at line 41 of file qgstextdocument.cpp.

◆ fromTextAndFormat()

QgsTextDocument QgsTextDocument::fromTextAndFormat ( const QStringList &  lines,
const QgsTextFormat format 
)
static

Constructor for QgsTextDocument consisting of a set of lines, respecting settings from a text format.

This method will determine from the text format whether the lines should be treated as HTML or plain text.

Since
QGIS 3.40

Definition at line 254 of file qgstextdocument.cpp.

◆ hasBackgrounds()

bool QgsTextDocument::hasBackgrounds ( ) const

Returns true if any blocks or fragments in the document have background brushes set.

Since
QGIS 3.42

Definition at line 396 of file qgstextdocument.cpp.

◆ insert() [1/2]

void QgsTextDocument::insert ( int  index,
const QgsTextBlock block 
)

Inserts a block into the document, at the specified index.

Since
QGIS 3.40

Definition at line 280 of file qgstextdocument.cpp.

◆ insert() [2/2]

void QgsTextDocument::insert ( int  index,
QgsTextBlock &&  block 
)

Inserts a block into the document, at the specified index.

Since
QGIS 3.40

Definition at line 285 of file qgstextdocument.cpp.

◆ operator[]()

QgsTextBlock & QgsTextDocument::operator[] ( int  index)

Returns the block at the specified index.

Definition at line 300 of file qgstextdocument.cpp.

◆ reserve()

void QgsTextDocument::reserve ( int  count)

Reserves the specified count of blocks for optimised block appending.

Definition at line 290 of file qgstextdocument.cpp.

◆ size()

int QgsTextDocument::size ( ) const

Returns the number of blocks in the document.

Definition at line 305 of file qgstextdocument.cpp.

◆ splitLines()

void QgsTextDocument::splitLines ( const QString &  wrapCharacter,
int  autoWrapLength = 0,
bool  useMaxLineLengthWhenAutoWrapping = true 
)

Splits lines of text in the document to separate lines, using a specified wrap character (wrapCharacter) or newline characters.

The autoWrapLength argument can be used to specify an ideal length of line to automatically wrap text to (automatic wrapping is disabled if autoWrapLength is 0). This automatic wrapping is performed after processing wrapping using wrapCharacter. When auto wrapping is enabled, the useMaxLineLengthWhenAutoWrapping argument controls whether the lines should be wrapped to an ideal maximum of autoWrapLength characters, or if false then the lines are wrapped to an ideal minimum length of autoWrapLength characters.

Definition at line 326 of file qgstextdocument.cpp.

◆ toPlainText()

QStringList QgsTextDocument::toPlainText ( ) const

Returns a list of plain text lines of text representing the document.

Definition at line 310 of file qgstextdocument.cpp.


The documentation for this class was generated from the following files: