QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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 public:
46 QgsTableCell( const QVariant &content = QVariant() );
47
48 QgsTableCell( const QgsTableCell &other );
49
51
52 QgsTableCell &operator=( const QgsTableCell &other );
53
59 QVariant content() const { return mContent; }
60
66 void setContent( const QVariant &content ) { mContent = content; }
67
73 QColor backgroundColor() const { return mBackgroundColor; }
74
82 void setBackgroundColor( const QColor &color ) { mBackgroundColor = color; }
83
89 QColor foregroundColor() const { return mForegroundColor; }
90
98 void setForegroundColor( const QColor &color ) { mForegroundColor = color; }
99
108 QgsTextFormat textFormat() const { return mTextFormat; }
109
118 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
119
125 const QgsNumericFormat *numericFormat() const;
126
134 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
135
143 Qt::Alignment horizontalAlignment() const;
144
152 void setHorizontalAlignment( Qt::Alignment alignment );
153
161 Qt::Alignment verticalAlignment() const;
162
170 void setVerticalAlignment( Qt::Alignment alignment );
171
180 void setSpan( int rowSpan, int columnSpan );
181
190 int rowSpan() const { return mRowSpan; }
191
200 int columnSpan() const { return mColumnSpan; }
201
207 QVariantMap properties( const QgsReadWriteContext &context ) const;
208
214 void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
215
216
217#ifdef SIP_RUN
218 // clang-format off
219 SIP_PYOBJECT __repr__();
220 % MethodCode
221 QString str = u"<QgsTableCell: %1>"_s.arg( sipCpp->content().toString() );
222 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
223 % End
224// clang-format on
225#endif
226
227 // clang-format off
228 private:
229 // clang-format on
230
231 QVariant mContent;
232 QColor mBackgroundColor;
233 QColor mForegroundColor;
234 QgsTextFormat mTextFormat;
235 std::unique_ptr< QgsNumericFormat > mFormat;
236
237 Qt::Alignment mHAlign = Qt::AlignLeft;
238 Qt::Alignment mVAlign = Qt::AlignVCenter;
239
240 int mRowSpan = 1;
241 int mColumnSpan = 1;
242};
243
249typedef QVector<QgsTableCell> QgsTableRow;
250
251#ifndef SIP_RUN
252
258typedef QVector<QgsTableRow> QgsTableContents;
259#else
260
266typedef QVector<QVector<QgsTableCell>> QgsTableContents;
267#endif
268
269
270#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:35
QVector< QgsTableRow > QgsTableContents
A set of table rows.
QVector< QgsTableCell > QgsTableRow
A row of table cells.