QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 "qgsfeatureid.h"
20
21#include "qgis_gui.h"
22
23class QgsVectorLayer;
24class QgsFeatureModel;
26
31class GUI_EXPORT QgsFeatureSelectionModel : public QItemSelectionModel
32{
33 Q_OBJECT
34 public:
35 explicit QgsFeatureSelectionModel( QAbstractItemModel *model, QgsFeatureModel *featureModel, QgsIFeatureSelectionManager *featureSelectionHandler, QObject *parent SIP_TRANSFERTHIS );
36
46 void enableSync( bool enable );
47
56 virtual bool isSelected( QgsFeatureId fid );
57
65 virtual bool isSelected( const QModelIndex &index );
66
67 signals:
68
75 void requestRepaint( const QModelIndexList &indexes );
76
82
83 public slots:
84
90 void select( const QModelIndex &index, QItemSelectionModel::SelectionFlags command ) override { Q_UNUSED( index ) Q_UNUSED( command ); }
91
97 void select( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command ) override { Q_UNUSED( selection ) Q_UNUSED( command ); }
98
105 virtual void selectFeatures( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command );
106
107 virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
108
109 private slots:
110 virtual void layerSelectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
111
112 private:
113 QModelIndexList expandIndexToRow( const QModelIndex &index ) const;
114
115 private:
116 QgsFeatureModel *mFeatureModel = nullptr;
117 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
118 bool mSyncEnabled;
119
124 QgsFeatureIds mSelectedBuffer;
125
130 QgsFeatureIds mDeselectedBuffer;
131
136 bool mClearAndSelectBuffer;
137};
138
139#endif // QGSFEATURESELECTIONMODEL_H
void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
void requestRepaint(const QModelIndexList &indexes)
Request a repaint of a list of model indexes.
void requestRepaint()
Request a repaint of the visible items of connected views.
void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) override
Overwritten to do NOTHING (we handle selection ourselves)
Is an interface class to abstract feature selection handling.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28