QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerattributetable.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerattributetable.h
3  ---------------------------
4  begin : April 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 QGSCOMPOSERATTRIBUTETABLE_H
19 #define QGSCOMPOSERATTRIBUTETABLE_H
20 
21 #include "qgscomposertable.h"
22 
23 class QgsComposerMap;
24 class QgsVectorLayer;
25 
28 {
29  public:
31  bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
32  void setSortColumn( int col ) { mCurrentSortColumn = col; }
33  void setAscending( bool asc ) { mAscending = asc; }
34  private:
36  bool mAscending;
37 };
38 
41 {
42  Q_OBJECT
43  public:
46 
48  virtual int type() const { return ComposerAttributeTable; }
49 
51  virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
52 
53  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
54  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
55 
56  void setVectorLayer( QgsVectorLayer* vl );
57  const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
58 
59  void setComposerMap( const QgsComposerMap* map );
60  const QgsComposerMap* composerMap() const { return mComposerMap; }
61 
62  void setMaximumNumberOfFeatures( int nr ) { mMaximumNumberOfFeatures = nr; }
63  int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
64 
65  void setDisplayOnlyVisibleFeatures( bool b ) { mShowOnlyVisibleFeatures = b; }
66  bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
67 
68  QSet<int> displayAttributes() const { return mDisplayAttributes; }
69  void setDisplayAttributes( const QSet<int>& attr ) { mDisplayAttributes = attr; }
70 
71  QMap<int, QString> fieldAliasMap() const { return mFieldAliasMap; }
72  void setFieldAliasMap( const QMap<int, QString>& map ) { mFieldAliasMap = map; }
73 
75  void setSceneRect( const QRectF& rectangle );
76 
77  // @note not available in python bindings
78  void setSortAttributes( const QList<QPair<int, bool> > att ) { mSortInformation = att; }
79 
80  // @note not available in python bindings
81  QList<QPair<int, bool> > sortAttributes() const { return mSortInformation; }
82 
83  protected:
87  bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
88 
90  QMap<int, QString> getHeaderLabels() const;
91 
92  private:
99 
102 
106  QMap<int, QString> mFieldAliasMap;
107 
109  QList< QPair<int, bool> > mSortInformation;
110 
112  void initializeAliasMap();
114  QString attributeDisplayName( int attributeIndex, const QString& name ) const;
115 
116  private slots:
118  void removeLayer( QString layerId );
119 
120  signals:
122  void maximumNumberOfFeaturesChanged( int n );
123 };
124 
125 #endif // QGSCOMPOSERATTRIBUTETABLE_H