Skip to content
Permalink
Browse files
[BACKPORT] to 1.8. Remove deprecated use of map layer registry addLay…
…er and removeLayer elsewhere in code base
  • Loading branch information
timlinux committed Apr 4, 2012
1 parent 8d4a656 commit d830d537a67bc4850b069418cc06a547e6373b09
@@ -1172,7 +1172,8 @@ void QgsLegend::removeGroup( QgsLegendGroup *lg )
QgsLegendGroup *cg = dynamic_cast<QgsLegendGroup *>( child );

if ( cl )
QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->id() );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << cl->layer()->id() );
else if ( cg )
removeGroup( cg );

@@ -2420,7 +2421,8 @@ void QgsLegend::removeSelectedLayers()
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
if ( ll && ll->layer() )
{
QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->id() );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << ll->layer()->id() );
continue;
}
}
@@ -429,7 +429,11 @@ bool QgsNewSpatialiteLayerDialog::apply()
if ( layer->isValid() )
{
// register this layer with the central layers registry
if ( QgsMapLayerRegistry::instance()->addMapLayer( layer ) )
QList<QgsMapLayer *> myList;
myList << layer;
//addMapLayers returns a list of all successfully added layers
//so we compare that to our original list.
if ( myList == QgsMapLayerRegistry::instance()->addMapLayers( myList ) )
return true;
}
else
@@ -245,7 +245,8 @@ bool QgsBrowser::layerClicked( QgsLayerItem *item )

QgsDebugMsg( "Layer created" );

QgsMapLayerRegistry::instance()->addMapLayer( mLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mLayer );

return true;
}
@@ -100,7 +100,8 @@ bool QgsPluginLayerRegistry::removePluginLayerType( QString typeName )
QgsPluginLayer* pl = qobject_cast<QgsPluginLayer*>( layer );
if ( pl->pluginLayerType() == typeName )
{
QgsMapLayerRegistry::instance()->removeMapLayer( layer->id() );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << layer->id() );
}
}
}
@@ -1427,7 +1427,8 @@ QStringList QgsWMSServer::layerSet( const QStringList &layersList,
if ( theMapLayer )
{
layerKeys.push_front( theMapLayer->id() );
QgsMapLayerRegistry::instance()->addMapLayer( theMapLayer, false );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << theMapLayer, false );
}
else
{
@@ -146,7 +146,8 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
// delete layer (and don't signal it as it's our private layer)
if ( mLayer )
{
QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->id(), false );
QgsMapLayerRegistry::instance()->removeMapLayers(
(QStringList() << mLayer->id()), false );
}

delete mToolZoomIn;
@@ -251,7 +252,8 @@ void QgsGeorefPluginGui::openRaster()

//delete any old rasterlayers
if ( mLayer )
QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->id(), false );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << mLayer->id(), false );

// Add raster
addRaster( mRasterFileName );
@@ -1039,7 +1041,8 @@ void QgsGeorefPluginGui::addRaster( QString file )
mLayer = new QgsRasterLayer( file, "Raster" );

// so layer is not added to legend
QgsMapLayerRegistry::instance()->addMapLayer( mLayer, false );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mLayer, false );

// add layer to map canvas
QList<QgsMapCanvasLayer> layers;
@@ -182,7 +182,8 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
copySymbology( offlineLayer, remoteLayer );

// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( remoteLayer, true );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << remoteLayer, true );

// apply layer edit log
QString qgisLayerId = layer->id();
@@ -233,7 +234,8 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface )
}

// remove offline layer
QgsMapLayerRegistry::instance()->removeMapLayer( qgisLayerId, true );
QgsMapLayerRegistry::instance()->removeMapLayers(
(QStringList() << qgisLayerId), true );

// disable offline project
QString projectTitle = QgsProject::instance()->title();
@@ -495,7 +497,8 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
}

// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( newLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << newLayer );

if ( hasLabels )
{
@@ -567,7 +570,8 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con
}

