[QGIS Commit] r13316 - in trunk/qgis/src: app/composer core core/composer gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Apr 15 10:57:33 EDT 2010


Author: mhugent
Date: 2010-04-15 10:57:32 -0400 (Thu, 15 Apr 2010)
New Revision: 13316

Added:
   trunk/qgis/src/core/composer/qgscomposerattributetable.cpp
   trunk/qgis/src/core/composer/qgscomposerattributetable.h
   trunk/qgis/src/core/composer/qgscomposertexttable.cpp
   trunk/qgis/src/core/composer/qgscomposertexttable.h
Modified:
   trunk/qgis/src/app/composer/qgscomposer.cpp
   trunk/qgis/src/app/composer/qgscomposer.h
   trunk/qgis/src/app/composer/qgscomposertablewidget.cpp
   trunk/qgis/src/app/composer/qgscomposertablewidget.h
   trunk/qgis/src/core/CMakeLists.txt
   trunk/qgis/src/core/composer/qgscomposertable.cpp
   trunk/qgis/src/core/composer/qgscomposertable.h
   trunk/qgis/src/gui/qgscomposerview.cpp
   trunk/qgis/src/gui/qgscomposerview.h
Log:
Refactor composer table to a base class that has vector attribute table and normal text table as subclasses

Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -35,7 +35,7 @@
 #include "qgscomposerscalebarwidget.h"
 #include "qgscomposershape.h"
 #include "qgscomposershapewidget.h"
-#include "qgscomposertable.h"
+#include "qgscomposerattributetable.h"
 #include "qgscomposertablewidget.h"
 #include "qgsexception.h"
 #include "qgsproject.h"
@@ -283,7 +283,7 @@
   connect( mView, SIGNAL( composerPictureAdded( QgsComposerPicture* ) ), this, SLOT( addComposerPicture( QgsComposerPicture* ) ) );
   connect( mView, SIGNAL( composerShapeAdded( QgsComposerShape* ) ), this, SLOT( addComposerShape( QgsComposerShape* ) ) );
   connect( mView, SIGNAL( composerArrowAdded( QgsComposerArrow* ) ), this, SLOT( addComposerArrow( QgsComposerArrow* ) ) );
-  connect( mView, SIGNAL( composerTableAdded( QgsComposerTable* ) ), this, SLOT( addComposerTable( QgsComposerTable* ) ) );
+  connect( mView, SIGNAL( composerTableAdded( QgsComposerAttributeTable* ) ), this, SLOT( addComposerTable( QgsComposerAttributeTable* ) ) );
   connect( mView, SIGNAL( actionFinished() ), this, SLOT( setSelectionTool() ) );
 }
 
@@ -1263,11 +1263,11 @@
   }
 
   //composer tables
-  QDomNodeList composerTableList = composerElem.elementsByTagName( "ComposerTable" );
+  QDomNodeList composerTableList = composerElem.elementsByTagName( "ComposerAttributeTable" );
   for ( int i = 0; i < composerTableList.size(); ++i )
   {
     QDomElement currentTableElem = composerTableList.at( i ).toElement();
-    QgsComposerTable* newTable = new QgsComposerTable( mComposition );
+    QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( mComposition );
     newTable->readXML( currentTableElem, doc );
     addComposerTable( newTable );
     mComposition->addItem( newTable );
@@ -1373,7 +1373,7 @@
   mItemWidgetMap.insert( shape, sWidget );
 }
 
