QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsattributetablefiltermodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  QgsAttributeTableFilterModel.h - Filter Model for attribute table
3  -------------------
4  date : Feb 2009
5  copyright : Vita Cizek
6  email : weetya (at) gmail.com
7 
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSATTRIBUTETABLEFILTERMODEL_H
18 #define QGSATTRIBUTETABLEFILTERMODEL_H
19 
20 #include <QSortFilterProxyModel>
21 #include <QModelIndex>
22 
23 #include "qgsvectorlayer.h" //QgsFeatureIds
24 #include "qgsattributetablemodel.h"
25 #include "qgsfeaturemodel.h"
26 
28 class QgsMapCanvas;
29 class QItemSelectionModel;
30 
31 class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, public QgsFeatureModel
32 {
33  Q_OBJECT
34 
35  public:
37  {
42  ShowEdited
43  };
44 
53  QgsAttributeTableFilterModel( QgsMapCanvas* canvas, QgsAttributeTableModel* sourceModel, QObject* parent = NULL );
54 
55  void setSourceModel( QgsAttributeTableModel* sourceModel );
56 
63  void setSelectedOnTop( bool selectedOnTop );
64 
70  bool selectedOnTop();
71 
78  virtual void setFilteredFeatures( QgsFeatureIds ids );
79 
85  void setFilterMode( FilterMode filterMode );
86 
92  inline QgsVectorLayer *layer() const { return masterModel()->layer(); }
93 
99  inline QgsVectorLayerCache *layerCache() const { return masterModel()->layerCache(); }
100 
106  inline QgsAttributeTableModel *masterModel() const { return mTableModel; }
107 
115  QgsFeatureId rowToId( const QModelIndex& row );
116 
117  QModelIndex fidToIndex( QgsFeatureId fid );
118  QModelIndexList fidToIndexList( QgsFeatureId fid );
119 
120  virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;
121 
122  virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
123 
124  protected:
131  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;
132 
137  void generateListOfVisibleFeatures();
138 
143  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
144 
152  virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
153 
154  public slots:
160  void extentsChanged();
161 
162  private slots:
163  void selectionChanged();
164 
165  private:
171 };
172 
173 #endif
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:326
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
This class caches features of a given QgsVectorLayer.
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
qint64 QgsFeatureId
Definition: qgsfeature.h:30
Represents a vector layer which manages a vector based data sets.