QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
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
91 {
92 Q_UNUSED( index )
93 Q_UNUSED( command );
94 }
95
101 void select( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command ) override
102 {
103 Q_UNUSED( selection )
104 Q_UNUSED( command );
105 }
106
113 virtual void selectFeatures( const QItemSelection &selection, QItemSelectionModel::SelectionFlags command );
114
115 virtual void setFeatureSelectionManager( QgsIFeatureSelectionManager *featureSelectionManager SIP_TRANSFER );
116
117 private slots:
118 virtual void layerSelectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
119
120 private:
121 QModelIndexList expandIndexToRow( const QModelIndex &index ) const;
122
123 private:
124 QgsFeatureModel *mFeatureModel = nullptr;
125 QgsIFeatureSelectionManager *mFeatureSelectionManager = nullptr;
126 bool mSyncEnabled;
127
132 QgsFeatureIds mSelectedBuffer;
133
138 QgsFeatureIds mDeselectedBuffer;
139
144 bool mClearAndSelectBuffer;
145};
146
147#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
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features