QGIS API Documentation  2.99.0-Master (ba079d8)
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 #include "qgis.h"
20 
21 #include "qgsfeature.h"
22 #include "qgis_gui.h"
23 
24 class QgsVectorLayer;
25 class QgsFeatureModel;
27 
31 class GUI_EXPORT QgsFeatureSelectionModel : public QItemSelectionModel
32 {
33  Q_OBJECT
34  public:
35  explicit QgsFeatureSelectionModel( QAbstractItemModel *model, QgsFeatureModel *featureModel, QgsIFeatureSelectionManager *featureSelectionHandler, QObject *parent SIP_TRANSFERTHIS );
36 
46  void enableSync( bool enable );
47 
56  virtual bool isSelected( QgsFeatureId fid );
57 
65  virtual bool isSelected( const QModelIndex &index );
66 
67  signals:
68 
75  void requestRepaint( const QModelIndexList &indexes );
76 
81  void requestRepaint();
82 
83  public slots:
84 
90  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
91 
97  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
98 
105  virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command );
106 
107  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager );
108 
109  private slots:
110  virtual void layerSelectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
111 
112  private:
113  QModelIndexList expandIndexToRow( const QModelIndex &index ) const;
114 
115  private:
116  QgsFeatureModel *mFeatureModel = nullptr;
117  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
118  bool mSyncEnabled;
119 
122  QgsFeatureIds mSelectedBuffer;
123 
126  QgsFeatureIds mDeselectedBuffer;
127 
130  bool mClearAndSelectBuffer;
131 };
132 
133 #endif // QGSFEATURESELECTIONMODEL_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:519
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:37
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.