QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
qgstablecell.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstablecell.h
3 --------------
4 begin : January 2020
5 copyright : (C) 2020 by 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#ifndef QGSTABLECELL_H
16#define QGSTABLECELL_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include "qgstextformat.h"
21#include <QVariant>
22#include <QColor>
23#include <memory>
24
27
35class CORE_EXPORT QgsTableCell
36{
37
38 public:
39
43 QgsTableCell( const QVariant &content = QVariant() );
44
45 QgsTableCell( const QgsTableCell &other );
46
48
49 QgsTableCell &operator=( const QgsTableCell &other );
50
56 QVariant content() const { return mContent; }
57
63 void setContent( const QVariant &content ) { mContent = content; }
64
70 QColor backgroundColor() const { return mBackgroundColor; }
71
79 void setBackgroundColor( const QColor &color ) { mBackgroundColor = color; }
80
86 QColor foregroundColor() const { return mForegroundColor; }
87
95 void setForegroundColor( const QColor &color ) { mForegroundColor = color; }
96
105 QgsTextFormat textFormat() const { return mTextFormat; }
106
115 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
116
122 const QgsNumericFormat *numericFormat() const;
123
131 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
132
140 Qt::Alignment horizontalAlignment() const;
141
149 void setHorizontalAlignment( Qt::Alignment alignment );
150
158 Qt::Alignment verticalAlignment() const;
159
167 void setVerticalAlignment( Qt::Alignment alignment );
168
174 QVariantMap properties( const QgsReadWriteContext &context ) const;
175
181 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
182
183
184#ifdef SIP_RUN
185 SIP_PYOBJECT __repr__();
186 % MethodCode
187 QString str = QStringLiteral( "<QgsTableCell: %1>" ).arg( sipCpp->content().toString() );
188 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
189 % End
190#endif
191
192 private:
193
194 QVariant mContent;
195 QColor mBackgroundColor;
196 QColor mForegroundColor;
197 QgsTextFormat mTextFormat;
198 std::unique_ptr< QgsNumericFormat > mFormat;
199
200 Qt::Alignment mHAlign = Qt::AlignLeft;
201 Qt::Alignment mVAlign = Qt::AlignVCenter;
202
203};
204
210typedef QVector<QgsTableCell> QgsTableRow;
211
212#ifndef SIP_RUN
213
219typedef QVector<QgsTableRow> QgsTableContents;
220#else
221
227typedef QVector<QVector<QgsTableCell>> QgsTableContents;
228#endif
229
230
231#endif // QGSTABLECELL_H
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
The class is used as a container of context for various read/write operations on other objects.
Encapsulates the contents and formatting of a single table cell.
void setBackgroundColor(const QColor &color)
Sets the cell's background color.
QColor foregroundColor() const
Returns the cell's foreground color, or an invalid color if a default color should be used for the fo...
void setTextFormat(const QgsTextFormat &format)
Sets the cell's text format.
void setContent(const QVariant &content)
Sets the cell's content.
QVariant content() const
Returns the cell's content.
QgsTextFormat textFormat() const
Returns the cell's text format.
void setForegroundColor(const QColor &color)
Sets the cell's foreground color.
QColor backgroundColor() const
Returns the cell's background color, or an invalid color if a default color should be used for the ba...
Container for all settings relating to text rendering.
#define str(x)
Definition qgis.cpp:38
#define SIP_TRANSFER
Definition qgis_sip.h:36
QVector< QgsTableRow > QgsTableContents
A set of table rows.
QVector< QgsTableCell > QgsTableRow
A row of table cells.