QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerattributetablev2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerattributetablev2.h
3  ---------------------------
4  begin : September 2014
5  copyright : (C) 2014 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 QGSCOMPOSERATTRIBUTETABLEV2_H
19 #define QGSCOMPOSERATTRIBUTETABLEV2_H
20 
21 #include "qgscomposertablev2.h"
23 
24 class QgsComposerMap;
25 class QgsVectorLayer;
26 
29 {
30  public:
32  bool operator()( const QgsComposerTableRow& m1, const QgsComposerTableRow& m2 );
33 
37  void setSortColumn( int col ) { mCurrentSortColumn = col; }
38 
42  void setAscending( bool asc ) { mAscending = asc; }
43 
44  private:
45  int mCurrentSortColumn;
46  bool mAscending;
47 };
48 
49 
52 {
53  Q_OBJECT
54 
55  public:
56 
60  {
61  LayerAttributes = 0,
63  RelationChildren
64  };
65 
66  QgsComposerAttributeTableV2( QgsComposition* composition, bool createUndoCommands );
68 
69  virtual QString displayName() const override;
70 
77  virtual bool writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const override;
78 
85  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false ) override;
86 
87  virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) override;
88 
93  void setSource( const ContentSource source );
94 
99  ContentSource source() const { return mSource; }
100 
107  QgsVectorLayer* sourceLayer();
108 
113  void setVectorLayer( QgsVectorLayer* layer );
114 
119  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
120 
127  void setRelationId( const QString relationId );
128 
135  QString relationId() const { return mRelationId; }
136 
140  void resetColumns();
141 
151  void setComposerMap( const QgsComposerMap* map );
152 
159  const QgsComposerMap* composerMap() const { return mComposerMap; }
160 
167  void setMaximumNumberOfFeatures( const int features );
168 
173  int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
174 
180  void setUniqueRowsOnly( const bool uniqueOnly );
181 
187  bool uniqueRowsOnly() const { return mShowUniqueRowsOnly; }
188 
196  void setDisplayOnlyVisibleFeatures( const bool visibleOnly );
197 
204  bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
205 
212  void setFilterToAtlasFeature( const bool filterToAtlas );
213 
219  bool filterToAtlasFeature() const { return mFilterToAtlasIntersection; }
220 
226  bool filterFeatures() const { return mFilterFeatures; }
227 
235  void setFilterFeatures( const bool filter );
236 
243  QString featureFilter() const { return mFeatureFilter; }
244 
253  void setFeatureFilter( const QString& expression );
254 
263  void setDisplayAttributes( const QSet<int>& attr, bool refresh = true );
264 
271  QList<QPair<int, bool> > sortAttributes() const;
272 
278  bool getTableContents( QgsComposerTableContents &contents ) override;
279 
280  private:
281 
283  ContentSource mSource;
285  QgsVectorLayer* mVectorLayer;
287  QString mRelationId;
288 
290  QgsVectorLayer* mCurrentAtlasLayer;
291 
293  const QgsComposerMap* mComposerMap;
295  int mMaximumNumberOfFeatures;
296 
298  bool mShowUniqueRowsOnly;
299 
301  bool mShowOnlyVisibleFeatures;
302 
304  bool mFilterToAtlasIntersection;
305 
307  bool mFilterFeatures;
309  QString mFeatureFilter;
310 
314  QList<int> fieldsToDisplay() const;
315 
320  void restoreFieldAliasMap( const QMap<int, QString>& map );
321 
322  private slots:
324  void removeLayer( QString layerId );
325 
326  void atlasLayerChanged( QgsVectorLayer* layer );
327 
328 };
329 
330 #endif // QGSCOMPOSERATTRIBUTETABLEV2_H