10 , mFeatureModel( featureModel )
11 , mSyncEnabled( true )
12 , mClearAndSelectBuffer( false )
19 mSyncEnabled = enable;
23 if ( mClearAndSelectBuffer )
29 mFeatureSelectionManager->
select( mSelectedBuffer );
30 mFeatureSelectionManager->
deselect( mDeselectedBuffer );
33 mSelectedBuffer.
clear();
34 mDeselectedBuffer.
clear();
35 mClearAndSelectBuffer =
false;
41 if ( mSelectedBuffer.
contains( fid ) )
44 if ( mDeselectedBuffer.
contains( fid ) )
71 if ( command.testFlag( QItemSelectionModel::ClearAndSelect ) )
75 mClearAndSelectBuffer =
true;
78 if ( !mDeselectedBuffer.
remove(
id ) )
80 mSelectedBuffer.
insert(
id );
89 else if ( command.testFlag( QItemSelectionModel::Select ) )
95 if ( !mDeselectedBuffer.
remove(
id ) )
97 mSelectedBuffer.
insert(
id );
103 mFeatureSelectionManager->
select( ids );
106 else if ( command.testFlag( QItemSelectionModel::Deselect ) )
112 if ( !mSelectedBuffer.
remove(
id ) )
114 mDeselectedBuffer.
insert(
id );
120 mFeatureSelectionManager->
deselect( ids );
126 QModelIndexList updatedIndexes;
129 updatedIndexes.append( expandIndexToRow( idx ) );
137 mFeatureSelectionManager = featureSelectionManager;
142 void QgsFeatureSelectionModel::layerSelectionChanged(
const QgsFeatureIds& selected,
const QgsFeatureIds& deselected,
bool clearAndSelect )
144 if ( clearAndSelect )
150 QModelIndexList updatedIndexes;
153 updatedIndexes.append( expandIndexToRow( mFeatureModel->
fidToIndex( fid ) ) );
158 updatedIndexes.append( expandIndexToRow( mFeatureModel->
fidToIndex( fid ) ) );
165 QModelIndexList QgsFeatureSelectionModel::expandIndexToRow(
const QModelIndex&
index )
const 167 QModelIndexList indexes;
169 int row = index.
row();
175 indexes.reserve( columns );
176 for (
int column = 0; column < columns; ++column )
178 indexes.append( model->
index( row, column ) );
QModelIndexList indexes() const
qlonglong toLongLong(bool *ok) const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
virtual const QgsFeatureIds & selectedFeaturesIds() const =0
Return reference to identifiers of selected features.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
virtual void setSelectedFeatures(const QgsFeatureIds &ids)=0
Change selection to the new set of features.
const_iterator insert(const T &value)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
void enableSync(bool enable)
Enables or disables synchronisation to the QgsVectorLayer When synchronisation is disabled...
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
virtual void deselect(const QgsFeatureIds &ids)=0
Deselect features.
void requestRepaint()
Request a repaint of the visible items of connected views.
const QItemSelection selection() const
virtual void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
virtual QVariant data(const QModelIndex &index, int role) const =0
bool contains(const T &value) const
virtual void selectFeatures(const QItemSelection &selection, const SelectionFlags &command)
Select features on this table.
const QAbstractItemModel * model() const
bool remove(const T &value)
virtual int columnCount(const QModelIndex &parent) const =0
QgsFeatureSelectionModel(QAbstractItemModel *model, QgsFeatureModel *featureModel, QgsIFeatureSelectionManager *featureSelectionHandler, QObject *parent)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Is an interface class to abstract feature selection handling.
const QAbstractItemModel * model() const
virtual void select(const QgsFeatureIds &ids)=0
Select features.