// remove remote layer
QgsMapLayerRegistry::instance()->removeMapLayer( layer->id() );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << layer->id() );
}
}
}
@@ -85,7 +85,9 @@ QgsVectorLayer* RgExportDlg::mapLayer() const
QList<QgsField> attrList;
attrList.append( QgsField( "one", QVariant::Int ) );
prov->addAttributes( attrList );
QgsMapLayerRegistry::instance()->addMapLayer( myLayer );
QList<QgsMapLayer *> myList;
myList << myLayer;
QgsMapLayerRegistry::instance()->addMapLayers( myList );

}
else
@@ -298,7 +298,8 @@ bool QgsSpatialQueryDialog::addLayerSubset( QString name, QString subset )
delete addLyr;
return false;
}
QgsMapLayerRegistry::instance()->addMapLayer( addLyr );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << addLyr );
return true;
} // bool QgsSpatialQueryDialog::addLayerSubset( QString name, QString subset )

@@ -152,7 +152,9 @@ void SqlAnywhere::addSqlAnywhereLayer()
SaDebugMsg( "Beautifying layer name. new: " + layer->name() );

// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer(( QgsVectorLayer* )layer );
QList<QgsMapLayer *> myList;
myList << ( QgsVectorLayer* )layer;
QgsMapLayerRegistry::instance()->addMapLayers( myList );
}
else
{
@@ -75,7 +75,9 @@ void Regression992::initTestCase()
mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName() );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpRasterLayer );
QList<QgsMapLayer *> myList;
myList << mpRasterLayer;
QgsMapLayerRegistry::instance()->addMapLayers( myList );
// add the test layer to the maprender
mpMapRenderer = new QgsMapRenderer();
QStringList myLayers;
@@ -166,7 +166,8 @@ void TestQgsMapRenderer::initTestCase()
mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(),
myPolyFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );
// add the test layer to the maprender
mpMapRenderer = new QgsMapRenderer();
QStringList myLayers;
@@ -90,8 +90,10 @@ void TestQgsRasterLayer::initTestCase()
mpLandsatRasterLayer = new QgsRasterLayer( myLandsatRasterFileInfo.filePath(),
myLandsatRasterFileInfo.completeBaseName() );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpRasterLayer );
QgsMapLayerRegistry::instance()->addMapLayer( mpLandsatRasterLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpRasterLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpLandsatRasterLayer );
// add the test layer to the maprender
mpMapRenderer = new QgsMapRenderer();
QStringList myLayers;
@@ -237,8 +239,10 @@ void TestQgsRasterLayer::registry()
QgsRasterLayer * mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName() );

QgsMapLayerRegistry::instance()->addMapLayer( mypLayer, false );
QgsMapLayerRegistry::instance()->removeMapLayer( mypLayer->id() );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mypLayer, false );
QgsMapLayerRegistry::instance()->removeMapLayers(
QStringList() << mypLayer->id() );
//cleanup
//delete mypLayer;
}
@@ -90,7 +90,8 @@ void TestQgsRenderers::initTestCase()
mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpPointsLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPointsLayer );

//
//create a poly layer that will be used in all tests...
@@ -100,7 +101,8 @@ void TestQgsRenderers::initTestCase()
mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(),
myPolyFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );


//
@@ -111,7 +113,8 @@ void TestQgsRenderers::initTestCase()
mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(),
myLineFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpLinesLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpLinesLayer );
//
// We only need maprender instead of mapcanvas
// since maprender does not require a qui
@@ -81,7 +81,8 @@ class TestQgsVectorLayer: public QObject
mpNonSpatialLayer = new QgsVectorLayer( myDbfFileInfo.filePath(),
myDbfFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpNonSpatialLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpNonSpatialLayer );
//
//create a point layer that will be used in all tests...
//
@@ -90,7 +91,8 @@ class TestQgsVectorLayer: public QObject
mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpPointsLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPointsLayer );

//
//create a poly layer that will be used in all tests...
@@ -100,7 +102,8 @@ class TestQgsVectorLayer: public QObject
mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(),
myPolyFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );


//
@@ -111,7 +114,8 @@ class TestQgsVectorLayer: public QObject
mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(),
myLineFileInfo.completeBaseName(), "ogr" );
// Register the layer with the registry
QgsMapLayerRegistry::instance()->addMapLayer( mpLinesLayer );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpLinesLayer );
//
// We only need maprender instead of mapcanvas
// since maprender does not require a qui

0 comments on commit d830d53

Please sign in to comment.