QGIS API Documentation 3.99.0-Master (d270888f95f)
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 <QString>
26#include <QVariant>
27
28using namespace Qt::StringLiterals;
29
32
40class CORE_EXPORT QgsTableCell
41{
42
43 public:
44
48 QgsTableCell( const QVariant &content = QVariant() );
49
50 QgsTableCell( const QgsTableCell &other );
51
53
54 QgsTableCell &operator=( const QgsTableCell &other );
55
61 QVariant content() const { return mContent; }
62
68 void setContent( const QVariant &content ) { mContent = content; }
69
75 QColor backgroundColor() const { return mBackgroundColor; }
76
84 void setBackgroundColor( const QColor &color ) { mBackgroundColor = color; }
85
91 QColor foregroundColor() const { return mForegroundColor; }
92
100 void setForegroundColor( const QColor &color ) { mForegroundColor = color; }
101
110 QgsTextFormat textFormat() const { return mTextFormat; }
111
120 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
121
127 const QgsNumericFormat *numericFormat() const;
128
136 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
137
145 Qt::Alignment horizontalAlignment() const;
146
154 void setHorizontalAlignment( Qt::Alignment alignment );
155
163 Qt::Alignment verticalAlignment() const;
164
172 void setVerticalAlignment( Qt::Alignment alignment );
173
182 void setSpan( int rowSpan, int columnSpan );
183
192 int rowSpan() const { return mRowSpan; }
193
202 int columnSpan() const { return mColumnSpan; }
203
209 QVariantMap properties( const QgsReadWriteContext &context ) const;
210
216 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
217
218
219#ifdef SIP_RUN
220 SIP_PYOBJECT __repr__();
221 % MethodCode
222 QString str = u"<QgsTableCell: %1>"_s.arg( sipCpp->content().toString() );
223 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
224 % End
225#endif
226
227 private:
228
229 QVariant mContent;
230 QColor mBackgroundColor;
231 QColor mForegroundColor;
232 QgsTextFormat mTextFormat;
233 std::unique_ptr< QgsNumericFormat > mFormat;
234
235 Qt::Alignment mHAlign = Qt::AlignLeft;
236 Qt::Alignment mVAlign = Qt::AlignVCenter;
237
238 int mRowSpan = 1;
239 int mColumnSpan = 1;
240
241};
242
248typedef QVector<QgsTableCell> QgsTableRow;
249
250#ifndef SIP_RUN
251
257typedef QVector<QgsTableRow> QgsTableContents;
258#else
259
265typedef QVector<QVector<QgsTableCell>> QgsTableContents;
266#endif
267
268
269#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.