-void QgsComposer::addComposerTable( QgsComposerTable* table )
+void QgsComposer::addComposerTable( QgsComposerAttributeTable* table )
 {
   if ( !table )
   {

Modified: trunk/qgis/src/app/composer/qgscomposer.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.h	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/app/composer/qgscomposer.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -29,7 +29,7 @@
 class QgsComposerPicture;
 class QgsComposerScaleBar;
 class QgsComposerShape;
-class QgsComposerTable;
+class QgsComposerAttributeTable;
 class QgsComposerView;
 class QgsComposition;
 class QgsMapCanvas;
@@ -223,7 +223,7 @@
     void addComposerShape( QgsComposerShape* shape );
 
     /**Adds a composer table to the item/widget map and creates a configuration widget*/
-    void addComposerTable( QgsComposerTable* table );
+    void addComposerTable( QgsComposerAttributeTable* table );
 
     /**Removes item from the item/widget map and deletes the configuration widget*/
     void deleteItem( QgsComposerItem* item );

Modified: trunk/qgis/src/app/composer/qgscomposertablewidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposertablewidget.cpp	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/app/composer/qgscomposertablewidget.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -18,14 +18,14 @@
 #include "qgscomposertablewidget.h"
 #include "qgsattributeselectiondialog.h"
 #include "qgscomposeritemwidget.h"
-#include "qgscomposertable.h"
+#include "qgscomposerattributetable.h"
 #include "qgscomposermap.h"
 #include "qgsmaplayerregistry.h"
 #include "qgsvectorlayer.h"
 #include <QColorDialog>
 #include <QFontDialog>
 
-QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerTable* table ): QWidget( 0 ), mComposerTable( table )
+QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table ): QWidget( 0 ), mComposerTable( table )
 {
   setupUi( this );
   //add widget for general composer item properties

Modified: trunk/qgis/src/app/composer/qgscomposertablewidget.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposertablewidget.h	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/app/composer/qgscomposertablewidget.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -20,17 +20,17 @@
 
 #include "ui_qgscomposertablewidgetbase.h"
 
-class QgsComposerTable;
+class QgsComposerAttributeTable;
 
 class QgsComposerTableWidget: public QWidget, private Ui::QgsComposerTableWidgetBase
 {
     Q_OBJECT
   public:
-    QgsComposerTableWidget( QgsComposerTable* table );
+    QgsComposerTableWidget( QgsComposerAttributeTable* table );
     ~QgsComposerTableWidget();
 
   private:
-    QgsComposerTable* mComposerTable;
+    QgsComposerAttributeTable* mComposerTable;
 
     /**Sets the GUI elements to the values of mComposerTable*/
     void updateGuiElements();

Modified: trunk/qgis/src/core/CMakeLists.txt
===================================================================
--- trunk/qgis/src/core/CMakeLists.txt	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/core/CMakeLists.txt	2010-04-15 14:57:32 UTC (rev 13316)
@@ -95,6 +95,8 @@
   composer/qgscomposerpicture.cpp
   composer/qgscomposermap.cpp
   composer/qgscomposertable.cpp
+  composer/qgscomposerattributetable.cpp
+  composer/qgscomposertexttable.cpp
   composer/qgscomposerscalebar.cpp
   composer/qgscomposershape.cpp
   composer/qgslegendmodel.cpp
@@ -238,7 +240,7 @@
   composer/qgscomposeritem.h
   composer/qgscomposeritemgroup.h
   composer/qgscomposershape.h
-  composer/qgscomposertable.h
+  composer/qgscomposerattributetable.h
   composer/qgscomposition.h
 
   composer/qgslegendmodel.h

Added: trunk/qgis/src/core/composer/qgscomposerattributetable.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerattributetable.cpp	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposerattributetable.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -0,0 +1,284 @@
+/***************************************************************************
+                         qgscomposerattributetable.cpp
+                         -----------------------------
+    begin                : April 2010
+    copyright            : (C) 2010 by Marco Hugentobler
+    email                : marco at hugis dot net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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 "qgscomposerattributetable.h"
+#include "qgscomposermap.h"
+#include "qgsmaplayerregistry.h"
+#include "qgsvectorlayer.h"
+
+QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ): QgsComposerTable( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), \
+    mMaximumNumberOfFeatures( 5 ), mShowOnlyVisibleFeatures( true )
+{
+
+}
+
+QgsComposerAttributeTable::~QgsComposerAttributeTable()
+{
+
+}
+
+void QgsComposerAttributeTable::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
+{
+  if ( mComposerMap && mComposerMap->isDrawing() )
+  {
+    return;
+  }
+  QgsComposerTable::paint( painter, itemStyle, pWidget );
+}
+
+void QgsComposerAttributeTable::initializeAliasMap()
+{
+  mFieldAliasMap.clear();
+  if ( mVectorLayer )
+  {
+    QgsFieldMap fieldMap = mVectorLayer->pendingFields();
+    QgsFieldMap::const_iterator it = fieldMap.constBegin();
+    for ( ; it != fieldMap.constEnd(); ++it )
+    {
+      QString currentAlias = mVectorLayer->attributeAlias( it.key() );
+      if ( !currentAlias.isEmpty() )
+      {
+        mFieldAliasMap.insert( it.key(), currentAlias );
+      }
+    }
+  }
+}
+
+void QgsComposerAttributeTable::setVectorLayer( QgsVectorLayer* vl )
+{
+  if ( vl != mVectorLayer )
+  {
+    mDisplayAttributes.clear();
+    mVectorLayer = vl;
+    initializeAliasMap();
+  }
+}
+
+void QgsComposerAttributeTable::setComposerMap( const QgsComposerMap* map )
+{
+  if ( mComposerMap )
+  {
+    QObject::disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( repaint() ) );
+  }
+  mComposerMap = map;
+  if ( mComposerMap )
+  {
+    QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( repaint() ) );
+  }
+}
+
+bool QgsComposerAttributeTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes )
+{
+  if ( !mVectorLayer )
+  {
+    return false;
+  }
+  attributes.clear();
+
+  QgsRectangle selectionRect;
+  if ( mComposerMap && mShowOnlyVisibleFeatures )
+  {
+    selectionRect = mComposerMap->extent();
+  }
+
+  if ( mDisplayAttributes.size() < 1 )
+  {
+    mVectorLayer->select( mVectorLayer->pendingAllAttributesList(), selectionRect, false, true );
+  }
+  else
+  {
+    mVectorLayer->select( mDisplayAttributes.toList(), selectionRect, false, true );
+  }
+  QgsFeature f;
+  int counter = 0;
+  while ( mVectorLayer->nextFeature( f ) && counter < mMaximumNumberOfFeatures )
+  {
+    attributes.push_back( f.attributeMap() );
+    ++counter;
+  }
+  return true;
+}
+
+QMap<int, QString> QgsComposerAttributeTable::getHeaderLabels() const
+{
+  QMap<int, QString> header;
+  if ( mVectorLayer )
+  {
+    QgsFieldMap vectorFields = mVectorLayer->pendingFields();
+    QgsFieldMap::const_iterator fieldIt = vectorFields.constBegin();
+    for ( ; fieldIt != vectorFields.constEnd(); ++fieldIt )
+    {
+      if ( mDisplayAttributes.size() > 0 && !mDisplayAttributes.contains( fieldIt.key() ) )
+      {
+        continue;
+      }
+      header.insert( fieldIt.key(), attributeDisplayName( fieldIt.key(), fieldIt.value().name() ) );
+    }
+  }
+  return header;
+}
+
+QString QgsComposerAttributeTable::attributeDisplayName( int attributeIndex, const QString& name ) const
+{
+  QMap<int, QString>::const_iterator it = mFieldAliasMap.find( attributeIndex );
+  if ( it != mFieldAliasMap.constEnd() )
+  {
+    return it.value();
+  }
+  else
+  {
+    return name;
+  }
+}
+
+void QgsComposerAttributeTable::setSceneRect( const QRectF& rectangle )
+{
+  double titleHeight =  2 * mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mHeaderFont );
+  double attributeHeight = mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mContentFont );
+  if (( rectangle.height() - titleHeight ) > 0 )
+  {
+    mMaximumNumberOfFeatures = ( rectangle.height() - titleHeight ) / attributeHeight;
+  }
+  else
+  {
+    mMaximumNumberOfFeatures = 0;
+  }
+  QgsComposerItem::setSceneRect( rectangle );
+  emit maximumNumerOfFeaturesChanged( mMaximumNumberOfFeatures );
+}
+
+bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
+{
+  QDomElement composerTableElem = doc.createElement( "ComposerAttributeTable" );
+  composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
+
+  if ( mComposerMap )
+  {
+    composerTableElem.setAttribute( "composerMap", mComposerMap->id() );
+  }
+  else
+  {
+    composerTableElem.setAttribute( "composerMap", -1 );
+  }
+  if ( mVectorLayer )
+  {
+    composerTableElem.setAttribute( "vectorLayer", mVectorLayer->getLayerID() );
+  }
+
+  //display attributes
+  QDomElement displayAttributesElem = doc.createElement( "displayAttributes" );
+  QSet<int>::const_iterator attIt = mDisplayAttributes.constBegin();
+  for ( ; attIt != mDisplayAttributes.constEnd(); ++attIt )
+  {
+    QDomElement attributeIndexElem = doc.createElement( "attributeEntry" );
+    attributeIndexElem.setAttribute( "index", *attIt );
+    displayAttributesElem.appendChild( attributeIndexElem );
+  }
+  composerTableElem.appendChild( displayAttributesElem );
+
+  //alias map
+  QDomElement aliasMapElem = doc.createElement( "attributeAliasMap" );
+  QMap<int, QString>::const_iterator aliasIt = mFieldAliasMap.constBegin();
+  for ( ; aliasIt != mFieldAliasMap.constEnd(); ++aliasIt )
+  {
+    QDomElement mapEntryElem = doc.createElement( "aliasEntry" );
+    mapEntryElem.setAttribute( "key", aliasIt.key() );
+    mapEntryElem.setAttribute( "value", aliasIt.value() );
+    aliasMapElem.appendChild( mapEntryElem );
+  }
+  composerTableElem.appendChild( aliasMapElem );
+  bool ok = tableWriteXML( composerTableElem, doc );
+  elem.appendChild( composerTableElem );
+  return ok;
+}
+
+bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDomDocument& doc )
+{
+  if ( itemElem.isNull() )
+  {
+    return false;
+  }
+
+  mMaximumNumberOfFeatures = itemElem.attribute( "maxFeatures", "5" ).toInt();
+  mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();
+
+  //composer map
+  int composerMapId = itemElem.attribute( "composerMap", "-1" ).toInt();
+  if ( composerMapId == -1 )
+  {
+    mComposerMap = 0;
+  }
+
+  if ( composition() )
+  {
+    mComposerMap = composition()->getComposerMapById( composerMapId );
+  }
+  else
+  {
+    mComposerMap = 0;
+  }
+
+  //vector layer
+  QString layerId = itemElem.attribute( "vectorLayer", "not_existing" );
+  if ( layerId == "not_existing" )
+  {
+    mVectorLayer = 0;
+  }
+  else
+  {
+    QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
+    if ( ml )
+    {
+      mVectorLayer = dynamic_cast<QgsVectorLayer*>( ml );
+    }
+  }
+
+  //restore display attribute map
+  mDisplayAttributes.clear();
+  QDomNodeList displayAttributeList = itemElem.elementsByTagName( "displayAttributes" );
+  if ( displayAttributeList.size() > 0 )
+  {
+    QDomElement displayAttributesElem =  displayAttributeList.at( 0 ).toElement();
+    QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName( "attributeEntry" );
+    for ( int i = 0; i < attributeEntryList.size(); ++i )
+    {
+      QDomElement attributeEntryElem = attributeEntryList.at( i ).toElement();
+      int index = attributeEntryElem.attribute( "index", "-1" ).toInt();
+      if ( index != -1 )
+      {
+        mDisplayAttributes.insert( index );
+      }
+    }
+  }
+
+  //restore alias map
+  mFieldAliasMap.clear();
+  QDomNodeList aliasMapNodeList = itemElem.elementsByTagName( "attributeAliasMap" );
+  if ( aliasMapNodeList.size() > 0 )
+  {
+    QDomElement attributeAliasMapElem = aliasMapNodeList.at( 0 ).toElement();
+    QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName( "aliasEntry" );
+    for ( int i = 0; i < aliasMepEntryList.size(); ++i )
+    {
+      QDomElement aliasEntryElem = aliasMepEntryList.at( i ).toElement();
+      int key = aliasEntryElem.attribute( "key", "-1" ).toInt();
+      QString value = aliasEntryElem.attribute( "value", "" );
+      mFieldAliasMap.insert( key, value );
+    }
+  }
+  return tableReadXML( itemElem, doc );
+}

Added: trunk/qgis/src/core/composer/qgscomposerattributetable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerattributetable.h	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposerattributetable.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -0,0 +1,92 @@
+/***************************************************************************
+                         qgscomposerattributetable.h
+                         ---------------------------
+    begin                : April 2010
+    copyright            : (C) 2010 by Marco Hugentobler
+    email                : marco at hugis dot net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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 QGSCOMPOSERATTRIBUTETABLE_H
+#define QGSCOMPOSERATTRIBUTETABLE_H
+
+#include "qgscomposertable.h"
+
+class QgsComposerMap;
+class QgsVectorLayer;
+
+/**A table class that displays a vector attribute table*/
+class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
+{
+    Q_OBJECT
+  public:
+    QgsComposerAttributeTable( QgsComposition* composition );
+    ~QgsComposerAttributeTable();
+
+    /** \brief Reimplementation of QCanvasItem::paint*/
+    virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+    void setVectorLayer( QgsVectorLayer* vl );// { mVectorLayer = vl; }
+    const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
+
+    void setComposerMap( const QgsComposerMap* map );
+    const QgsComposerMap* composerMap() const { return mComposerMap; }
+
+    void setMaximumNumberOfFeatures( int nr ) { mMaximumNumberOfFeatures = nr; }
+    int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
+
+    void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
+    bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
+
+    QSet<int> displayAttributes() const { return mDisplayAttributes; }
+    void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr;}
+
+    QMap<int, QString> fieldAliasMap() const { return mFieldAliasMap; }
+    void setFieldAliasMap( const QMap<int, QString>& map ) { mFieldAliasMap = map; }
+
+    /**Adapts mMaximumNumberOfFeatures depending on the rectangle height*/
+    void setSceneRect( const QRectF& rectangle );
+
+  protected:
+    /**Retrieves feature attributes*/
+    bool getFeatureAttributes( QList<QgsAttributeMap>& attributes );
+    QMap<int, QString> getHeaderLabels() const;
+
+  private:
+    /**Associated vector layer*/
+    QgsVectorLayer* mVectorLayer;
+    /**Associated composer map (used to display the visible features)*/
+    const QgsComposerMap* mComposerMap;
+    /**Maximum number of features that is displayed*/
+    int mMaximumNumberOfFeatures;
+
+    /**Shows only the features that are visible in the associated composer map (true by default)*/
+    bool mShowOnlyVisibleFeatures;
+
+    /**List of attribute indices to display (or all attributes if list is empty)*/
+    QSet<int> mDisplayAttributes;
+    /**Map of attribute name aliases. The aliases might be different to those of QgsVectorLayer (but those from the vector layer are the default)*/
+    QMap<int, QString> mFieldAliasMap;
+
+    /**Inserts aliases from vector layer as starting configuration to the alias map*/
+    void initializeAliasMap();
+    /**Returns the attribute name to display in the item (attribute name or an alias if present)*/
+    QString attributeDisplayName( int attributeIndex, const QString& name ) const;
+
+  signals:
+    /**This signal is emitted if the maximum number of feature changes (interactively)*/
+    void maximumNumerOfFeaturesChanged( int n );
+};
+
+#endif // QGSCOMPOSERATTRIBUTETABLE_H

Modified: trunk/qgis/src/core/composer/qgscomposertable.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertable.cpp	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/core/composer/qgscomposertable.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -16,14 +16,10 @@
  ***************************************************************************/
 
 #include "qgscomposertable.h"
-#include "qgscomposermap.h"
 #include "qgslogger.h"
-#include "qgsmaplayerregistry.h"
-#include "qgsvectorlayer.h"
 #include <QPainter>
 
-QgsComposerTable::QgsComposerTable( QgsComposition* composition ): QgsComposerItem( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), \
-    mMaximumNumberOfFeatures( 5 ), mLineTextDistance( 1.0 ), mShowGrid( true ), mGridStrokeWidth( 0.5 ), mGridColor( QColor( 0, 0, 0 ) ), mShowOnlyVisibleFeatures( true )
+QgsComposerTable::QgsComposerTable( QgsComposition* composition ): QgsComposerItem( composition ), mLineTextDistance( 1.0 ), mShowGrid( true ), mGridStrokeWidth( 0.5 ), mGridColor( QColor( 0, 0, 0 ) )
 {
 
 }
@@ -33,47 +29,6 @@
 
 }
 
