QGIS API Documentation  master-59fd5e0
src/core/composer/qgscomposertable.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposertable.h
00003                          ------------------
00004     begin                : January 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 #ifndef QGSCOMPOSERTABLE_H
00019 #define QGSCOMPOSERTABLE_H
00020 
00021 #include "qgscomposeritem.h"
00022 #include "qgscomposition.h"
00023 #include "qgsfeature.h"
00024 #include <QSet>
00025 
00026 
00027 
00029 class CORE_EXPORT QgsComposerTable: public QgsComposerItem
00030 {
00031   public:
00032     QgsComposerTable( QgsComposition* composition );
00033     virtual ~QgsComposerTable();
00034 
00036     virtual int type() const { return ComposerTable; }
00037 
00039     virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00040 
00041     virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
00042     virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
00043 
00044     void setLineTextDistance( double d ) { mLineTextDistance = d; }
00045     double lineTextDistance() const { return mLineTextDistance; }
00046 
00047     void setHeaderFont( const QFont& f ) { mHeaderFont = f;}
00048     QFont headerFont() const { return mHeaderFont; }
00049 
00050     void setContentFont( const QFont& f ) { mContentFont = f; }
00051     QFont contentFont() const { return mContentFont; }
00052 
00053     void setShowGrid( bool show ) { mShowGrid = show;}
00054     bool showGrid() const { return mShowGrid; }
00055 
00056     void setGridStrokeWidth( double w ) { mGridStrokeWidth = w; }
00057     double gridStrokeWidth() const { return mGridStrokeWidth; }
00058 
00059     void setGridColor( const QColor& c ) { mGridColor = c; }
00060     QColor gridColor() const { return mGridColor; }
00061 
00064     void adjustFrameToSize();
00065 
00066   protected:
00068     double mLineTextDistance;
00069 
00070     QFont mHeaderFont;
00071     QFont mContentFont;
00072 
00073     bool mShowGrid;
00074     double mGridStrokeWidth;
00075     QColor mGridColor;
00076 
00078 
00079     virtual bool getFeatureAttributes( QList<QgsAttributes>& attributes ) { Q_UNUSED( attributes ); return false; }
00080     virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0;
00082     virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributes>& attributeList ) const;
00084 
00085     void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributes>& attributeList );
00086     void drawHorizontalGridLines( QPainter* p, int nAttributes );
00088     void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
00089 
00090     bool tableWriteXML( QDomElement& itemElem, QDomDocument& doc ) const;
00091     bool tableReadXML( const QDomElement& itemElem, const QDomDocument& doc );
00092 };
00093 
00094 #endif // QGSCOMPOSERTABLE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines