QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
46 QgsTableCell( const QgsTableCell &other );
47
49
50 QgsTableCell &operator=( const QgsTableCell &other );
51
57 QVariant content() const { return mContent; }
58
64 void setContent( const QVariant &content ) { mContent = content; }
65
71 QColor backgroundColor() const { return mBackgroundColor; }
72
80 void setBackgroundColor( const QColor &color ) { mBackgroundColor = color; }
81
87 QColor foregroundColor() const { return mForegroundColor; }
88
96 void setForegroundColor( const QColor &color ) { mForegroundColor = color; }
97
106 QgsTextFormat textFormat() const { return mTextFormat; }
107
116 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
117
123 const QgsNumericFormat *numericFormat() const;
124
132 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
133
141 Qt::Alignment horizontalAlignment() const;
142
150 void setHorizontalAlignment( Qt::Alignment alignment );
151
159 Qt::Alignment verticalAlignment() const;
160
168 void setVerticalAlignment( Qt::Alignment alignment );
169
175 QVariantMap properties( const QgsReadWriteContext &context ) const;
176
182 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
183
184
185#ifdef SIP_RUN
186 SIP_PYOBJECT __repr__();
187 % MethodCode
188 QString str = QStringLiteral( "<QgsTableCell: %1>" ).arg( sipCpp->content().toString() );
189 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
190 % End
191#endif
192
193 private:
194
195 QVariant mContent;
196 QColor mBackgroundColor;
197 QColor mForegroundColor;
198 QgsTextFormat mTextFormat;
199 std::unique_ptr< QgsNumericFormat > mFormat;
200
201 Qt::Alignment mHAlign = Qt::AlignLeft;
202 Qt::Alignment mVAlign = Qt::AlignVCenter;
203
204};
205
211typedef QVector<QgsTableCell> QgsTableRow;
212
213#ifndef SIP_RUN
214
220typedef QVector<QgsTableRow> QgsTableContents;
221#else
222
228typedef QVector<QVector<QgsTableCell>> QgsTableContents;
229#endif
230
231
232#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.
Definition: qgstablecell.h:36
void setBackgroundColor(const QColor &color)
Sets the cell's background color.
Definition: qgstablecell.h:80
QColor foregroundColor() const
Returns the cell's foreground color, or an invalid color if a default color should be used for the fo...
Definition: qgstablecell.h:87
void setTextFormat(const QgsTextFormat &format)
Sets the cell's text format.
Definition: qgstablecell.h:116
void setContent(const QVariant &content)
Sets the cell's content.
Definition: qgstablecell.h:64
QVariant content() const
Returns the cell's content.
Definition: qgstablecell.h:57
QgsTextFormat textFormat() const
Returns the cell's text format.
Definition: qgstablecell.h:106
void setForegroundColor(const QColor &color)
Sets the cell's foreground color.
Definition: qgstablecell.h:96
QColor backgroundColor() const
Returns the cell's background color, or an invalid color if a default color should be used for the ba...
Definition: qgstablecell.h:71
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
#define str(x)
Definition: qgis.cpp:37
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QVector< QgsTableRow > QgsTableContents
A set of table rows.
Definition: qgstablecell.h:220
QVector< QgsTableCell > QgsTableRow
A row of table cells.
Definition: qgstablecell.h:211