QGIS API Documentation  2.99.0-Master (8ec3eaf)
qgsfeatureselectionmodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeatureselectionmodel.h
3  ---------------------
4  begin : April 2013
5  copyright : (C) 2013 by Matthias Kuhn
6  email : matthias at opengis dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSFEATURESELECTIONMODEL_H
16 #define QGSFEATURESELECTIONMODEL_H
17 
18 #include <QItemSelectionModel>
19 
20 #include "qgsfeature.h"
21 
22 class QgsVectorLayer;
23 class QgsFeatureModel;
25 
29 class GUI_EXPORT QgsFeatureSelectionModel : public QItemSelectionModel
30 {
31  Q_OBJECT
32  public:
33  explicit QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsIFeatureSelectionManager* featureSelectionHandler, QObject* parent );
34 
44  void enableSync( bool enable );
45 
54  virtual bool isSelected( QgsFeatureId fid );
55 
63  virtual bool isSelected( const QModelIndex& index );
64 
65  signals:
66 
73  void requestRepaint( const QModelIndexList& indexes );
74 
79  void requestRepaint();
80 
81  public slots:
82 
88  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
89 
95  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
96 
103  virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command );
104 
105  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
106 
107  private slots:
108  virtual void layerSelectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, bool clearAndSelect );
109 
110  private:
111  QModelIndexList expandIndexToRow( const QModelIndex& index ) const;
112 
113  private:
114  QgsFeatureModel* mFeatureModel;
115  QgsIFeatureSelectionManager* mFeatureSelectionManager;
116  bool mSyncEnabled;
117 
120  QgsFeatureIds mSelectedBuffer;
121 
124  QgsFeatureIds mDeselectedBuffer;
125 
128  bool mClearAndSelectBuffer;
129 };
130 
131 #endif // QGSFEATURESELECTIONMODEL_H
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:355
virtual void select(const QModelIndex &index, SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
virtual void select(const QItemSelection &selection, SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
qint64 QgsFeatureId
Definition: qgsfeature.h:32
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.