QGIS API Documentation  2.6.0-Brighton
 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 
36  void setSortColumn( int col ) { mCurrentSortColumn = col; }
37 
41  void setAscending( bool asc ) { mAscending = asc; }
42 
43  private:
44  int mCurrentSortColumn;
45  bool mAscending;
46 };
47 
50 {
51  Q_OBJECT
52  public:
55 
57  virtual int type() const { return ComposerAttributeTable; }
58 
60  virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
61 
67  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
68 
74  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
75 
80  void setVectorLayer( QgsVectorLayer* layer );
81 
86  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
87 
92  void resetColumns();
93 
103  void setComposerMap( const QgsComposerMap* map );
104 
111  const QgsComposerMap* composerMap() const { return mComposerMap; }
112 
119  void setMaximumNumberOfFeatures( int features );
120 
125  int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
126 
134  void setDisplayOnlyVisibleFeatures( bool visibleOnly );
135 
142  bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
143 
150  bool filterFeatures() const { return mFilterFeatures; }
151 
160  void setFilterFeatures( bool filter );
161 
169  QString featureFilter() const { return mFeatureFilter; }
170 
180  void setFeatureFilter( const QString& expression );
181 
188  Q_DECL_DEPRECATED QSet<int> displayAttributes() const;
189 
198  void setDisplayAttributes( const QSet<int>& attr, bool refresh = true );
199 
207  Q_DECL_DEPRECATED QMap<int, QString> fieldAliasMap() const;
208 
216  Q_DECL_DEPRECATED void setFieldAliasMap( const QMap<int, QString>& map );
217 
224  void setSceneRect( const QRectF& rectangle );
225 
236  Q_DECL_DEPRECATED void setSortAttributes( const QList<QPair<int, bool> > att );
237 
244  QList<QPair<int, bool> > sortAttributes() const;
245 
251  bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps );
252 
253  private:
255  QgsVectorLayer* mVectorLayer;
257  const QgsComposerMap* mComposerMap;
259  int mMaximumNumberOfFeatures;
260 
262  bool mShowOnlyVisibleFeatures;
263 
265  bool mFilterFeatures;
267  QString mFeatureFilter;
268 
272  QList<int> fieldsToDisplay() const;
273 
278  void restoreFieldAliasMap( const QMap<int, QString>& map );
279 
280  private slots:
282  void removeLayer( QString layerId );
283 
284 };
285 
286 #endif // QGSCOMPOSERATTRIBUTETABLE_H