QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
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
18
#include "
qgslayoutitemtexttable.h
"
19
20
#include "
qgslayout.h
"
21
#include "
qgslayoutframe.h
"
22
#include "
qgslayouttablecolumn.h
"
23
24
#include "moc_qgslayoutitemtexttable.cpp"
25
26
QgsLayoutItemTextTable::QgsLayoutItemTextTable
(
QgsLayout
*
layout
)
27
:
QgsLayoutTable
(
layout
)
28
{}
29
30
int
QgsLayoutItemTextTable::type
()
const
31
{
32
return
QgsLayoutItemRegistry::LayoutTextTable
;
33
}
34
35
QString
QgsLayoutItemTextTable::displayName
()
const
36
{
37
return
tr(
"<Text table frame>"
);
38
}
39
40
QgsLayoutItemTextTable
*
QgsLayoutItemTextTable::create
(
QgsLayout
*
layout
)
41
{
42
return
new
QgsLayoutItemTextTable
(
layout
);
43
}
44
45
void
QgsLayoutItemTextTable::addRow
(
const
QStringList &row )
46
{
47
mRowText.append( row );
48
refreshAttributes
();
49
}
50
51
void
QgsLayoutItemTextTable::setContents
(
const
QVector<QStringList> &
contents
)
52
{
53
mRowText =
contents
;
54
refreshAttributes
();
55
}
56
57
bool
QgsLayoutItemTextTable::getTableContents
(
QgsLayoutTableContents
&
contents
)
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
79
recalculateTableSize
();
80
return
true
;
81
}
QgsLayoutItemRegistry::LayoutTextTable
@ LayoutTextTable
Preset text table.
Definition
qgslayoutitemregistry.h:350
QgsLayoutItemTextTable::create
static QgsLayoutItemTextTable * create(QgsLayout *layout)
Returns a new QgsLayoutItemTextTable for the specified parent layout.
Definition
qgslayoutitemtexttable.cpp:40
QgsLayoutItemTextTable::QgsLayoutItemTextTable
QgsLayoutItemTextTable(QgsLayout *layout)
Constructor for QgsLayoutItemTextTable, for the specified layout.
Definition
qgslayoutitemtexttable.cpp:26
QgsLayoutItemTextTable::displayName
QString displayName() const override
Returns the multiframe display name.
Definition
qgslayoutitemtexttable.cpp:35
QgsLayoutItemTextTable::getTableContents
bool getTableContents(QgsLayoutTableContents &contents) override
Fetches the contents used for the cells in the table.
Definition
qgslayoutitemtexttable.cpp:57
QgsLayoutItemTextTable::type
int type() const override
Returns unique multiframe type id.
Definition
qgslayoutitemtexttable.cpp:30
QgsLayoutItemTextTable::addRow
void addRow(const QStringList &row)
Adds a row to the table.
Definition
qgslayoutitemtexttable.cpp:45
QgsLayoutItemTextTable::setContents
void setContents(const QVector< QStringList > &contents)
Sets the contents of the text table.
Definition
qgslayoutitemtexttable.cpp:51
QgsLayoutMultiFrame::QgsLayout
friend class QgsLayout
Definition
qgslayoutmultiframe.h:442
QgsLayoutObject::layout
const QgsLayout * layout() const
Returns the layout the object is attached to.
Definition
qgslayoutobject.cpp:323
QgsLayoutTable::QgsLayoutTable
QgsLayoutTable(QgsLayout *layout)
Constructor for QgsLayoutTable, belonging to the specified layout.
Definition
qgslayouttable.cpp:64
QgsLayoutTable::refreshAttributes
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
Definition
qgslayouttable.cpp:1110
QgsLayoutTable::recalculateTableSize
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.
Definition
qgslayouttable.cpp:1667
QgsLayoutTable::mColumns
QgsLayoutTableColumns mColumns
Columns to show in table.
Definition
qgslayouttable.h:630
QgsLayoutTable::contents
QgsLayoutTableContents & contents()
Returns the current contents of the table.
Definition
qgslayouttable.h:565
QgsLayoutTableContents
QVector< QgsLayoutTableRow > QgsLayoutTableContents
List of QgsLayoutTableRows, representing rows and column cell contents for a QgsLayoutTable.
Definition
qgslayouttable.h:46
QgsLayoutTableRow
QVector< QVariant > QgsLayoutTableRow
List of QVariants, representing a the contents of a single row in a QgsLayoutTable.
Definition
qgslayouttable.h:38
qgslayout.h
qgslayoutframe.h
qgslayoutitemtexttable.h
qgslayouttablecolumn.h
Generated on
for QGIS API Documentation by
1.17.0