Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for #241: don't use 0_* layers as default
git-svn-id: http://svn.osgeo.org/qgis/trunk@6211 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Dec 8, 2006
1 parent 2691adc commit 493e742
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -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");
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/grass/qgsgrassselect.cpp
Expand Up @@ -273,6 +273,7 @@ void QgsGrassSelect::setMaps()
if ( list[j] == lastVectorMap ) sel = idx;
idx++;
}

}
else if ( type == RASTER )
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 493e742

Please sign in to comment.