-void QgsComposerTable::initializeAliasMap()
-{
-  mFieldAliasMap.clear();
-  if ( mVectorLayer )
-  {
-    QgsFieldMap fieldMap = mVectorLayer->pendingFields();
-    QgsFieldMap::const_iterator it = fieldMap.constBegin();
-    for ( ; it != fieldMap.constEnd(); ++it )
-    {
-      QString currentAlias = mVectorLayer->attributeAlias( it.key() );
-      if ( !currentAlias.isEmpty() )
-      {
-        mFieldAliasMap.insert( it.key(), currentAlias );
-      }
-    }
-  }
-}
-
-void QgsComposerTable::setComposerMap( const QgsComposerMap* map )
-{
-  if ( mComposerMap )
-  {
-    QObject::disconnect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( repaint() ) );
-  }
-  mComposerMap = map;
-  if ( mComposerMap )
-  {
-    QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( repaint() ) );
-  }
-}
-
-void QgsComposerTable::setVectorLayer( QgsVectorLayer* vl )
-{
-  if ( vl != mVectorLayer )
-  {
-    mDisplayAttributes.clear();
-    mVectorLayer = vl;
-    initializeAliasMap();
-  }
-}
-
 void QgsComposerTable::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
 {
   if ( !painter )
@@ -81,11 +36,6 @@
     return;
   }
 
