QGIS API Documentation  2.5.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 
80  QgsFeatureIds filteredFeatures();
81 
87  void setFilterMode( FilterMode filterMode );
88 
89  FilterMode filterMode() { return mFilterMode; }
90 
96  inline QgsVectorLayer *layer() const { return masterModel()->layer(); }
97 
103  inline QgsVectorLayerCache *layerCache() const { return masterModel()->layerCache(); }
104 
110  inline QgsAttributeTableModel *masterModel() const { return mTableModel; }
111 
119  QgsFeatureId rowToId( const QModelIndex& row );
120 
121  QModelIndex fidToIndex( QgsFeatureId fid );
122  QModelIndexList fidToIndexList( QgsFeatureId fid );
123 
124  virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;
125 
126  virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
127 
128  protected:
135  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;
136 
141  void generateListOfVisibleFeatures();
142 
147  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const;
148 
156  virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder );
157 
158  public slots:
164  void extentsChanged();
165 
166  private slots:
167  void selectionChanged();
168 
169  private:
175 };
176 
177 #endif
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:325
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:104
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.
void sort(double *heap, int *x, int *y, int N)
Definition: util.cpp:72
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.