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  enum Role
35  {
36  FeatureInfoRole = Qt::UserRole,
37  FeatureRole
38  };
39 
40  public:
41  explicit QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject* parent = NULL );
42  virtual ~QgsFeatureListModel();
43 
44  virtual void setSourceModel( QgsAttributeTableFilterModel* sourceModel );
45  QgsVectorLayerCache* layerCache();
46  virtual QVariant data( const QModelIndex& index, int role ) const;
47  virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
48 
49  QgsAttributeTableModel* masterModel();
50 
57  bool setDisplayExpression( const QString expression );
58 
63  QString parserErrorString();
64 
65  QString displayExpression() const;
66  bool featureByIndex( const QModelIndex& index, QgsFeature& feat );
67  QgsFeatureId idxToFid( const QModelIndex& index ) const;
68  QModelIndex fidToIdx( const QgsFeatureId fid ) const;
69 
70  virtual QModelIndex mapToSource( const QModelIndex& proxyIndex ) const;
71  virtual QModelIndex mapFromSource( const QModelIndex& sourceIndex ) const;
72 
73  virtual QModelIndex mapToMaster( const QModelIndex& proxyIndex ) const;
74  virtual QModelIndex mapFromMaster( const QModelIndex& sourceIndex ) const;
75 
76  virtual QItemSelection mapSelectionFromMaster( const QItemSelection& selection ) const;
77  virtual QItemSelection mapSelectionToMaster( const QItemSelection& selection ) const;
78 
79  virtual QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
80  virtual QModelIndex parent( const QModelIndex& child ) const;
81  virtual int columnCount( const QModelIndex&parent = QModelIndex() ) const;
82  virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
83 
84  QModelIndex fidToIndex( QgsFeatureId fid );
85  QModelIndexList fidToIndexList( QgsFeatureId fid );
86 
87  public slots:
88  void onBeginRemoveRows( const QModelIndex& parent, int first, int last );
89  void onEndRemoveRows( const QModelIndex& parent, int first, int last );
90  void onBeginInsertRows( const QModelIndex& parent, int first, int last );
91  void onEndInsertRows( const QModelIndex& parent, int first, int last );
92 
93  private:
94  QgsExpression* mExpression;
95  QgsAttributeTableFilterModel* mFilterModel;
96  QString mParserErrorString;
97 };
98 
100 
101 #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:45
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
bool isEdited
Definition: qgsfeaturelistmodel.h:31
Definition: qgsfeaturelistmodel.h:17
bool isNew
Definition: qgsfeaturelistmodel.h:30
Role
Definition: qgsfeaturelistmodel.h:34
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)