-  if ( mComposerMap && mComposerMap->isDrawing() )
-  {
-    return;
-  }
-
   //getFeatureAttributes
   QList<QgsAttributeMap> attributeList;
   if ( !getFeatureAttributes( attributeList ) )
@@ -96,7 +46,7 @@
   QMap<int, double> maxColumnWidthMap;
   //check how much space each column needs
   calculateMaxColumnWidths( maxColumnWidthMap, attributeList );
-  //adapt item fram to max width / height
+  //adapt item frame to max width / height
   adaptItemFrame( maxColumnWidthMap, attributeList );
 
   drawBackground( painter );
@@ -105,19 +55,16 @@
   double currentX = mGridStrokeWidth;
   double currentY;
 
-  QgsFieldMap vectorFields = mVectorLayer->pendingFields();
-  QgsFieldMap::const_iterator fieldIt = vectorFields.constBegin();
-  for ( ; fieldIt != vectorFields.constEnd(); ++fieldIt )
+  QMap<int, QString> headerMap = getHeaderLabels();
+  QMap<int, QString>::const_iterator columnIt = headerMap.constBegin();
+
+  for ( ; columnIt != headerMap.constEnd(); ++columnIt )
   {
-    if ( mDisplayAttributes.size() > 0 && !mDisplayAttributes.contains( fieldIt.key() ) )
-    {
-      continue;
-    }
     currentY = mGridStrokeWidth;
     currentY += mLineTextDistance;
     currentY += fontAscentMillimeters( mHeaderFont );
     currentX += mLineTextDistance;
-    drawText( painter, currentX, currentY, attributeDisplayName( fieldIt.key(), fieldIt.value().name() ), mHeaderFont );
+    drawText( painter, currentX, currentY, columnIt.value(), mHeaderFont );
 
     currentY += mLineTextDistance;
     currentY += mGridStrokeWidth;
@@ -130,7 +77,7 @@
       currentY += mLineTextDistance;
 
       QgsAttributeMap currentAttributeMap = *attIt;
-      QgsAttributeMap::const_iterator attMapIt = currentAttributeMap.find( fieldIt.key() );
+      QgsAttributeMap::const_iterator attMapIt = currentAttributeMap.find( columnIt.key() );
       if ( attMapIt != currentAttributeMap.constEnd() )
       {
         drawText( painter, currentX, currentY, attMapIt.value().toString(), mContentFont );
@@ -139,7 +86,7 @@
       currentY += mGridStrokeWidth;
     }
 
-    currentX += maxColumnWidthMap[fieldIt.key()];
+    currentX += maxColumnWidthMap[columnIt.key()];
     currentX += mLineTextDistance;
     currentX += mGridStrokeWidth;
   }
