QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
21 {
22 
23 }
24 
26 {
27 
28 }
29 
30 bool QgsComposerTextTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
31 {
32  QDomElement composerTableElem = doc.createElement( "ComposerTextTable" );
33  //todo: write headers and text entries
34  bool ok = _writeXML( composerTableElem , doc );
35  elem.appendChild( composerTableElem );
36  return ok;
37 }
38 
39 bool QgsComposerTextTable::readXML( const QDomElement& itemElem, const QDomDocument& doc )
40 {
41  //todo: read headers and text entries
42  return tableReadXML( itemElem, doc );
43 }
44 
45 bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps )
46 {
47  attributeMaps.clear();
48 
49  QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
50  QStringList currentStringList;
51  for ( ; rowIt != mRowText.constEnd(); ++rowIt )
52  {
53  currentStringList = *rowIt;
54 
55  attributeMaps.push_back( QgsAttributeMap() );
56  for ( int i = 0; i < currentStringList.size(); ++i )
57  {
58  attributeMaps.last().insert( i, QVariant( currentStringList.at( i ) ) );
59  }
60  }
61 
62  return true;
63 }
64 
65 QMap<int, QString> QgsComposerTextTable::getHeaderLabels() const
66 {
67  QMap<int, QString> header;
68  QStringList::const_iterator it = mHeaderLabels.constBegin();
69  int index = 0;
70  for ( ; it != mHeaderLabels.constEnd(); ++it )
71  {
72  header.insert( index, *it );
73  ++index;
74  }
75  return header;
76 }
77 
78 
static unsigned index
QList< QStringList > mRowText
One stringlist per row.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
QMap< int, QVariant > QgsAttributeMap
Definition: qgsfeature.h:98
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom element
A class to display feature attributes in the print composer.
QgsComposerTextTable(QgsComposition *c)
QStringList mHeaderLabels
Column titles.
Graphics scene for map printing.
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
bool tableReadXML(const QDomElement &itemElem, const QDomDocument &doc)
QMap< int, QString > getHeaderLabels() const
bool getFeatureAttributes(QList< QgsAttributeMap > &attributeMaps)