QGIS API Documentation  2.99.0-Master (40f86b2)
qgscomposertexttable.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposertexttable.h
3  ----------------------
4  begin : April 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco at hugis dot net
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 "qgscomposertexttable.h"
19 #include "qgscomposertablecolumn.h"
20 #include "qgscomposerframe.h"
21 #include "qgscomposition.h"
22 
24  : QgsComposerTableV2( c, createUndoCommands )
25 {
26 
27 }
28 
29 void QgsComposerTextTableV2::addRow( const QStringList &row )
30 {
31  mRowText.append( row );
33 }
34 
35 void QgsComposerTextTableV2::setContents( const QList<QStringList> &contents )
36 {
37  mRowText = contents;
39 }
40 
42 {
43  contents.clear();
44 
45  QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
46  for ( ; rowIt != mRowText.constEnd(); ++rowIt )
47  {
48  QgsComposerTableRow currentRow;
49 
50  for ( int i = 0; i < mColumns.count(); ++i )
51  {
52  if ( i < ( *rowIt ).count() )
53  {
54  currentRow << ( *rowIt ).at( i );
55  }
56  else
57  {
58  currentRow << QString();
59  }
60  }
61  contents << currentRow;
62  }
63 
65  return true;
66 }
67 
69 {
70  mFrameItems.push_back( frame );
72 
73  if ( mComposition )
74  {
75  //TODO - if QgsComposerTextTableV2 gains a UI, this will need a dedicated add method
76  //added to QgsComposition
77  mComposition->addItem( frame );
78  }
79 
80  if ( recalcFrameSizes )
81  {
83  }
84 }
bool getTableContents(QgsComposerTableContents &contents) override
Fetches the contents used for the cells in the table.
void setContents(const QList< QStringList > &contents)
Sets the contents of the text table.
void addRow(const QStringList &row)
Adds a row to the table.
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.
QList< QgsComposerTableRow > QgsComposerTableContents
List of QgsComposerTableRows, representing rows and column cell contents for a QgsComposerTable.
QList< QVariant > QgsComposerTableRow
List of QVariants, representing a the contents of a single row in a QgsComposerTable.
virtual void addFrame(QgsComposerFrame *frame, bool recalcFrameSizes=true) override
Adds a frame to the multiframe.
A class to display a table in the print composer, and allow the table to span over multiple frames...
void recalculateFrameSizes() override
Graphics scene for map printing.
Frame item for a composer multiframe item.
QgsComposition * mComposition
QgsComposerTableColumns mColumns
Columns to show in table.
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
void sizeChanged()
Emitted if the rectangle changes.
QList< QgsComposerFrame * > mFrameItems
QgsComposerTextTableV2(QgsComposition *c, bool createUndoCommands)
QgsComposerTableContents * contents()
Returns the current contents of the table.
QgsComposerFrame * frame(int i) const
Returns a child frame from the multiframe.