QGIS API Documentation  2.99.0-Master (f1c3692)
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 
32 class GUI_EXPORT QgsFeatureSelectionModel : public QItemSelectionModel
33 {
34  Q_OBJECT
35  public:
36  explicit QgsFeatureSelectionModel( QAbstractItemModel *model, QgsFeatureModel *featureModel, QgsIFeatureSelectionManager *featureSelectionHandler, QObject *parent SIP_TRANSFERTHIS );
37 
47  void enableSync( bool enable );
48 
57  virtual bool isSelected( QgsFeatureId fid );
58 
66  virtual bool isSelected( const QModelIndex &index );
67 
68  signals:
69 
76  void requestRepaint( const QModelIndexList &indexes );
77 
82  void requestRepaint();
83 
84  public slots:
85 
91  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
92 
98  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
99 
106  virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command );
107 
108  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
109 
110  private slots:
111  virtual void layerSelectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
112 
113  private:
114  QModelIndexList expandIndexToRow( const QModelIndex &index ) const;
115 
116  private:
117  QgsFeatureModel *mFeatureModel = nullptr;
118  QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
119  bool mSyncEnabled;
120 
125  QgsFeatureIds mSelectedBuffer;
126 
131  QgsFeatureIds mDeselectedBuffer;
132 
137  bool mClearAndSelectBuffer;
138 };
139 
140 #endif // QGSFEATURESELECTIONMODEL_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:544
virtual void select(const QModelIndex &index, SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
#define SIP_TRANSFER
Definition: qgis_sip.h:36
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.