QGIS API Documentation  2.99.0-Master (7fe5405)
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 #include "qgis_gui.h"
22 
23 class QgsVectorLayer;
24 class QgsFeatureModel;
26 
30 class GUI_EXPORT QgsFeatureSelectionModel : public QItemSelectionModel
31 {
32  Q_OBJECT
33  public:
34  explicit QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsIFeatureSelectionManager* featureSelectionHandler, QObject* parent );
35 
45  void enableSync( bool enable );
46 
55  virtual bool isSelected( QgsFeatureId fid );
56 
64  virtual bool isSelected( const QModelIndex& index );
65 
66  signals:
67 
74  void requestRepaint( const QModelIndexList& indexes );
75 
80  void requestRepaint();
81 
82  public slots:
83 
89  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
90 
96  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
97 
104  virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command );
105 
106  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
107 
108  private slots:
109  virtual void layerSelectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, bool clearAndSelect );
110 
111  private:
112  QModelIndexList expandIndexToRow( const QModelIndex& index ) const;
113 
114  private:
115  QgsFeatureModel* mFeatureModel;
116  QgsIFeatureSelectionManager* mFeatureSelectionManager;
117  bool mSyncEnabled;
118 
121  QgsFeatureIds mSelectedBuffer;
122 
125  QgsFeatureIds mDeselectedBuffer;
126 
129  bool mClearAndSelectBuffer;
130 };
131 
132 #endif // QGSFEATURESELECTIONMODEL_H
static unsigned index
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:348
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:33
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.