Quantum GIS API Documentation
1.7.4
|
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 "qgsfeature.h" 00023 #include <QSet> 00024 00025 00026 00028 class CORE_EXPORT QgsComposerTable: public QgsComposerItem 00029 { 00030 public: 00031 QgsComposerTable( QgsComposition* composition ); 00032 virtual ~QgsComposerTable(); 00033 00035 virtual int type() const { return ComposerTable; } 00036 00038 virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ); 00039 00040 virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0; 00041 virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0; 00042 00043 void setLineTextDistance( double d ) { mLineTextDistance = d; } 00044 double lineTextDistance() const { return mLineTextDistance; } 00045 00046 void setHeaderFont( const QFont& f ) { mHeaderFont = f;} 00047 QFont headerFont() const { return mHeaderFont; } 00048 00049 void setContentFont( const QFont& f ) { mContentFont = f; } 00050 QFont contentFont() const { return mContentFont; } 00051 00052 void setShowGrid( bool show ) { mShowGrid = show;} 00053 bool showGrid() const { return mShowGrid; } 00054 00055 void setGridStrokeWidth( double w ) { mGridStrokeWidth = w; } 00056 double gridStrokeWidth() const { return mGridStrokeWidth; } 00057 00058 void setGridColor( const QColor& c ) { mGridColor = c; } 00059 QColor gridColor() const { return mGridColor; } 00060 00063 void adjustFrameToSize(); 00064 00065 protected: 00067 double mLineTextDistance; 00068 00069 QFont mHeaderFont; 00070 QFont mContentFont; 00071 00072 bool mShowGrid; 00073 double mGridStrokeWidth; 00074 QColor mGridColor; 00075 00077 virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributes ) {return false;} //= 0; 00078 virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0; 00080 virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ) const; 00082 void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeList ); 00083 void drawHorizontalGridLines( QPainter* p, int nAttributes ); 00084 void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap ); 00085 00086 bool tableWriteXML( QDomElement& itemElem, QDomDocument& doc ) const; 00087 bool tableReadXML( const QDomElement& itemElem, const QDomDocument& doc ); 00088 }; 00089 00090 #endif // QGSCOMPOSERTABLE_H