QGIS API Documentation  2.14.0-Essen
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 override { return ComposerAttributeTable; }
58 
60  virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
61 
67  bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
68 
74  bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
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 ) override;
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 ) override;
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( const QString& layerId );
283 
284 };
285 
286 #endif // QGSCOMPOSERATTRIBUTETABLE_H
bool displayOnlyVisibleFeatures() const
Returns true if the table is set to show only features visible on a corresponding composer map item...
void setAscending(bool asc)
Sets sort order for column sorting.
virtual int type() const override
Return correct graphics item type.
QgsVectorLayer * vectorLayer() const
Returns the vector layer the attribute table is currently using.
A class to display feature attributes in the print composer.
const QgsComposerMap * composerMap() const
Returns the composer map whose extents are controlling the features shown in the table.
Graphics scene for map printing.
Object representing map window.
virtual bool getFeatureAttributes(QList< QgsAttributeMap > &attributeMaps)
Fetches the text used for the rows of the table.
bool filterFeatures() const
Returns true if a feature filter is active on the attribute table.
int maximumNumberOfFeatures() const
Returns the maximum number of features to be shown by the table.
A table class that displays a vector attribute table.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const override=0
Stores item state in DOM element.
void setSortColumn(int col)
Sets column number to sort by.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
QString featureFilter() const
Returns the current expression used to filter features for the table.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Reimplementation of QCanvasItem::paint.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override=0
Sets item state from DOM element.
Represents a vector layer which manages a vector based data sets.
Helper class for sorting tables, takes into account sorting column and ascending / descending...