QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 <QVariant>
21 #include <QColor>
22 #include <memory>
23 
24 class QgsNumericFormat;
26 
34 class CORE_EXPORT QgsTableCell
35 {
36 
37  public:
38 
42  QgsTableCell( const QVariant &content = QVariant() );
43 
45  QgsTableCell( const QgsTableCell &other );
46 
47  ~QgsTableCell();
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 
102  const QgsNumericFormat *numericFormat() const;
103 
111  void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
112 
118  QVariantMap properties( const QgsReadWriteContext &context ) const;
119 
125  void setProperties( const QVariantMap &properties, const QgsReadWriteContext &context );
126 
127 
128 #ifdef SIP_RUN
129  SIP_PYOBJECT __repr__();
130  % MethodCode
131  QString str = QStringLiteral( "<QgsTableCell: %1>" ).arg( sipCpp->content().toString() );
132  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
133  % End
134 #endif
135 
136  private:
137 
138  QVariant mContent;
139  QColor mBackgroundColor;
140  QColor mForegroundColor;
141  std::unique_ptr< QgsNumericFormat > mFormat;
142 };
143 
149 typedef QVector<QgsTableCell> QgsTableRow;
150 
151 #ifndef SIP_RUN
152 
158 typedef QVector<QgsTableRow> QgsTableContents;
159 #else
160 
166 typedef QVector<QVector<QgsTableRow>> QgsTableContents;
167 #endif
168 
169 
170 #endif // QGSTABLECELL_H
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsTableCell::backgroundColor
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:70
QgsNumericFormat
Definition: qgsnumericformat.h:217
QgsTableCell::setContent
void setContent(const QVariant &content)
Sets the cell's content.
Definition: qgstablecell.h:63
QgsTableContents
QVector< QgsTableRow > QgsTableContents
A set of table rows.
Definition: qgstablecell.h:158
QgsTableCell::setForegroundColor
void setForegroundColor(const QColor &color)
Sets the cell's foreground color.
Definition: qgstablecell.h:95
QgsTableCell
Encapsulates the contents and formatting of a single table cell.
Definition: qgstablecell.h:34
QgsTableCell::foregroundColor
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:86
qgis_sip.h
QgsTableCell::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets the cell's background color.
Definition: qgstablecell.h:79
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsTableRow
QVector< QgsTableCell > QgsTableRow
A row of table cells.
Definition: qgstablecell.h:149
QgsTableCell::content
QVariant content() const
Returns the cell's content.
Definition: qgstablecell.h:56