Skip to content

Commit

Permalink
Fix for #241: don't use 0_* layers as default
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6211 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Dec 8, 2006
1 parent b3f9dcd commit 09bfc8a
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 09bfc8a

Please sign in to comment.