Skip to content
Permalink
Browse files

Fix for #241: don't use 0_* layers as default

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6211 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Dec 8, 2006
1 parent b3f9dcd commit 09bfc8aa0f9b9d2e2bff71f0cca8481c5440f7e0
Showing with 31 additions and 0 deletions.
  1. +16 −0 src/plugins/grass/qgsgrassmodule.cpp
  2. +15 −0 src/plugins/grass/qgsgrassselect.cpp
@@ -1514,13 +1514,29 @@ void QgsGrassModule::viewOutput()
QgsGrass::getDefaultLocation(),
QgsGrass::getDefaultMapset(), map );

// check whether there are 1_* layers
// if so, 0_* layers won't be added
bool onlyLayer1 = false;
for ( int j = 0; j < layers.count(); j++ )
{
if (layers[j].left(1) == "1")
{
onlyLayer1 = true;
break;
}
}

// TODO common method for add all layers
for ( int j = 0; j < layers.count(); j++ )
{
QString uri = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ QgsGrass::getDefaultMapset() + "/"
+ map + "/" + layers[j];

// skip 0_* layers
if (onlyLayer1 && layers[j].left(1) != "1")
continue;

// TODO vector layer name
mIface->addVectorLayer( uri, layers[j], "grass");
@@ -273,6 +273,7 @@ void QgsGrassSelect::setMaps()
if ( list[j] == lastVectorMap ) sel = idx;
idx++;
}

}
else if ( type == RASTER )
{
@@ -354,6 +355,20 @@ void QgsGrassSelect::setLayers()
idx++;
}

// if last used layer has not been found
// make default a map from layer 1
if (sel == -1)
{
for ( int j = 0; j < layers.count(); j++ )
{
if (layers[j].left(1) == "1")
{
sel = j;
break;
}
}
}

if ( sel >= 0 ) {
elayer->setCurrentItem(sel);
} else {

0 comments on commit 09bfc8a

Please sign in to comment.
You can’t perform that action at this time.