Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cf6e0a
commit 3a0f943
Showing
5 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutitemtexttable.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLayoutItemTextTable : QgsLayoutTable | ||
{ | ||
%Docstring | ||
A text table item that reads text from string lists | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutitemtexttable.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutItemTextTable( QgsLayout *layout ); | ||
%Docstring | ||
Constructor for QgsLayoutItemTextTable, for the specified ``layout``. | ||
%End | ||
|
||
void addRow( const QStringList &row ); | ||
%Docstring | ||
Adds a row to the table | ||
\param row list of strings to use for each cell's value in the newly added row | ||
.. note:: | ||
|
||
If row is shorter than the number of columns in the table than blank cells | ||
will be inserted at the end of the row. If row contains more strings then the number | ||
of columns in the table then these extra strings will be ignored. | ||
.. note:: | ||
|
||
if adding many rows, setContents() is much faster | ||
%End | ||
|
||
void setContents( const QVector< QStringList > &contents ); | ||
%Docstring | ||
Sets the contents of the text table. | ||
\param contents list of table rows | ||
.. seealso:: addRow | ||
%End | ||
|
||
virtual bool getTableContents( QgsLayoutTableContents &contents ); | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutitemtexttable.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*************************************************************************** | ||
qgslayoutitemtexttable.cpp | ||
-------------------------- | ||
begin : November 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutitemtexttable.h" | ||
#include "qgslayouttablecolumn.h" | ||
#include "qgslayoutframe.h" | ||
#include "qgslayout.h" | ||
|
||
QgsLayoutItemTextTable::QgsLayoutItemTextTable( QgsLayout *layout ) | ||
: QgsLayoutTable( layout ) | ||
{ | ||
|
||
} | ||
|
||
void QgsLayoutItemTextTable::addRow( const QStringList &row ) | ||
{ | ||
mRowText.append( row ); | ||
refreshAttributes(); | ||
} | ||
|
||
void QgsLayoutItemTextTable::setContents( const QVector<QStringList> &contents ) | ||
{ | ||
mRowText = contents; | ||
refreshAttributes(); | ||
} | ||
|
||
bool QgsLayoutItemTextTable::getTableContents( QgsLayoutTableContents &contents ) | ||
{ | ||
contents.clear(); | ||
|
||
for ( const QStringList &row : qgis::as_const( mRowText ) ) | ||
{ | ||
QgsLayoutTableRow currentRow; | ||
|
||
for ( int i = 0; i < mColumns.count(); ++i ) | ||
{ | ||
if ( i < row.count() ) | ||
{ | ||
currentRow << row.at( i ); | ||
} | ||
else | ||
{ | ||
currentRow << QString(); | ||
} | ||
} | ||
contents << currentRow; | ||
} | ||
|
||
recalculateTableSize(); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*************************************************************************** | ||
qgslayoutitemtexttable.h | ||
---------------------- | ||
begin : November 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSLAYOUTTEXTTABLE_H | ||
#define QGSLAYOUTTEXTTABLE_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis.h" | ||
#include "qgslayouttable.h" | ||
|
||
/** | ||
* \ingroup core | ||
* A text table item that reads text from string lists | ||
* \since QGIS 3.0 | ||
*/ | ||
class CORE_EXPORT QgsLayoutItemTextTable : public QgsLayoutTable | ||
{ | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for QgsLayoutItemTextTable, for the specified \a layout. | ||
*/ | ||
QgsLayoutItemTextTable( QgsLayout *layout ); | ||
|
||
/** | ||
* Adds a row to the table | ||
* \param row list of strings to use for each cell's value in the newly added row | ||
* \note If row is shorter than the number of columns in the table than blank cells | ||
* will be inserted at the end of the row. If row contains more strings then the number | ||
* of columns in the table then these extra strings will be ignored. | ||
* \note if adding many rows, setContents() is much faster | ||
*/ | ||
void addRow( const QStringList &row ); | ||
|
||
/** | ||
* Sets the contents of the text table. | ||
* \param contents list of table rows | ||
* \see addRow | ||
*/ | ||
void setContents( const QVector< QStringList > &contents ); | ||
|
||
bool getTableContents( QgsLayoutTableContents &contents ) override; | ||
|
||
private: | ||
//! One stringlist per row | ||
QVector< QStringList > mRowText; | ||
}; | ||
|
||
#endif // QGSLAYOUTTEXTTABLE_H |