Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:qgis/Quantum-GIS
  • Loading branch information
timlinux committed Apr 7, 2012
2 parents 8ae8e15 + a82a243 commit 7326925
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -1649,11 +1649,11 @@ void QgisApp::setupConnections()
this, SLOT( markDirty() ) );

// connect map layer registry
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QgsMapLayer * ) ),
this, SLOT( layersWereAdded( QgsMapLayer * ) ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer *> ) ),
this, SLOT( layersWereAdded( QList<QgsMapLayer *> ) ) );
connect( QgsMapLayerRegistry::instance(),
SIGNAL( layersWillBeRemoved( QStringList ) ),
this, SLOT( removingLayer( QString ) ) );
this, SLOT( removingLayers( QStringList ) ) );

// Connect warning dialog from project reading
connect( QgsProject::instance(), SIGNAL( oldProjectVersionWarning( QString ) ),
Expand Down
37 changes: 24 additions & 13 deletions src/app/qgssnappingdialog.cpp
Expand Up @@ -69,8 +69,8 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
}
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( addLayer( QgsMapLayer * ) ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layerWillBeRemoved( QString ) ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer * > ) ), this, SLOT( addLayers( QList<QgsMapLayer * > ) ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) );
connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) );

mLayerTreeWidget->clear();
Expand Down Expand Up @@ -180,6 +180,14 @@ void QgsSnappingDialog::show()
QDialog::show();
}

void QgsSnappingDialog::addLayers( QList<QgsMapLayer *> layers )
{
foreach( QgsMapLayer* layer, layers )
{
addLayer( layer );
}
}

void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
{
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( theMapLayer );
Expand Down Expand Up @@ -298,20 +306,23 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
}
}

void QgsSnappingDialog::layerWillBeRemoved( QString theLayerId )
void QgsSnappingDialog::layersWillBeRemoved( QStringList thelayers )
{
QTreeWidgetItem *item = 0;

for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
foreach( QString theLayerId, thelayers )
{
item = mLayerTreeWidget->topLevelItem( i );
if ( item && item->data( 0, Qt::UserRole ).toString() == theLayerId )
break;
item = 0;
}
QTreeWidgetItem *item = 0;

for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
{
item = mLayerTreeWidget->topLevelItem( i );
if ( item && item->data( 0, Qt::UserRole ).toString() == theLayerId )
break;
item = 0;
}

if ( item )
delete item;
if ( item )
delete item;
}
}

void QgsSnappingDialog::setTopologicalEditingState()
Expand Down
6 changes: 4 additions & 2 deletions src/app/qgssnappingdialog.h
Expand Up @@ -48,8 +48,10 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
//! add layer to tree
void addLayer( QgsMapLayer* theMapLayer );

//! layer removed
void layerWillBeRemoved( QString );
void addLayers( QList<QgsMapLayer * > layers );

//! layers removed
void layersWillBeRemoved( QStringList );

void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int );

Expand Down

0 comments on commit 7326925

Please sign in to comment.