QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutitemmanualtable.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutitemmanualtable.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 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSLAYOUTITEMMANUALTABLE_H
19 #define QGSLAYOUTITEMMANUALTABLE_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgslayouttable.h"
24 #include "qgstablecell.h"
25 
31 class CORE_EXPORT QgsLayoutItemManualTable: public QgsLayoutTable
32 {
33  Q_OBJECT
34 
35  public:
36 
43 
44  ~QgsLayoutItemManualTable() override;
45 
46  int type() const override;
47  QIcon icon() const override;
48  QString displayName() const override;
49 
53  static QgsLayoutItemManualTable *create( QgsLayout *layout ) SIP_FACTORY;
54  bool getTableContents( QgsLayoutTableContents &contents ) override SIP_SKIP;
55  QgsConditionalStyle conditionalCellStyle( int row, int column ) const override;
56 
62  void setTableContents( const QgsTableContents &contents );
63 
69  QgsTableContents tableContents() const;
70 
79  QList< double > rowHeights() const { return mRowHeights; }
80 
89  void setRowHeights( const QList< double > &heights );
90 
99  QList< double > columnWidths() const { return mColumnWidths; }
100 
109  void setColumnWidths( const QList< double > &widths );
110 
116  bool includeTableHeader() const;
117 
123  void setIncludeTableHeader( bool included );
124 
129  QgsLayoutTableColumns &headers();
130 
135  void setHeaders( const QgsLayoutTableColumns &headers );
136 
137  protected:
138 
139  bool writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
140  bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
141  bool calculateMaxRowHeights() override;
142  QgsTextFormat textFormatForHeader( int column ) const override;
143  QgsTextFormat textFormatForCell( int row, int column ) const override;
144  Qt::Alignment horizontalAlignmentForCell( int row, int column ) const override;
145  Qt::Alignment verticalAlignmentForCell( int row, int column ) const override;
146 
147  private:
148 
149  QgsTableContents mContents;
150  QgsLayoutTableColumns mHeaders;
151 
152  QList< double > mRowHeights;
153  QList< double > mColumnWidths;
154  bool mIncludeHeader = false;
155 
156  void refreshColumns();
157 
158 };
159 
160 #endif // QGSLAYOUTITEMMANUALTABLE_H
QgsLayoutTableColumns
QVector< QgsLayoutTableColumn > QgsLayoutTableColumns
List of column definitions for a QgsLayoutTable.
Definition: qgslayouttable.h:58
QgsLayoutTableContents
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
Definition: qgslayouttable.h:47
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsLayoutItemManualTable::columnWidths
QList< double > columnWidths() const
Returns the list of column widths (in millimeters) to use when rendering the table.
Definition: qgslayoutitemmanualtable.h:99
QgsLayoutTable::writePropertiesToElement
bool writePropertiesToElement(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Stores multiframe state within an XML DOM element.
Definition: qgslayouttable.cpp:69
QgsLayoutMultiFrame::icon
virtual QIcon icon() const
Returns the item's icon.
Definition: qgslayoutmultiframe.h:154
QgsConditionalStyle
Conditional styling for a rule.
Definition: qgsconditionalstyle.h:113
QgsLayoutTable::textFormatForCell
virtual QgsTextFormat textFormatForCell(int row, int column) const
Returns the text format to use for the cell at the specified row and column.
Definition: qgslayouttable.cpp:1544
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsTableContents
QVector< QgsTableRow > QgsTableContents
A set of table rows.
Definition: qgstablecell.h:220
QgsLayoutTable::verticalAlignmentForCell
virtual Qt::Alignment verticalAlignmentForCell(int row, int column) const
Returns the vertical alignment to use for the cell at the specified row and column.
Definition: qgslayouttable.cpp:1559
QgsLayoutTable::readPropertiesFromElement
bool readPropertiesFromElement(const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
Sets multiframe state from a DOM element.
Definition: qgslayouttable.cpp:133
QgsTextFormat
Container for all settings relating to text rendering.
Definition: qgstextformat.h:40
QgsLayoutMultiFrame::type
virtual int type() const =0
Returns unique multiframe type id.
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgslayouttable.h
qgstablecell.h
qgis_sip.h
QgsLayoutTable::getTableContents
virtual bool getTableContents(QgsLayoutTableContents &contents)=0
Fetches the contents used for the cells in the table.
QgsLayoutTable::textFormatForHeader
virtual QgsTextFormat textFormatForHeader(int column) const
Returns the text format to use for the header cell at the specified column.
Definition: qgslayouttable.cpp:1549
QgsLayoutTable
A class to display a table in the print layout, and allow the table to span over multiple frames.
Definition: qgslayouttable.h:113
QgsLayoutTable::calculateMaxRowHeights
virtual bool calculateMaxRowHeights()
Calculates the maximum height of text shown in rows.
Definition: qgslayouttable.cpp:1155
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsLayoutItemManualTable::rowHeights
QList< double > rowHeights() const
Returns the list of row heights (in millimeters) to use when rendering the table.
Definition: qgslayoutitemmanualtable.h:79
QgsLayoutTable::conditionalCellStyle
virtual QgsConditionalStyle conditionalCellStyle(int row, int column) const
Returns the conditional style to use for the cell at row, column.
Definition: qgslayouttable.cpp:1002
QgsLayoutTable::horizontalAlignmentForCell
virtual Qt::Alignment horizontalAlignmentForCell(int row, int column) const
Returns the horizontal alignment to use for the cell at the specified row and column.
Definition: qgslayouttable.cpp:1554
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsLayoutMultiFrame::displayName
virtual QString displayName() const
Returns the multiframe display name.
Definition: qgslayoutmultiframe.cpp:273
QgsLayoutItemManualTable
A layout table subclass that displays manually entered (and formatted) content.
Definition: qgslayoutitemmanualtable.h:32