Skip to content

Commit a82a243

Browse files
committedApr 7, 2012
Remove/Add layers to snapping dialog. Fixes #5318
1 parent 6403ebd commit a82a243

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed
 

‎src/app/qgssnappingdialog.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
6969
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) );
7070
connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
7171
}
72-
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( addLayer( QgsMapLayer * ) ) );
73-
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layerWillBeRemoved( QString ) ) );
72+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer * > ) ), this, SLOT( addLayers( QList<QgsMapLayer * > ) ) );
73+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) );
7474
connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) );
7575

7676
mLayerTreeWidget->clear();
@@ -180,6 +180,14 @@ void QgsSnappingDialog::show()
180180
QDialog::show();
181181
}
182182

183+
void QgsSnappingDialog::addLayers( QList<QgsMapLayer *> layers )
184+
{
185+
foreach( QgsMapLayer* layer, layers )
186+
{
187+
addLayer( layer );
188+
}
189+
}
190+
183191
void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
184192
{
185193
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( theMapLayer );
@@ -298,20 +306,23 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
298306
}
299307
}
300308

301-
void QgsSnappingDialog::layerWillBeRemoved( QString theLayerId )
309+
void QgsSnappingDialog::layersWillBeRemoved( QStringList thelayers )
302310
{
303-
QTreeWidgetItem *item = 0;
304-
305-
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
311+
foreach( QString theLayerId, thelayers )
306312
{
307-
item = mLayerTreeWidget->topLevelItem( i );
308-
if ( item && item->data( 0, Qt::UserRole ).toString() == theLayerId )
309-
break;
310-
item = 0;
311-
}
313+
QTreeWidgetItem *item = 0;
314+
315+
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
316+
{
317+
item = mLayerTreeWidget->topLevelItem( i );
318+
if ( item && item->data( 0, Qt::UserRole ).toString() == theLayerId )
319+
break;
320+
item = 0;
321+
}
312322

313-
if ( item )
314-
delete item;
323+
if ( item )
324+
delete item;
325+
}
315326
}
316327

317328
void QgsSnappingDialog::setTopologicalEditingState()

‎src/app/qgssnappingdialog.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
4848
//! add layer to tree
4949
void addLayer( QgsMapLayer* theMapLayer );
5050

51-
//! layer removed
52-
void layerWillBeRemoved( QString );
51+
void addLayers( QList<QgsMapLayer * > layers );
52+
53+
//! layers removed
54+
void layersWillBeRemoved( QStringList );
5355

5456
void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int );
5557

0 commit comments

Comments
 (0)
Please sign in to comment.