QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgslayoutitemtexttable.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemtexttable.cpp
3 --------------------------
4 begin : November 2017
5 copyright : (C) 2017 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
19#include "moc_qgslayoutitemtexttable.cpp"
21#include "qgslayoutframe.h"
22#include "qgslayout.h"
23
29
34
36{
37 return tr( "<Text table frame>" );
38}
39
44
45void QgsLayoutItemTextTable::addRow( const QStringList &row )
46{
47 mRowText.append( row );
49}
50
51void QgsLayoutItemTextTable::setContents( const QVector<QStringList> &contents )
52{
53 mRowText = contents;
55}
56
58{
59 contents.clear();
60
61 for ( const QStringList &row : std::as_const( mRowText ) )
62 {
63 QgsLayoutTableRow currentRow;
64
65 for ( int i = 0; i < mColumns.count(); ++i )
66 {
67 if ( i < row.count() )
68 {
69 currentRow << row.at( i );
70 }
71 else
72 {
73 currentRow << QString();
74 }
75 }
76 contents << currentRow;
77 }
78
80 return true;
81}
@ LayoutTextTable
Preset text table.
A text table item that reads text from string lists.
static QgsLayoutItemTextTable * create(QgsLayout *layout)
Returns a new QgsLayoutItemTextTable for the specified parent layout.
QgsLayoutItemTextTable(QgsLayout *layout)
Constructor for QgsLayoutItemTextTable, for the specified layout.
QString displayName() const override
Returns the multiframe display name.
bool getTableContents(QgsLayoutTableContents &contents) override
Fetches the contents used for the cells in the table.
int type() const override
Returns unique multiframe type id.
void addRow(const QStringList &row)
Adds a row to the table.
void setContents(const QVector< QStringList > &contents)
Sets the contents of the text table.
const QgsLayout * layout() const
Returns the layout the object is attached to.
A class to display a table in the print layout, and allow the table to span over multiple frames.
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.
QgsLayoutTableColumns mColumns
Columns to show in table.
QgsLayoutTableContents & contents()
Returns the current contents of the table.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
QVector< QVariant > QgsLayoutTableRow
List of QVariants, representing a the contents of a single row in a QgsLayoutTable.