@@ -163,74 +110,31 @@
   }
 }
 
-bool QgsComposerTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
+bool QgsComposerTable::tableWriteXML( QDomElement& elem, QDomDocument & doc ) const
 {
-  QDomElement composerTableElem = doc.createElement( "ComposerTable" );
-  composerTableElem.setAttribute( "maxFeatures", mMaximumNumberOfFeatures );
-  composerTableElem.setAttribute( "lineTextDist", mLineTextDistance );
-  composerTableElem.setAttribute( "headerFont", mHeaderFont.toString() );
-  composerTableElem.setAttribute( "contentFont", mContentFont.toString() );
-  composerTableElem.setAttribute( "gridStrokeWidth", mGridStrokeWidth );
-  composerTableElem.setAttribute( "gridColorRed", mGridColor.red() );
-  composerTableElem.setAttribute( "gridColorGreen", mGridColor.green() );
-  composerTableElem.setAttribute( "gridColorBlue", mGridColor.blue() );
-  composerTableElem.setAttribute( "showGrid", mShowGrid );
-  composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
-
-  if ( mComposerMap )
-  {
-    composerTableElem.setAttribute( "composerMap", mComposerMap->id() );
-  }
-  else
-  {
-    composerTableElem.setAttribute( "composerMap", -1 );
-  }
-  if ( mVectorLayer )
-  {
-    composerTableElem.setAttribute( "vectorLayer", mVectorLayer->getLayerID() );
-  }
-
-  //display attributes
-  QDomElement displayAttributesElem = doc.createElement( "displayAttributes" );
-  QSet<int>::const_iterator attIt = mDisplayAttributes.constBegin();
-  for ( ; attIt != mDisplayAttributes.constEnd(); ++attIt )
-  {
-    QDomElement attributeIndexElem = doc.createElement( "attributeEntry" );
-    attributeIndexElem.setAttribute( "index", *attIt );
-    displayAttributesElem.appendChild( attributeIndexElem );
-  }
-  composerTableElem.appendChild( displayAttributesElem );
-
-  //alias map
-  QDomElement aliasMapElem = doc.createElement( "attributeAliasMap" );
-  QMap<int, QString>::const_iterator aliasIt = mFieldAliasMap.constBegin();
-  for ( ; aliasIt != mFieldAliasMap.constEnd(); ++aliasIt )
-  {
-    QDomElement mapEntryElem = doc.createElement( "aliasEntry" );
-    mapEntryElem.setAttribute( "key", aliasIt.key() );
-    mapEntryElem.setAttribute( "value", aliasIt.value() );
-    aliasMapElem.appendChild( mapEntryElem );
-  }
-  composerTableElem.appendChild( aliasMapElem );
-
-  elem.appendChild( composerTableElem );
-  return _writeXML( composerTableElem, doc );
+  elem.setAttribute( "lineTextDist", mLineTextDistance );
+  elem.setAttribute( "headerFont", mHeaderFont.toString() );
+  elem.setAttribute( "contentFont", mContentFont.toString() );
+  elem.setAttribute( "gridStrokeWidth", mGridStrokeWidth );
+  elem.setAttribute( "gridColorRed", mGridColor.red() );
+  elem.setAttribute( "gridColorGreen", mGridColor.green() );
+  elem.setAttribute( "gridColorBlue", mGridColor.blue() );
+  elem.setAttribute( "showGrid", mShowGrid );
+  return _writeXML( elem, doc );
 }
 
