QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextblock.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextblock.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 QGSTEXTBLOCK_H
17 #define QGSTEXTBLOCK_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_core.h"
21 #include "qgstextfragment.h"
22 #include <QVector>
23 
34 class CORE_EXPORT QgsTextBlock
35 {
36 
37  public:
38 
42  QgsTextBlock() = default;
43 
47  explicit QgsTextBlock( const QgsTextFragment &fragment );
48 
52  void append( const QgsTextFragment &fragment );
53 
57  void append( QgsTextFragment &&fragment ) SIP_SKIP;
58 
62  void clear();
63 
67  bool empty() const;
68 
72  int size() const;
73 
74 #ifdef SIP_RUN
75  int __len__() const;
76  % MethodCode
77  sipRes = sipCpp->size();
78  % End
79 #endif
80 
84  const QgsTextFragment &at( int index ) const SIP_FACTORY;
85 #ifdef SIP_RUN
86  % MethodCode
87  if ( a0 < 0 || a0 >= sipCpp->size() )
88  {
89  PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
90  sipIsErr = 1;
91  }
92  else
93  {
94  sipRes = new QgsTextFragment( sipCpp->at( a0 ) );
95  }
96  % End
97 #endif
98 
102  QgsTextFragment &operator[]( int index ) SIP_FACTORY;
103 #ifdef SIP_RUN
104  % MethodCode
105  SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->size() );
106  if ( idx < 0 )
107  sipIsErr = 1;
108  else
109  sipRes = new QgsTextFragment( sipCpp->operator[]( idx ) );
110  % End
111 #endif
112 
113 #ifndef SIP_RUN
114  QVector< QgsTextFragment >::const_iterator begin() const;
116  QVector< QgsTextFragment >::const_iterator end() const;
118 #endif
119 
120  private:
121 
122  QVector< QgsTextFragment > mFragments;
123 
124 };
125 
126 #endif // QGSTEXTBLOCK_H
qgstextfragment.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