QGIS API Documentation 3.39.0-Master (d85f3c2a281)
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
177 void setSpan( int rowSpan, int columnSpan );
178
187 int rowSpan() const { return mRowSpan; }
188
197 int columnSpan() const { return mColumnSpan; }
198
204 QVariantMap properties( const QgsReadWriteContext &context ) const;
205
211 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
212
213
214#ifdef SIP_RUN
215 SIP_PYOBJECT __repr__();
216 % MethodCode
217 QString str = QStringLiteral( "<QgsTableCell: %1>" ).arg( sipCpp->content().toString() );
218 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
219 % End
220#endif
221
222 private:
223
224 QVariant mContent;
225 QColor mBackgroundColor;
226 QColor mForegroundColor;
227 QgsTextFormat mTextFormat;
228 std::unique_ptr< QgsNumericFormat > mFormat;
229
230 Qt::Alignment mHAlign = Qt::AlignLeft;
231 Qt::Alignment mVAlign = Qt::AlignVCenter;
232
233 int mRowSpan = 1;
234 int mColumnSpan = 1;
235
236};
237
243typedef QVector<QgsTableCell> QgsTableRow;
244
245#ifndef SIP_RUN
246
252typedef QVector<QgsTableRow> QgsTableContents;
253#else
254
260typedef QVector<QVector<QgsTableCell>> QgsTableContents;
261#endif
262
263
264#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.
int columnSpan() const
Returns the column span for the 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.
int rowSpan() const
Returns the row span for the cell.
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.