-bool QgsComposerTable::readXML( const QDomElement& itemElem, const QDomDocument& doc )
+bool QgsComposerTable::tableReadXML( const QDomElement& itemElem, const QDomDocument& doc )
 {
   if ( itemElem.isNull() )
   {
     return false;
   }
 
-  mMaximumNumberOfFeatures = itemElem.attribute( "maxFeatures", "5" ).toInt();
   mHeaderFont.fromString( itemElem.attribute( "headerFont", "" ) );
   mContentFont.fromString( itemElem.attribute( "contentFont", "" ) );
   mLineTextDistance = itemElem.attribute( "lineTextDist", "1.0" ).toDouble();
   mGridStrokeWidth = itemElem.attribute( "gridStrokeWidth", "0.5" ).toDouble();
   mShowGrid = itemElem.attribute( "showGrid", "1" ).toInt();
-  mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();
 
   //grid color
   int gridRed = itemElem.attribute( "gridColorRed", "0" ).toInt();
@@ -238,71 +142,6 @@
   int gridBlue = itemElem.attribute( "gridColorBlue", "0" ).toInt();
   mGridColor = QColor( gridRed, gridGreen, gridBlue );
 
-  //composer map
-  int composerMapId = itemElem.attribute( "composerMap", "-1" ).toInt();
-  if ( composerMapId == -1 )
-  {
-    mComposerMap = 0;
-  }
-
-  if ( composition() )
-  {
-    mComposerMap = composition()->getComposerMapById( composerMapId );
-  }
-  else
-  {
-    mComposerMap = 0;
-  }
-
-  //vector layer
-  QString layerId = itemElem.attribute( "vectorLayer", "not_existing" );
-  if ( layerId == "not_existing" )
-  {
-    mVectorLayer = 0;
-  }
-  else
-  {
-    QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
-    if ( ml )
-    {
-      mVectorLayer = dynamic_cast<QgsVectorLayer*>( ml );
-    }
-  }
-
-  //restore display attribute map
-  mDisplayAttributes.clear();
-  QDomNodeList displayAttributeList = itemElem.elementsByTagName( "displayAttributes" );
-  if ( displayAttributeList.size() > 0 )
-  {
-    QDomElement displayAttributesElem =  displayAttributeList.at( 0 ).toElement();
-    QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName( "attributeEntry" );
-    for ( int i = 0; i < attributeEntryList.size(); ++i )
-    {
-      QDomElement attributeEntryElem = attributeEntryList.at( i ).toElement();
-      int index = attributeEntryElem.attribute( "index", "-1" ).toInt();
-      if ( index != -1 )
-      {
-        mDisplayAttributes.insert( index );
-      }
-    }
-  }
-
-  //restore alias map
-  mFieldAliasMap.clear();
-  QDomNodeList aliasMapNodeList = itemElem.elementsByTagName( "attributeAliasMap" );
-  if ( aliasMapNodeList.size() > 0 )
-  {
-    QDomElement attributeAliasMapElem = aliasMapNodeList.at( 0 ).toElement();
-    QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName( "aliasEntry" );
-    for ( int i = 0; i < aliasMepEntryList.size(); ++i )
-    {
-      QDomElement aliasEntryElem = aliasMepEntryList.at( i ).toElement();
-      int key = aliasEntryElem.attribute( "key", "-1" ).toInt();
-      QString value = aliasEntryElem.attribute( "value", "" );
-      mFieldAliasMap.insert( key, value );
-    }
-  }
-
   //restore general composer item properties
   QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
   if ( composerItemList.size() > 0 )
@@ -313,58 +152,16 @@
   return true;
 }
 
-bool QgsComposerTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes )
-{
-  if ( !mVectorLayer )
-  {
-    return false;
-  }
-  attributes.clear();
-
-  QgsRectangle selectionRect;
-  if ( mComposerMap && mShowOnlyVisibleFeatures )
-  {
-    selectionRect = mComposerMap->extent();
-  }
-
-  if ( mDisplayAttributes.size() < 1 )
-  {
-    mVectorLayer->select( mVectorLayer->pendingAllAttributesList(), selectionRect, false, true );
-  }
-  else
-  {
-    mVectorLayer->select( mDisplayAttributes.toList(), selectionRect, false, true );
-  }
-  QgsFeature f;
-  int counter = 0;
-  while ( mVectorLayer->nextFeature( f ) && counter < mMaximumNumberOfFeatures )
-  {
-    attributes.push_back( f.attributeMap() );
-    ++counter;
-  }
-  return true;
-}
-
 bool QgsComposerTable::calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const
 {
   maxWidthMap.clear();
-  if ( !mVectorLayer )
+  QMap<int, QString> headerMap = getHeaderLabels();
+  QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
+  for ( ; headerIt != headerMap.constEnd(); ++headerIt )
   {
-    return false;
+    maxWidthMap.insert( headerIt.key(), textWidthMillimeters( mHeaderFont, headerIt.value() ) );
   }
 
-  QgsFieldMap vectorFields = mVectorLayer->pendingFields();
-
-  //initialize max width map with attribute names
-  QgsFieldMap::const_iterator fieldIt = vectorFields.constBegin();
-  for ( ; fieldIt != vectorFields.constEnd(); ++fieldIt )
-  {
-    if ( mDisplayAttributes.size() < 1 || mDisplayAttributes.contains( fieldIt.key() ) )
-    {
-      maxWidthMap.insert( fieldIt.key(), textWidthMillimeters( mHeaderFont, attributeDisplayName( fieldIt.key(), fieldIt.value().name() ) ) );
-    }
-  }
-
   //go through all the attributes and adapt the max width values
   QList<QgsAttributeMap>::const_iterator attIt = attributeList.constBegin();
 
@@ -387,6 +184,10 @@
   return true;
 }
 
