QGIS API Documentation  3.2.0-Bonn (bc43194)
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  void select( const QModelIndex &index, QItemSelectionModel::SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
92 
98  void select( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
99 
106  virtual void selectFeatures( const QItemSelection &selection, QItemSelectionModel::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
void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:544
#define SIP_TRANSFER
Definition: qgis_sip.h:36
void select(const QModelIndex &index, QItemSelectionModel::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.