QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
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 );
62  virtual bool isSelected( const QModelIndex& index );
63 
64  signals:
71  void requestRepaint( const QModelIndexList& indexes );
72 
77  void requestRepaint();
78 
79  public slots:
85  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
86 
92  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
93 
100  virtual void selectFeatures( const QItemSelection &selection, const SelectionFlags& command );
101 
102  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
103 
104  private slots:
105  virtual void layerSelectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, bool clearAndSelect );
106 
107  private:
108  QModelIndexList expandIndexToRow( const QModelIndex& index ) const;
109 
110  private:
111  QgsFeatureModel* mFeatureModel;
112  QgsIFeatureSelectionManager* mFeatureSelectionManager;
113  bool mSyncEnabled;
114 
117  QgsFeatureIds mSelectedBuffer;
118 
121  QgsFeatureIds mDeselectedBuffer;
122 
125  bool mClearAndSelectBuffer;
126 };
127 
128 #endif // QGSFEATURESELECTIONMODEL_H
static unsigned index
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)
bool isSelected(const QModelIndex &index) const
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.