QGIS API Documentation  2.99.0-Master (c558d51)
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 
30 {
31 
32 }
33 
34 void QgsComposerTextTableV2::addRow( const QStringList& row )
35 {
36  mRowText.append( row );
38 }
39 
40 void QgsComposerTextTableV2::setContents( const QList<QStringList>& contents )
41 {
42  mRowText = contents;
44 }
45 
47 {
48  contents.clear();
49 
50  QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
51  for ( ; rowIt != mRowText.constEnd(); ++rowIt )
52  {
53  QgsComposerTableRow currentRow;
54 
55  for ( int i = 0; i < mColumns.count(); ++i )
56  {
57  if ( i < ( *rowIt ).count() )
58  {
59  currentRow << ( *rowIt ).at( i );
60  }
61  else
62  {
63  currentRow << QString();
64  }
65  }
66  contents << currentRow;
67  }
68 
70  return true;
71 }
72 
74 {
75  mFrameItems.push_back( frame );
76  connect( frame, SIGNAL( sizeChanged() ), this, SLOT( recalculateFrameSizes() ) );
77 
78  if ( mComposition )
79  {
80  //TODO - if QgsComposerTextTableV2 gains a UI, this will need a dedicated add method
81  //added to QgsComposition
82  mComposition->addItem( frame );
83  }
84 
85  if ( recalcFrameSizes )
86  {
88  }
89 }
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.
QList< QgsComposerFrame * > mFrameItems
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.
QgsComposerFrame * frame(int i) const
Returns a child frame from the multiframe.
QgsComposerTextTableV2(QgsComposition *c, bool createUndoCommands)
QgsComposerTableContents * contents()
Returns the current contents of the table.