QGIS API Documentation  2.10.1-Pisa
 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;
30 
32 {
33  Q_OBJECT
34 
35  public:
37  {
42  ShowEdited
43  };
44 
53  QgsAttributeTableFilterModel( QgsMapCanvas* canvas, QgsAttributeTableModel* sourceModel, QObject* parent = 0 );
54 
62  void setSourceModel( QgsAttributeTableModel* sourceModel );
63 
70  void setSelectedOnTop( bool selectedOnTop );
71 
77  bool selectedOnTop();
78 
85  virtual void setFilteredFeatures( QgsFeatureIds ids );
86 
92  QgsFeatureIds filteredFeatures();
93 
99  void setFilterMode( FilterMode filterMode );
100 
106  FilterMode filterMode() { return mFilterMode; }
107 
113  inline QgsVectorLayer *layer() const { return masterModel()->layer(); }
114 
120  inline QgsVectorLayerCache *layerCache() const { return masterModel()->layerCache(); }
121 
127  inline QgsAttributeTableModel *masterModel() const { return mTableModel; }
128 
136  QgsFeatureId rowToId( const QModelIndex& row );
137 
138  QModelIndex fidToIndex( QgsFeatureId fid ) override;
139  QModelIndexList fidToIndexList( QgsFeatureId fid );
140 
141  virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;
142 
143  virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
144 
152  virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override;
153 
154  protected:
161  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
162 
167  void generateListOfVisibleFeatures();
168 
173  bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override;
174 
175  public slots:
181  void extentsChanged();
182 
183  private slots:
184  void selectionChanged();
185 
186  private:
187  QgsFeatureIds mFilteredFeatures;
188  QgsMapCanvas* mCanvas;
189  FilterMode mFilterMode;
190  bool mSelectedOnTop;
191  QgsAttributeTableModel* mTableModel;
192 };
193 
194 #endif
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
virtual void sort(int column, Qt::SortOrder order)
virtual void setSourceModel(QAbstractItemModel *sourceModel)
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.
FilterMode filterMode()
The current filterModel.
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
This class caches features of a given QgsVectorLayer.
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Represents a vector layer which manages a vector based data sets.