Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgscomposertexttable.h 00003 ---------------------- 00004 begin : April 2010 00005 copyright : (C) 2010 by Marco Hugentobler 00006 email : marco at hugis dot net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "qgscomposertexttable.h" 00019 00020 QgsComposerTextTable::QgsComposerTextTable( QgsComposition* c ): QgsComposerTable( c ) 00021 { 00022 00023 } 00024 00025 QgsComposerTextTable::~QgsComposerTextTable() 00026 { 00027 00028 } 00029 00030 bool QgsComposerTextTable::writeXML( QDomElement& elem, QDomDocument & doc ) const 00031 { 00032 QDomElement composerTableElem = doc.createElement( "ComposerTextTable" ); 00033 //todo: write headers and text entries 00034 bool ok = _writeXML( composerTableElem , doc ); 00035 elem.appendChild( composerTableElem ); 00036 return ok; 00037 } 00038 00039 bool QgsComposerTextTable::readXML( const QDomElement& itemElem, const QDomDocument& doc ) 00040 { 00041 //todo: read headers and text entries 00042 return tableReadXML( itemElem, doc ); 00043 } 00044 00045 bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes ) 00046 { 00047 attributes.clear(); 00048 00049 QList< QStringList >::const_iterator rowIt = mRowText.constBegin(); 00050 QStringList currentStringList; 00051 for ( ; rowIt != mRowText.constEnd(); ++rowIt ) 00052 { 00053 currentStringList = *rowIt; 00054 QgsAttributeMap map; 00055 for ( int i = 0; i < currentStringList.size(); ++i ) 00056 { 00057 map.insert( i, QVariant( currentStringList.at( i ) ) ); 00058 } 00059 attributes.append( map ); 00060 } 00061 return true; 00062 } 00063 00064 QMap<int, QString> QgsComposerTextTable::getHeaderLabels() const 00065 { 00066 QMap<int, QString> header; 00067 QStringList::const_iterator it = mHeaderLabels.constBegin(); 00068 int index = 0; 00069 for ( ; it != mHeaderLabels.constEnd(); ++it ) 00070 { 00071 header.insert( index, *it ); 00072 ++index; 00073 } 00074 return header; 00075 } 00076 00077