QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgslayouttablecolumn.h
Go to the documentation of this file.
1 /***************************************************************************
2  QgsLayoutTableColumn.h
3  ------------------
4  begin : November 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSLAYOUTTABLECOLUMN_H
19 #define QGSLAYOUTTABLECOLUMN_H
20 
21 #include <QDomDocument>
22 #include <QDomElement>
23 #include <QColor>
24 
25 #include "qgis_core.h"
26 #include "qgis_sip.h"
27 
37 class CORE_EXPORT QgsLayoutTableColumn
38 {
39  public:
40 
45  QgsLayoutTableColumn( const QString &heading = QString() );
46 
53  bool writeXml( QDomElement &columnElem, QDomDocument &doc ) const;
54 
60  bool readXml( const QDomElement &columnElem );
61 
67  double width() const { return mWidth; }
68 
73  void setWidth( const double width ) { mWidth = width; }
74 
80  QString heading() const { return mHeading; }
81 
87  void setHeading( const QString &heading ) { mHeading = heading; }
88 
95  Qt::AlignmentFlag hAlignment() const { return mHAlignment; }
96 
103  void setHAlignment( Qt::AlignmentFlag alignment ) { mHAlignment = alignment; }
104 
111  Qt::AlignmentFlag vAlignment() const { return mVAlignment; }
112 
119  void setVAlignment( Qt::AlignmentFlag alignment ) { mVAlignment = alignment; }
120 
127  QString attribute() const { return mAttribute; }
128 
135  void setAttribute( const QString &attribute ) { mAttribute = attribute; }
136 
144  Qt::SortOrder sortOrder() const { return mSortOrder; }
145 
153  void setSortOrder( Qt::SortOrder order ) { mSortOrder = order; }
154 
169  Q_DECL_DEPRECATED int sortByRank() const SIP_DEPRECATED { return mSortByRank; }
170 
184  Q_DECL_DEPRECATED void setSortByRank( int rank ) SIP_DEPRECATED { mSortByRank = rank; }
185 
191  Q_DECL_DEPRECATED QgsLayoutTableColumn *clone() SIP_DEPRECATED SIP_FACTORY {return new QgsLayoutTableColumn( *this );}
192 
193  bool operator==( const QgsLayoutTableColumn &other ) const
194  {
195  return mHeading == other.mHeading
196  && mAttribute == other.mAttribute
197  && mSortByRank == other.mSortByRank
198  && mSortOrder == other.mSortOrder
199  && mWidth == other.mWidth
200  && mHAlignment == other.mHAlignment
201  && mVAlignment == other.mVAlignment;
202  }
203 
204 
205 #ifdef SIP_RUN
206  SIP_PYOBJECT __repr__();
207  % MethodCode
208  QString str;
209  if ( sipCpp->heading() != sipCpp->attribute() && !sipCpp->heading().isEmpty() )
210  str = QStringLiteral( "<QgsLayoutTableColumn: %1 (\"%2\")>" ).arg( sipCpp->attribute(), sipCpp->heading() );
211  else
212  str = QStringLiteral( "<QgsLayoutTableColumn: %1>" ).arg( sipCpp->attribute() );
213  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
214  % End
215 #endif
216 
217  private:
218 
219  QString mHeading;
220  QString mAttribute;
221  int mSortByRank = 0;
222  Qt::SortOrder mSortOrder = Qt::AscendingOrder;
223  double mWidth = 0.0;
224  QColor mBackgroundColor = Qt::transparent; //currently unused
225  Qt::AlignmentFlag mHAlignment = Qt::AlignLeft;
226  Qt::AlignmentFlag mVAlignment = Qt::AlignVCenter;
227 
228  friend class QgsCompositionConverter;
229 
230 };
231 #endif //QGSLAYOUTTABLECOLUMN_H
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsCompositionConverter
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
Definition: qgscompositionconverter.h:56
qgis_sip.h
str
#define str(x)
Definition: qgis.cpp:37
QgsLayoutTableColumn
Stores properties of a column for a QgsLayoutTable.
Definition: qgslayouttablecolumn.h:37