QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  const 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 
88  private:
92 };
93 
95 
96 #endif // QGSATTRIBUTEEDITORMODEL_H