QGIS API Documentation  2.11.0-Master
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  enum Role
35  {
36  FeatureInfoRole = Qt::UserRole,
37  FeatureRole
38  };
39 
40  public:
41  explicit QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject* parent = 0 );
42  virtual ~QgsFeatureListModel();
43 
44  virtual void setSourceModel( QgsAttributeTableFilterModel* sourceModel );
45  QgsVectorLayerCache* layerCache();
46  virtual QVariant data( const QModelIndex& index, int role ) const override;
47  virtual Qt::ItemFlags flags( const QModelIndex& index ) const override;
48 
54  void setInjectNull( bool injectNull );
55 
61  bool injectNull();
62 
63  QgsAttributeTableModel* masterModel();
64 
71  bool setDisplayExpression( const QString expression );
72 
77  QString parserErrorString();
78 
79  QString displayExpression() const;
80  bool featureByIndex( const QModelIndex& index, QgsFeature& feat );
81  QgsFeatureId idxToFid( const QModelIndex& index ) const;
82  QModelIndex fidToIdx( const QgsFeatureId fid ) const;
83 
84  virtual QModelIndex mapToSource( const QModelIndex& proxyIndex ) const override;
85  virtual QModelIndex mapFromSource( const QModelIndex& sourceIndex ) const override;
86 
87  virtual QModelIndex mapToMaster( const QModelIndex& proxyIndex ) const;
88  virtual QModelIndex mapFromMaster( const QModelIndex& sourceIndex ) const;
89 
90  virtual QItemSelection mapSelectionFromMaster( const QItemSelection& selection ) const;
91  virtual QItemSelection mapSelectionToMaster( const QItemSelection& selection ) const;
92 
93  virtual QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
94  virtual QModelIndex parent( const QModelIndex& child ) const override;
95  virtual int columnCount( const QModelIndex&parent = QModelIndex() ) const override;
96  virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
97 
98  QModelIndex fidToIndex( QgsFeatureId fid ) override;
99  QModelIndexList fidToIndexList( QgsFeatureId fid );
100 
101  public slots:
102  void onBeginRemoveRows( const QModelIndex& parent, int first, int last );
103  void onEndRemoveRows( const QModelIndex& parent, int first, int last );
104  void onBeginInsertRows( const QModelIndex& parent, int first, int last );
105  void onEndInsertRows( const QModelIndex& parent, int first, int last );
106 
107  private:
108  QgsExpression* mExpression;
109  QgsAttributeTableFilterModel* mFilterModel;
110  QString mParserErrorString;
111  bool mInjectNull;
112 };
113 
115 
116 #endif // QGSATTRIBUTEEDITORMODEL_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:86
static unsigned index
virtual int rowCount(const QModelIndex &parent) const =0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:119
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
virtual void setSourceModel(QAbstractItemModel *sourceModel)
virtual QVariant data(const QModelIndex &proxyIndex, int role) const
This class caches features of a given QgsVectorLayer.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual int columnCount(const QModelIndex &parent) const =0
qint64 QgsFeatureId
Definition: qgsfeature.h:31
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const =0
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
QObject * parent() const
Q_DECLARE_METATYPE(QgsExpression::Interval)
typedef ItemFlags