QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposertable.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposertable.h
3  ------------------
4  begin : January 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 #ifndef QGSCOMPOSERTABLE_H
19 #define QGSCOMPOSERTABLE_H
20 
21 #include "qgscomposeritem.h"
22 #include "qgscomposition.h"
23 #include "qgsfeature.h"
24 #include <QSet>
25 
26 
27 
29 class CORE_EXPORT QgsComposerTable: public QgsComposerItem
30 {
31  Q_OBJECT
32 
33  public:
34  QgsComposerTable( QgsComposition* composition );
35  virtual ~QgsComposerTable();
36 
38  virtual int type() const { return ComposerTable; }
39 
41  virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
42 
43  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const = 0;
44  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
45 
46  void setLineTextDistance( double d ) { mLineTextDistance = d; }
47  double lineTextDistance() const { return mLineTextDistance; }
48 
49  void setHeaderFont( const QFont& f );
50  QFont headerFont() const { return mHeaderFont; }
51 
52  void setContentFont( const QFont& f );
53  QFont contentFont() const { return mContentFont; }
54 
55  void setShowGrid( bool show ) { mShowGrid = show;}
56  bool showGrid() const { return mShowGrid; }
57 
58  void setGridStrokeWidth( double w ) { mGridStrokeWidth = w; }
59  double gridStrokeWidth() const { return mGridStrokeWidth; }
60 
61  void setGridColor( const QColor& c ) { mGridColor = c; }
62  QColor gridColor() const { return mGridColor; }
63 
64  public slots:
65 
72  virtual void refreshAttributes();
73 
81  virtual void adjustFrameToSize();
82 
83  protected:
86 
87  QFont mHeaderFont;
88  QFont mContentFont;
89 
90  bool mShowGrid;
92  QColor mGridColor;
93 
94  QList<QgsAttributeMap> mAttributeMaps;
95  QMap<int, double> mMaxColumnWidthMap;
96 
98  virtual bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) { Q_UNUSED( attributeMaps ); return false; }
100  virtual QMap<int, QString> getHeaderLabels() const { return QMap<int, QString>(); } //= 0;
102  virtual bool calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const;
104  void adaptItemFrame( const QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps );
106  void drawHorizontalGridLines( QPainter* p, int nAttributes );
108  void drawVerticalGridLines( QPainter* p, const QMap<int, double>& maxWidthMap );
109 
110  bool tableWriteXML( QDomElement& itemElem, QDomDocument& doc ) const;
111  bool tableReadXML( const QDomElement& itemElem, const QDomDocument& doc );
112 };
113 
114 #endif // QGSCOMPOSERTABLE_H
QColor gridColor() const
void setLineTextDistance(double d)
virtual int type() const
return correct graphics item type.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)=0
sets state from Dom document
void setGridStrokeWidth(double w)
A item that forms part of a map composition.
void setShowGrid(bool show)
void setGridColor(const QColor &c)
virtual QMap< int, QString > getHeaderLabels() const
A class to display feature attributes in the print composer.
QFont headerFont() const
bool showGrid() const
Graphics scene for map printing.
QFont contentFont() const
QList< QgsAttributeMap > mAttributeMaps
double mLineTextDistance
Distance between table lines and text.
QMap< int, double > mMaxColumnWidthMap
double gridStrokeWidth() const
double lineTextDistance() const
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const =0
stores state in Dom element