QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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 <memory>
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgstextformat.h"
23
24#include <QColor>
25#include <QVariant>
26
29
37class CORE_EXPORT QgsTableCell
38{
39
40 public:
41
45 QgsTableCell( const QVariant &content = QVariant() );
46
47 QgsTableCell( const QgsTableCell &other );
48
50
51 QgsTableCell &operator=( const QgsTableCell &other );
52
58 QVariant content() const { return mContent; }
59
65 void setContent( const QVariant &content ) { mContent = content; }
66
72 QColor backgroundColor() const { return mBackgroundColor; }
73
81 void setBackgroundColor( const QColor &color ) { mBackgroundColor = color; }
82
88 QColor foregroundColor() const { return mForegroundColor; }
89
97 void setForegroundColor( const QColor &color ) { mForegroundColor = color; }
98
107 QgsTextFormat textFormat() const { return mTextFormat; }
108
117 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
118
124 const QgsNumericFormat *numericFormat() const;
125
133 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
134
142 Qt::Alignment horizontalAlignment() const;
143
151 void setHorizontalAlignment( Qt::Alignment alignment );
152
160 Qt::Alignment verticalAlignment() const;
161
169 void setVerticalAlignment( Qt::Alignment alignment );
170
179 void setSpan( int rowSpan, int columnSpan );
180
189 int rowSpan() const { return mRowSpan; }
190
199 int columnSpan() const { return mColumnSpan; }
200
206 QVariantMap properties( const QgsReadWriteContext &context ) const;
207
213 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
214
215
216#ifdef SIP_RUN
217 SIP_PYOBJECT __repr__();
218 % MethodCode
219 QString str = QStringLiteral( "<QgsTableCell: %1>" ).arg( sipCpp->content().toString() );
220 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
221 % End
222#endif
223
224 private:
225
226 QVariant mContent;
227 QColor mBackgroundColor;
228 QColor mForegroundColor;
229 QgsTextFormat mTextFormat;
230 std::unique_ptr< QgsNumericFormat > mFormat;
231
232 Qt::Alignment mHAlign = Qt::AlignLeft;
233 Qt::Alignment mVAlign = Qt::AlignVCenter;
234
235 int mRowSpan = 1;
236 int mColumnSpan = 1;
237
238};
239
245typedef QVector<QgsTableCell> QgsTableRow;
246
247#ifndef SIP_RUN
248
254typedef QVector<QgsTableRow> QgsTableContents;
255#else
256
262typedef QVector<QVector<QgsTableCell>> QgsTableContents;
263#endif
264
265
266#endif // QGSTABLECELL_H
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
A container for the context for various read/write operations on objects.
int columnSpan() const
Returns the column span for the cell.
QgsTableCell(const QVariant &content=QVariant())
Constructor for QgsTableCell, with the specified content.
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.
QgsTableCell & operator=(const QgsTableCell &other)
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 SIP_TRANSFER
Definition qgis_sip.h:36
QVector< QgsTableRow > QgsTableContents
A set of table rows.
QVector< QgsTableCell > QgsTableRow
A row of table cells.