QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsfeaturelistmodel.h
Go to the documentation of this file.
1 #ifndef QGSATTRIBUTEEDITORMODEL_H
2 #define QGSATTRIBUTEEDITORMODEL_H
3 
4 #include <qgsexpression.h>
5 
6 #include <QAbstractProxyModel>
7 #include <QVariant>
8 #include <QItemSelectionModel>
9 
10 #include "qgsfeaturemodel.h"
11 #include "qgsfeature.h" // QgsFeatureId
12 
16 
17 class GUI_EXPORT QgsFeatureListModel : public QAbstractProxyModel, public QgsFeatureModel
18 {
19  Q_OBJECT
20 
21  public:
22  struct FeatureInfo
23  {
24  public:
26  : isNew( false )
27  , isEdited( false )
28  {}
29 
30  bool isNew;
31  bool isEdited;
32  };
33 
34  public:
35  explicit QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject* parent = NULL );
36  virtual ~QgsFeatureListModel();
37 
38  virtual void setSourceModel( QgsAttributeTableFilterModel* sourceModel );
39  QgsVectorLayerCache* layerCache();
40  virtual QVariant data( const QModelIndex& index, int role ) const;
41  virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
42 
43  QgsAttributeTableModel* masterModel();
44 
51  bool setDisplayExpression( const QString expression );
52 
57  QString parserErrorString();
58 
59  QString displayExpression() const;
60  bool featureByIndex( const QModelIndex& index, QgsFeature& feat );
61  QgsFeatureId idxToFid( const QModelIndex& index ) const;
62  QModelIndex fidToIdx( const QgsFeatureId fid ) const;
63 
64  virtual QModelIndex mapToSource( const QModelIndex& proxyIndex ) const;
65  virtual QModelIndex mapFromSource( const QModelIndex& sourceIndex ) const;
66 
67  virtual QModelIndex mapToMaster( const QModelIndex& proxyIndex ) const;
68  virtual QModelIndex mapFromMaster( const QModelIndex& sourceIndex ) const;
69 
70  virtual QItemSelection mapSelectionFromMaster( const QItemSelection& selection ) const;
71  virtual QItemSelection mapSelectionToMaster( const QItemSelection& selection ) const;
72 
73  virtual QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
74  virtual QModelIndex parent( const QModelIndex& child ) const;
75  virtual int columnCount( const QModelIndex&parent = QModelIndex() ) const;
76  virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
77 
78  QModelIndex fidToIndex( QgsFeatureId fid );
79  QModelIndexList fidToIndexList( QgsFeatureId fid );
80 
81  public slots:
82  void onBeginRemoveRows( const QModelIndex& parent, int first, int last );
83  void onEndRemoveRows( const QModelIndex& parent, int first, int last );
84  void onBeginInsertRows( const QModelIndex& parent, int first, int last );
85  void onEndInsertRows( const QModelIndex& parent, int first, int last );
86 
87  private:
88  QgsExpression* mExpression;
89  QgsAttributeTableFilterModel* mFilterModel;
90  QString mParserErrorString;
91 };
92 
94 
95 #endif // QGSATTRIBUTEEDITORMODEL_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:89
static unsigned index
Definition: mersenne-twister.cpp:36
FeatureInfo()
Definition: qgsfeaturelistmodel.h:25
Definition: qgsattributetablefiltermodel.h:31
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Definition: qgsattributetablemodel.h:44
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
bool isEdited
Definition: qgsfeaturelistmodel.h:31
Definition: qgsfeaturelistmodel.h:17
bool isNew
Definition: qgsfeaturelistmodel.h:30
Definition: qgsfeaturelistmodel.h:22
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:38
Definition: qgsfeaturemodel.h:7
qint64 QgsFeatureId
Definition: qgsfeature.h:30
Q_DECLARE_METATYPE(QgsExpression::Interval)