QGIS API Documentation  2.10.1-Pisa
 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
bool displayOnlyVisibleFeatures() const
Returns true if the table is set to show only features visible on a corresponding composer map item...
Helper class for sorting tables, takes into account sorting column and ascending / descending...
virtual QString displayName() const
Get multiframe display name.
QgsVectorLayer * vectorLayer() const
Returns the vector layer the attribute table is currently using.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const override
Stores state information about multiframe in DOM element.
A table that displays attributes from a vector layer.
virtual void addFrame(QgsComposerFrame *frame, bool recalcFrameSizes=true)=0
Adds a frame to the multiframe.
void setSortColumn(int col)
Sets column number to sort by.
A class to display a table in the print composer, and allow the table to span over multiple frames...
bool uniqueRowsOnly() const
Returns true if the table is set to show only unique rows.
int maximumNumberOfFeatures() const
Returns the maximum number of features to be shown by the table.
QString featureFilter() const
Returns the current expression used to filter features for the table.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
Reads multiframe state information from a DOM element.
Graphics scene for map printing.
const QgsComposerMap * composerMap() const
Returns the composer map whose extents are controlling the features shown in the table.
Object representing map window.
Frame item for a composer multiframe item.
bool filterToAtlasFeature() const
Returns true if the table is set to only show features which intersect the current atlas feature...
QString relationId() const
Returns the relation id which the table displays child features from.
bool filterFeatures() const
Returns true if a feature filter is active on the attribute table.
virtual bool getTableContents(QgsComposerTableContents &contents)=0
Fetches the contents used for the cells in the table.
void setAscending(bool asc)
Sets sort order for column sorting.
Represents a vector layer which manages a vector based data sets.
ContentSource source() const
Returns the source for attributes shown in the table body.