QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
31 {
32  public:
34  bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
35 
39  void setSortColumn( int col ) { mCurrentSortColumn = col; }
40 
44  void setAscending( bool asc ) { mAscending = asc; }
45 
46  private:
47  int mCurrentSortColumn;
48  bool mAscending;
49 };
50 
55 // TODO QGIS 3.0 - remove
57 {
58  Q_OBJECT
59  public:
62 
64  virtual int type() const override { return ComposerAttributeTable; }
65 
67  virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
68 
74  bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
75 
81  bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
82 
87  void setVectorLayer( QgsVectorLayer* layer );
88 
93  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
94 
99  void resetColumns();
100 
110  void setComposerMap( const QgsComposerMap* map );
111 
118  const QgsComposerMap* composerMap() const { return mComposerMap; }
119 
126  void setMaximumNumberOfFeatures( int features );
127 
132  int maximumNumberOfFeatures() const { return mMaximumNumberOfFeatures; }
133 
141  void setDisplayOnlyVisibleFeatures( bool visibleOnly );
142 
149  bool displayOnlyVisibleFeatures() const { return mShowOnlyVisibleFeatures; }
150 
157  bool filterFeatures() const { return mFilterFeatures; }
158 
167  void setFilterFeatures( bool filter );
168 
176  QString featureFilter() const { return mFeatureFilter; }
177 
187  void setFeatureFilter( const QString& expression );
188 
195  Q_DECL_DEPRECATED QSet<int> displayAttributes() const;
196 
205  void setDisplayAttributes( const QSet<int>& attr, bool refresh = true );
206 
214  Q_DECL_DEPRECATED QMap<int, QString> fieldAliasMap() const;
215 
223  Q_DECL_DEPRECATED void setFieldAliasMap( const QMap<int, QString>& map );
224 
231  void setSceneRect( const QRectF& rectangle ) override;
232 
243  Q_DECL_DEPRECATED void setSortAttributes( const QList<QPair<int, bool> >& att );
244 
251  QList<QPair<int, bool> > sortAttributes() const;
252 
258  bool getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps ) override;
259 
260  private:
262  QgsVectorLayer* mVectorLayer;
264  const QgsComposerMap* mComposerMap;
266  int mMaximumNumberOfFeatures;
267 
269  bool mShowOnlyVisibleFeatures;
270 
272  bool mFilterFeatures;
274  QString mFeatureFilter;
275 
279  QList<int> fieldsToDisplay() const;
280 
285  void restoreFieldAliasMap( const QMap<int, QString>& map );
286 
287  private slots:
289  void removeLayer( const QString& layerId );
290 
291 };
292 
293 #endif // QGSCOMPOSERATTRIBUTETABLE_H
void setAscending(bool asc)
Sets sort order for column sorting.
int maximumNumberOfFeatures() const
Returns the maximum number of features to be shown by the table.
const QgsComposerMap * composerMap() const
Returns the composer map whose extents are controlling the features shown in the table.
virtual int type() const override
Return correct graphics item type.
A class to display feature attributes in the print composer.
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.
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...
bool displayOnlyVisibleFeatures() const
Returns true if the table is set to show only features visible on a corresponding composer map item...
QgsVectorLayer * vectorLayer() const
Returns the vector layer the attribute table is currently using.
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.
QString featureFilter() const
Returns the current expression used to filter features for the table.
Represents a vector layer which manages a vector based data sets.
bool filterFeatures() const
Returns true if a feature filter is active on the attribute table.
Helper class for sorting tables, takes into account sorting column and ascending / descending...