Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 );// { mVectorLayer = 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  void setSortAttributes( const QList<QPair<int, bool> > att ) { mSortInformation = att; }
78  QList<QPair<int, bool> > sortAttributes() const { return mSortInformation; }
79 
80  protected:
82  bool getFeatureAttributes( QList<QgsAttributeMap>& attributes );
83  QMap<int, QString> getHeaderLabels() const;
84 
85  private:
92 
95 
97  QSet<int> mDisplayAttributes;
99  QMap<int, QString> mFieldAliasMap;
100 
102  QList< QPair<int, bool> > mSortInformation;
103 
105  void initializeAliasMap();
107  QString attributeDisplayName( int attributeIndex, const QString& name ) const;
108 
109  private slots:
111  void removeLayer( QString layerId );
112 
113  signals:
115  void maximumNumerOfFeaturesChanged( int n );
116 };
117 
118 #endif // QGSCOMPOSERATTRIBUTETABLE_H