23   : QItemSelectionModel( model, parent )
    24   , mFeatureModel( featureModel )
    25   , mSyncEnabled( true )
    26   , mClearAndSelectBuffer( false )
    33   mSyncEnabled = enable;
    37     if ( mClearAndSelectBuffer )
    43       mFeatureSelectionManager->
select( mSelectedBuffer );
    44       mFeatureSelectionManager->
deselect( mDeselectedBuffer );
    47     mSelectedBuffer.clear();
    48     mDeselectedBuffer.clear();
    49     mClearAndSelectBuffer = 
false;
    55   if ( mSelectedBuffer.contains( fid ) )
    58   if ( mDeselectedBuffer.contains( fid ) )
    61   if ( !mClearAndSelectBuffer && mFeatureSelectionManager->
selectedFeatureIds().contains( fid ) )
    76   QgsDebugMsg( QStringLiteral( 
"Index count: %1" ).arg( selection.indexes().size() ) );
    78   Q_FOREACH ( 
const QModelIndex &index, selection.indexes() )
    87   if ( command.testFlag( QItemSelectionModel::ClearAndSelect ) )
    91       mClearAndSelectBuffer = 
true;
    94         if ( !mDeselectedBuffer.remove( 
id ) )
    96           mSelectedBuffer.insert( 
id );
   105   else if ( command.testFlag( QItemSelectionModel::Select ) )
   111         if ( !mDeselectedBuffer.remove( 
id ) )
   113           mSelectedBuffer.insert( 
id );
   119       mFeatureSelectionManager->
select( ids );
   122   else if ( command.testFlag( QItemSelectionModel::Deselect ) )
   128         if ( !mSelectedBuffer.remove( 
id ) )
   130           mDeselectedBuffer.insert( 
id );
   136       mFeatureSelectionManager->
deselect( ids );
   142   QModelIndexList updatedIndexes;
   143   Q_FOREACH ( 
const QModelIndex &idx, selection.indexes() )
   145     updatedIndexes.append( expandIndexToRow( idx ) );
   153   mFeatureSelectionManager = featureSelectionManager;
   158 void QgsFeatureSelectionModel::layerSelectionChanged( 
const QgsFeatureIds &selected, 
const QgsFeatureIds &deselected, 
bool clearAndSelect )
   160   if ( clearAndSelect )
   166     QModelIndexList updatedIndexes;
   169       updatedIndexes.append( expandIndexToRow( mFeatureModel->
fidToIndex( fid ) ) );
   174       updatedIndexes.append( expandIndexToRow( mFeatureModel->
fidToIndex( fid ) ) );
   181 QModelIndexList QgsFeatureSelectionModel::expandIndexToRow( 
const QModelIndex &index )
 const   183   QModelIndexList indexes;
   184   const QAbstractItemModel *model = index.model();
   185   int row = index.row();
   190   int columns = model->columnCount();
   191   indexes.reserve( columns );
   192   for ( 
int column = 0; column < columns; ++column )
   194     indexes.append( model->index( row, column ) );
 virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id. 
 
QSet< QgsFeatureId > QgsFeatureIds
 
virtual void selectFeatures(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
Select features on this table. 
 
virtual void setSelectedFeatures(const QgsFeatureIds &ids)=0
Change selection to the new set of features. 
 
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
This signal is emitted when selection was changed. 
 
void enableSync(bool enable)
Enables or disables synchronisation to the QgsVectorLayer When synchronisation is disabled...
 
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
 
Get the feature id of the feature in this row. 
 
virtual void deselect(const QgsFeatureIds &ids)=0
Deselect features by feature ids. 
 
void requestRepaint()
Request a repaint of the visible items of connected views. 
 
virtual const QgsFeatureIds & selectedFeatureIds() const =0
Returns reference to identifiers of selected features. 
 
virtual void setFeatureSelectionManager(QgsIFeatureSelectionManager *featureSelectionManager)
 
QgsFeatureSelectionModel(QAbstractItemModel *model, QgsFeatureModel *featureModel, QgsIFeatureSelectionManager *featureSelectionHandler, QObject *parent)
 
Is an interface class to abstract feature selection handling. 
 
virtual void select(const QgsFeatureIds &ids)=0
Select features by feature ids.