@@ -38,6 +38,7 @@ QgsFeatureListView::QgsFeatureListView( QWidget *parent )
3838 , mModel( 0 )
3939 , mCurrentEditSelectionModel( 0 )
4040 , mFeatureSelectionModel( 0 )
41+ , mFeatureSelectionManager( NULL )
4142 , mItemDelegate( 0 )
4243 , mEditSelectionDrag( false )
4344 , mRowAnchor( 0 )
@@ -56,10 +57,15 @@ void QgsFeatureListView::setModel( QgsFeatureListModel* featureListModel )
5657 mModel = featureListModel;
5758
5859 delete mFeatureSelectionModel ;
59- mFeatureSelectionModel = new QgsFeatureSelectionModel ( featureListModel, featureListModel, new QgsVectorLayerSelectionManager ( featureListModel->layerCache ()->layer (), this ), this );
60- setSelectionModel ( mFeatureSelectionModel );
6160
6261 mCurrentEditSelectionModel = new QItemSelectionModel ( mModel ->masterModel (), this );
62+ if ( !mFeatureSelectionManager )
63+ {
64+ mFeatureSelectionManager = new QgsVectorLayerSelectionManager ( mModel ->layerCache ()->layer (), mModel );
65+ }
66+
67+ mFeatureSelectionModel = new QgsFeatureSelectionModel ( featureListModel, featureListModel, mFeatureSelectionManager , this );
68+ setSelectionModel ( mFeatureSelectionModel );
6369
6470 if ( mItemDelegate && mItemDelegate ->parent () == this )
6571 {
@@ -75,6 +81,7 @@ void QgsFeatureListView::setModel( QgsFeatureListModel* featureListModel )
7581 connect ( mFeatureSelectionModel , SIGNAL ( requestRepaint () ), this , SLOT ( repaintRequested () ) );
7682
7783 connect ( mCurrentEditSelectionModel , SIGNAL ( selectionChanged ( QItemSelection, QItemSelection ) ), SLOT ( editSelectionChanged ( QItemSelection, QItemSelection ) ) );
84+
7885}
7986
8087bool QgsFeatureListView::setDisplayExpression ( const QString& expression )
@@ -338,3 +345,13 @@ void QgsFeatureListView::selectRow( const QModelIndex& index, bool anchor )
338345
339346 mFeatureSelectionModel ->selectFeatures ( QItemSelection ( tl, br ), command );
340347}
348+
349+ void QgsFeatureListView::setFeatureSelectionManager ( QgsIFeatureSelectionManager* featureSelectionManager )
350+ {
351+ delete mFeatureSelectionManager ;
352+
353+ mFeatureSelectionManager = featureSelectionManager;
354+
355+ if ( mFeatureSelectionModel )
356+ mFeatureSelectionModel ->setFeatureSelectionManager ( mFeatureSelectionManager );
357+ }
0 commit comments