QGIS API Documentation  2.15.0-Master (972fc9f)
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 
27 {
28  Q_OBJECT
29  public:
30  explicit QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsIFeatureSelectionManager* featureSelectionHandler, QObject* parent );
31 
41  void enableSync( bool enable );
42 
51  virtual bool isSelected( QgsFeatureId fid );
59  virtual bool isSelected( const QModelIndex& index );
60 
61  signals:
68  void requestRepaint( const QModelIndexList& indexes );
69 
74  void requestRepaint();
75 
76  public slots:
82  virtual void select( const QModelIndex &index, SelectionFlags command ) override { Q_UNUSED( index ); Q_UNUSED( command ); }
83 
89  virtual void select( const QItemSelection &selection, SelectionFlags command ) override { Q_UNUSED( selection ); Q_UNUSED( command ); }
90 
97  virtual void selectFeatures( const QItemSelection &selection, const SelectionFlags& command );
98 
99  virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager* featureSelectionManager );
100 
101  private slots:
102  virtual void layerSelectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, bool clearAndSelect );
103 
104  private:
105  QModelIndexList expandIndexToRow( const QModelIndex& index ) const;
106 
107  private:
108  QgsFeatureModel* mFeatureModel;
109  QgsIFeatureSelectionManager* mFeatureSelectionManager;
110  bool mSyncEnabled;
111 
114  QgsFeatureIds mSelectedBuffer;
115 
118  QgsFeatureIds mDeselectedBuffer;
119 
122  bool mClearAndSelectBuffer;
123 };
124 
125 #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.