QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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 "qgis_core.h"
22#include "qgis_sip.h"
23
24#include <QColor>
25#include <QDomDocument>
26#include <QDomElement>
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
39class CORE_EXPORT QgsLayoutTableColumn
40{
41 public:
42
47 QgsLayoutTableColumn( const QString &heading = QString() );
48
55 bool writeXml( QDomElement &columnElem, QDomDocument &doc ) const;
56
62 bool readXml( const QDomElement &columnElem );
63
69 double width() const { return mWidth; }
70
75 void setWidth( const double width ) { mWidth = width; }
76
82 QString heading() const { return mHeading; }
83
89 void setHeading( const QString &heading ) { mHeading = heading; }
90
97 Qt::AlignmentFlag hAlignment() const { return mHAlignment; }
98
105 void setHAlignment( Qt::AlignmentFlag alignment ) { mHAlignment = alignment; }
106
113 Qt::AlignmentFlag vAlignment() const { return mVAlignment; }
114
121 void setVAlignment( Qt::AlignmentFlag alignment ) { mVAlignment = alignment; }
122
129 QString attribute() const { return mAttribute; }
130
137 void setAttribute( const QString &attribute ) { mAttribute = attribute; }
138
146 Qt::SortOrder sortOrder() const { return mSortOrder; }
147
155 void setSortOrder( Qt::SortOrder order ) { mSortOrder = order; }
156
171 Q_DECL_DEPRECATED int sortByRank() const SIP_DEPRECATED { return mSortByRank; }
172
186 Q_DECL_DEPRECATED void setSortByRank( int rank ) SIP_DEPRECATED { mSortByRank = rank; }
187
194
195 bool operator==( const QgsLayoutTableColumn &other ) const
196 {
197 return mHeading == other.mHeading
198 && mAttribute == other.mAttribute
199 && mSortByRank == other.mSortByRank
200 && mSortOrder == other.mSortOrder
201 && mWidth == other.mWidth
202 && mHAlignment == other.mHAlignment
203 && mVAlignment == other.mVAlignment;
204 }
205
206
207#ifdef SIP_RUN
208 SIP_PYOBJECT __repr__();
209 % MethodCode
210 QString str;
211 if ( sipCpp->heading() != sipCpp->attribute() && !sipCpp->heading().isEmpty() )
212 str = u"<QgsLayoutTableColumn: %1 (\"%2\")>"_s.arg( sipCpp->attribute(), sipCpp->heading() );
213 else
214 str = u"<QgsLayoutTableColumn: %1>"_s.arg( sipCpp->attribute() );
215 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
216 % End
217#endif
218
219 private:
220
221 QString mHeading;
222 QString mAttribute;
223 int mSortByRank = 0;
224 Qt::SortOrder mSortOrder = Qt::AscendingOrder;
225 double mWidth = 0.0;
226 QColor mBackgroundColor = Qt::transparent; //currently unused
227 Qt::AlignmentFlag mHAlignment = Qt::AlignLeft;
228 Qt::AlignmentFlag mVAlignment = Qt::AlignVCenter;
229
231
232};
233#endif //QGSLAYOUTTABLECOLUMN_H
bool readXml(const QDomElement &columnElem)
Reads the column's properties from xml.
Q_DECL_DEPRECATED QgsLayoutTableColumn * clone()
Creates a duplicate column which is a deep copy of this column.
QString attribute() const
Returns the attribute name or expression used for the column's values.
void setVAlignment(Qt::AlignmentFlag alignment)
Sets the vertical alignment for a column, which controls the alignment used for drawing column values...
double width() const
Returns the width for the column in mm, or 0 if column width is automatically calculated.
Qt::AlignmentFlag vAlignment() const
Returns the vertical alignment for a column, which controls the alignment used for drawing column val...
QString heading() const
Returns the heading for a column, which is the value displayed in the column's header cell.
bool writeXml(QDomElement &columnElem, QDomDocument &doc) const
Writes the column's properties to xml for storage.
bool operator==(const QgsLayoutTableColumn &other) const
Q_DECL_DEPRECATED void setSortByRank(int rank)
Sets the sort rank for the column.
void setSortOrder(Qt::SortOrder order)
Sets the sort order for the column.
void setAttribute(const QString &attribute)
Sets the attribute name or expression used for the column's values.
Q_DECL_DEPRECATED int sortByRank() const
Returns the sort rank for the column.
QgsLayoutTableColumn(const QString &heading=QString())
Constructor for QgsLayoutTableColumn.
Qt::SortOrder sortOrder() const
Returns the sort order for the column.
void setHAlignment(Qt::AlignmentFlag alignment)
Sets the horizontal alignment for a column, which controls the alignment used for drawing column valu...
void setHeading(const QString &heading)
Sets the heading for a column, which is the value displayed in the column's header cell.
Qt::AlignmentFlag hAlignment() const
Returns the horizontal alignment for a column, which controls the alignment used for drawing column v...
void setWidth(const double width)
Sets the width for a column in mm.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_FACTORY
Definition qgis_sip.h:84