+
+
+
+
 void QgsComposerTable::adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList )
 {
   //calculate height
@@ -439,32 +240,5 @@
   }
 }
 
-QString QgsComposerTable::attributeDisplayName( int attributeIndex, const QString& name ) const
-{
-  QMap<int, QString>::const_iterator it = mFieldAliasMap.find( attributeIndex );
-  if ( it != mFieldAliasMap.constEnd() )
-  {
-    return it.value();
-  }
-  else
-  {
-    return name;
-  }
-}
 
-void QgsComposerTable::setSceneRect( const QRectF& rectangle )
-{
-  double titleHeight =  2 * mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mHeaderFont );
-  double attributeHeight = mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mContentFont );
-  if (( rectangle.height() - titleHeight ) > 0 )
-  {
-    mMaximumNumberOfFeatures = ( rectangle.height() - titleHeight ) / attributeHeight;
-  }
-  else
-  {
-    mMaximumNumberOfFeatures = 0;
-  }
-  QgsComposerItem::setSceneRect( rectangle );
-  emit maximumNumerOfFeaturesChanged( mMaximumNumberOfFeatures );
-}
 

Modified: trunk/qgis/src/core/composer/qgscomposertable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertable.h	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/core/composer/qgscomposertable.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -22,32 +22,21 @@
 #include "qgsfeature.h"
 #include <QSet>
 
-class QgsComposerMap;
-class QgsVectorLayer;
 
+
 /**A class to display feature attributes in the print composer*/
 class CORE_EXPORT QgsComposerTable: public QgsComposerItem
 {
-    Q_OBJECT
   public:
     QgsComposerTable( QgsComposition* composition );
-    ~QgsComposerTable();
+    virtual ~QgsComposerTable();
 
     /** \brief Reimplementation of QCanvasItem::paint*/
-    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+    virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
 
-    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
-    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+    virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
+    virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
 
-    void setVectorLayer( QgsVectorLayer* vl );// { mVectorLayer = vl; }
-    const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
-
-    void setComposerMap( const QgsComposerMap* map );
-    const QgsComposerMap* composerMap() const { return mComposerMap; }
-
-    void setMaximumNumberOfFeatures( int nr ) { mMaximumNumberOfFeatures = nr; }
-    int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
-
     void setLineTextDistance( double d ) { mLineTextDistance = d; }
     double lineTextDistance() const { return mLineTextDistance; }
 
@@ -66,25 +55,7 @@
     void setGridColor( const QColor& c ) { mGridColor = c; }
     QColor gridColor() const { return mGridColor; }
 
-    void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
-    bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
-
-    QSet<int> displayAttributes() const { return mDisplayAttributes; }
-    void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr;}
-
-    QMap<int, QString> fieldAliasMap() const { return mFieldAliasMap; }
-    void setFieldAliasMap( const QMap<int, QString>& map ) { mFieldAliasMap = map; }
-
-    /**Adapts mMaximumNumberOfFeatures depending on the rectangle height*/
-    void setSceneRect( const QRectF& rectangle );
-
-  private:
-    /**Associated vector layer*/
-    QgsVectorLayer* mVectorLayer;
-    /**Associated composer map (used to display the visible features)*/
-    const QgsComposerMap* mComposerMap;
-    /**Maximum number of features that is displayed*/
-    int mMaximumNumberOfFeatures;
+  protected:
     /**Distance between table lines and text*/
     double mLineTextDistance;
 
@@ -94,30 +65,19 @@
     bool mShowGrid;
     double mGridStrokeWidth;
     QColor mGridColor;
-    /**Shows only the features that are visible in the associated composer map (true by default)*/
-    bool mShowOnlyVisibleFeatures;
 
-    /**List of attribute indices to display (or all attributes if list is empty)*/
-    QSet<int> mDisplayAttributes;
-    /**Map of attribute name aliases. The aliases might be different to those of QgsVectorLayer (but those from the vector layer are the default)*/
-    QMap<int, QString> mFieldAliasMap;
-
     /**Retrieves feature attributes*/
-    bool getFeatureAttributes( QList<QgsAttributeMap>& attributes );
+    virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ) = 0;
+    virtual QMap<int, QString> getHeaderLabels() const = 0;
     /**Calculate the maximum width values of the vector attributes*/
-    bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const;
+    virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const;
     /**Adapts the size of the item frame to match the content*/
     void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList );
     void drawHorizontalGridLines( QPainter* p, int nAttributes );
     void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
-    /**Inserts aliases from vector layer as starting configuration to the alias map*/
-    void initializeAliasMap();
-    /**Returns the attribute name to display in the item (attribute name or an alias if present)*/
-    QString attributeDisplayName( int attributeIndex, const QString& name ) const;
 
-  signals:
-    /**This signal is emitted if the maximum number of feature changes (interactively)*/
-    void maximumNumerOfFeaturesChanged( int n );
+    bool tableWriteXML( QDomElement& itemElem, QDomDocument& doc ) const;
+    bool tableReadXML( const QDomElement& itemElem, const QDomDocument& doc );
 };
 
 #endif // QGSCOMPOSERTABLE_H

