QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextdocument.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextdocument.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 QGSTEXTDOCUMENT_H
17 #define QGSTEXTDOCUMENT_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_core.h"
21 
22 #include <QVector>
23 
24 class QgsTextBlock;
25 class QgsTextFragment;
26 
37 class CORE_EXPORT QgsTextDocument
38 {
39 
40  public:
41 
43  ~QgsTextDocument();
44 
48  explicit QgsTextDocument( const QgsTextBlock &block );
49 
53  explicit QgsTextDocument( const QgsTextFragment &fragment );
54 
58  static QgsTextDocument fromPlainText( const QStringList &lines );
59 
63  static QgsTextDocument fromHtml( const QStringList &lines );
64 
68  void append( const QgsTextBlock &block );
69 
73  void append( QgsTextBlock &&block ) SIP_SKIP;
74 
78  void reserve( int count );
79 
83  const QgsTextBlock &at( int index ) const SIP_FACTORY;
84 #ifdef SIP_RUN
85  % MethodCode
86  if ( a0 < 0 || a0 >= sipCpp->size() )
87  {
88  PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
89  sipIsErr = 1;
90  }
91  else
92  {
93  sipRes = new QgsTextBlock( sipCpp->at( a0 ) );
94  }
95  % End
96 #endif
97 
101  QgsTextBlock &operator[]( int index ) SIP_FACTORY;
102 #ifdef SIP_RUN
103  % MethodCode
104  SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
105  if ( idx < 0 )
106  sipIsErr = 1;
107  else
108  sipRes = new QgsTextBlock( sipCpp->operator[]( idx ) );
109  % End
110 #endif
111 
115  int size() const;
116 
117 #ifdef SIP_RUN
118  int __len__() const;
119  % MethodCode
120  sipRes = sipCpp->size();
121  % End
122 #endif
123 
127  QStringList toPlainText() const;
128 
138  void splitLines( const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
139 
140 #ifndef SIP_RUN
141  QVector< QgsTextBlock >::const_iterator begin() const;
143  QVector< QgsTextBlock >::const_iterator end() const;
145 #endif
146 
147  private:
148 
149  QVector< QgsTextBlock > mBlocks;
150 
151 };
152 
153 #endif // QGSTEXTDOCUMENT_H
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsTextFragment
Definition: qgstextfragment.h:34
qgis_sip.h
QgsTextBlock
Definition: qgstextblock.h:34
QgsTextDocument
Definition: qgstextdocument.h:37