QGIS API Documentation 3.43.0-Master (b60ef06885e)
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
32class 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
83
84 public slots:
85
91 void select( const QModelIndex &index, QItemSelectionModel::SelectionFlags command ) override
92 {
93 Q_UNUSED( index )
94 Q_UNUSED( command );
95 }
96
102 void select( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command ) override
103 {
104 Q_UNUSED( selection )
105 Q_UNUSED( command );
106 }
107
114 virtual void selectFeatures( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command );
115
116 virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
117
118 private slots:
119 virtual void layerSelectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
120
121 private:
122 QModelIndexList expandIndexToRow( const QModelIndex &index ) const;
123
124 private:
125 QgsFeatureModel *mFeatureModel = nullptr;
126 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
127 bool mSyncEnabled;
128
133 QgsFeatureIds mSelectedBuffer;
134
139 QgsFeatureIds mDeselectedBuffer;
140
145 bool mClearAndSelectBuffer;
146};
147
148#endif // QGSFEATURESELECTIONMODEL_H
Base class for feature models.
Item selection model for selecting features.
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 dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features