Added: trunk/qgis/src/core/composer/qgscomposertexttable.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertexttable.cpp	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposertexttable.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -0,0 +1,77 @@
+/***************************************************************************
+                         qgscomposertexttable.h
+                         ----------------------
+    begin                : April 2010
+    copyright            : (C) 2010 by Marco Hugentobler
+    email                : marco at hugis dot net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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 "qgscomposertexttable.h"
+
+QgsComposerTextTable::QgsComposerTextTable( QgsComposition* c ): QgsComposerTable( c )
+{
+
+}
+
+QgsComposerTextTable::~QgsComposerTextTable()
+{
+
+}
+
+bool QgsComposerTextTable::writeXML( QDomElement& elem, QDomDocument & doc ) const
+{
+  QDomElement composerTableElem = doc.createElement( "ComposerTextTable" );
+  //todo: write headers and text entries
+  bool ok = _writeXML( composerTableElem , doc );
+  elem.appendChild( composerTableElem );
+  return ok;
+}
+
+bool QgsComposerTextTable::readXML( const QDomElement& itemElem, const QDomDocument& doc )
+{
+  //todo: read headers and text entries
+  return tableReadXML( itemElem, doc );
+}
+
+bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attributes )
+{
+  attributes.clear();
+
+  QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
+  QStringList currentStringList;
+  for ( ; rowIt != mRowText.constEnd(); ++rowIt )
+  {
+    currentStringList = *rowIt;
+    QgsAttributeMap map;
+    for ( int i = 0; i < currentStringList.size(); ++i )
+    {
+      map.insert( i, QVariant( currentStringList.at( i ) ) );
+    }
+    attributes.append( map );
+  }
+  return true;
+}
+
+QMap<int, QString> QgsComposerTextTable::getHeaderLabels() const
+{
+  QMap<int, QString> header;
+  QStringList::const_iterator it = mHeaderLabels.constBegin();
+  int index = 0;
+  for ( ; it != mHeaderLabels.constEnd(); ++it )
+  {
+    header.insert( index, *it );
+    ++index;
+  }
+  return header;
+}
+
+

Added: trunk/qgis/src/core/composer/qgscomposertexttable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertexttable.h	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposertexttable.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -0,0 +1,47 @@
+/***************************************************************************
+                         qgscomposertexttable.h
+                         ----------------------
+    begin                : April 2010
+    copyright            : (C) 2010 by Marco Hugentobler
+    email                : marco at hugis dot net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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 QGSCOMPOSERTEXTTABLE_H
+#define QGSCOMPOSERTEXTTABLE_H
+
+#include "qgscomposertable.h"
+
+/**A text table item that reads text from string lists*/
+class CORE_EXPORT QgsComposerTextTable: public QgsComposerTable
+{
+  public:
+    QgsComposerTextTable( QgsComposition* c );
+    ~QgsComposerTextTable();
+
+    void setHeaderLabels( const QStringList& l ) { mHeaderLabels = l; }
+    void addRow( const QStringList& row ) { mRowText.append( row ); }
+
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+  protected:
+    bool getFeatureAttributes( QList<QgsAttributeMap>& attributes );
+    QMap<int, QString> getHeaderLabels() const;
+
+  private:
+    /**Column titles*/
+    QStringList mHeaderLabels;
+    /**One stringlist per row*/
+    QList< QStringList > mRowText;
+};
+
+#endif // QGSCOMPOSERTEXTTABLE_H

Modified: trunk/qgis/src/gui/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.cpp	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/gui/qgscomposerview.cpp	2010-04-15 14:57:32 UTC (rev 13316)
@@ -28,7 +28,7 @@
 #include "qgscomposerpicture.h"
 #include "qgscomposerscalebar.h"
 #include "qgscomposershape.h"
-#include "qgscomposertable.h"
+#include "qgscomposerattributetable.h"
 
 QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags f ) :
     QGraphicsView( parent ), mShiftKeyPressed( false ), mRubberBandItem( 0 ), mRubberBandLineItem( 0 ), mMoveContentItem( 0 )
@@ -162,7 +162,7 @@
     }
     case AddTable:
     {
-      QgsComposerTable* newTable = new QgsComposerTable( composition() );
+      QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( composition() );
       addComposerTable( newTable );
       newTable->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 50, 50 ) );
       emit actionFinished();
@@ -541,7 +541,7 @@
   emit selectedItemChanged( shape );
 }
 
-void QgsComposerView::addComposerTable( QgsComposerTable* table )
+void QgsComposerView::addComposerTable( QgsComposerAttributeTable* table )
 {
   scene()->addItem( table );
   emit composerTableAdded( table );

Modified: trunk/qgis/src/gui/qgscomposerview.h
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.h	2010-04-15 00:45:38 UTC (rev 13315)
+++ trunk/qgis/src/gui/qgscomposerview.h	2010-04-15 14:57:32 UTC (rev 13316)
@@ -32,7 +32,7 @@
 class QgsComposerPicture;
 class QgsComposerScaleBar;
 class QgsComposerShape;
-class QgsComposerTable;
+class QgsComposerAttributeTable;
 
 /** \ingroup MapComposer
  * \ingroup gui
@@ -93,7 +93,7 @@
     /**Adds a composer shape to the graphics scene and advices composer to create a widget for it (through signal)*/
     void addComposerShape( QgsComposerShape* shape );
     /**Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)*/
-    void addComposerTable( QgsComposerTable* table );
+    void addComposerTable( QgsComposerAttributeTable* table );
 
     /**Returns the composer main window*/
     QMainWindow* composerWindow();
@@ -147,7 +147,7 @@
     /**Is emitted when a new composer shape has been added*/
     void composerShapeAdded( QgsComposerShape* shape );
     /**Is emitted when a new composer table has been added*/
-    void composerTableAdded( QgsComposerTable* table );
+    void composerTableAdded( QgsComposerAttributeTable* table );
     /**Is emitted when a composer item has been removed from the scene*/
     void itemRemoved( QgsComposerItem* );
     /**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that



More information about the QGIS-commit mailing list