Skip to content
Permalink
Browse files

GRASS fixes: remember last mapset, update layer list in tools if a la…

…yer is added/removed
  • Loading branch information
blazek committed May 30, 2013
1 parent 2fcd2da commit 923be58b1ccc3bd4ff8aa507880eae443d89d32f
@@ -132,7 +132,9 @@ void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds )
mOwnedLayers.remove( lyr );
}
mMapLayers.remove( myId );
emit layerRemoved( myId );
}
emit layersRemoved( theLayerIds );
}

void QgsMapLayerRegistry::removeMapLayer( const QString& theLayerId )
@@ -176,6 +176,22 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
*/
void layerWillBeRemoved( QString theLayerId );

/**
* Emitted after one or more layers were removed from the registry
*
* @param theLayerIds A list of ids of the layers which were removed.
*/
void layersRemoved( QStringList theLayerIds );

/**
* Emitted after a layer was removed from the registry
*
* @param theLayerId The id of the layer removed
*
* @note Consider using {@link layersRemoved()} instead
*/
void layerRemoved( QString theLayerId );


/**
* Emitted, when all layers are removed, before {@link layersWillBeRemoved()} and
@@ -2710,8 +2710,7 @@ QgsGrassModuleInput::QgsGrassModuleInput( QgsGrassModule *module,

connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer *> ) ),
this, SLOT( updateQgisLayers() ) );
// layersWillBeRemoved is emitted AFTER the layer was removed from registry
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ),
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersRemoved( QStringList ) ),
this, SLOT( updateQgisLayers() ) );

connect( mLayerComboBox, SIGNAL( activated( int ) ), this, SLOT( changed( int ) ) );
@@ -3348,8 +3347,7 @@ QgsGrassModuleGdalInput::QgsGrassModuleGdalInput(

connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer *> ) ),
this, SLOT( updateQgisLayers() ) );
// layersWillBeRemoved is emitted after the layer was removed from registry
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ),
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersRemoved( QStringList ) ),
this, SLOT( updateQgisLayers() ) );

// Fill in QGIS layers
@@ -3375,12 +3373,9 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
mLayerComboBox->addItem( tr( "Select a layer" ), QVariant() );
}

QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();

int nlayers = canvas->layerCount();
for ( int i = 0; i < nlayers; i++ )
foreach ( QgsMapLayer *layer, QgsMapLayerRegistry::instance()->mapLayers().values() )
{
QgsMapLayer *layer = canvas->layer( i );
if ( !layer ) continue;

if ( mType == Ogr && layer->type() == QgsMapLayer::VectorLayer )
{
@@ -764,7 +764,7 @@ void QgsGrassPlugin::newMapset()

void QgsGrassPlugin::projectRead()
{
// QgsDebugMsg("entered.");
QgsDebugMsg( "entered." );

bool ok;
QString gisdbase = QgsProject::instance()->readEntry(
@@ -774,13 +774,13 @@ void QgsGrassPlugin::projectRead()
QString mapset = QgsProject::instance()->readEntry(
"GRASS", "/WorkingMapset", "", &ok ).trimmed();

if ( gisdbase.length() == 0 || location.length() == 0 ||
mapset.length() == 0 )
if ( gisdbase.isEmpty() || location.isEmpty() || mapset.isEmpty() )
{
// Mapset not specified
return;
}

QgsDebugMsg( "Working mapset specified" );

QString currentPath = QgsGrass::getDefaultGisdbase() + "/"
+ QgsGrass::getDefaultLocation() + "/"
+ QgsGrass::getDefaultMapset();
@@ -55,6 +55,7 @@ QgsGrassSelect::QgsGrassSelect( QWidget *parent, int type ): QDialog( parent ),
QDir home = QDir::home();
lastGisdbase = QString( home.path() );
}
lastMapset = settings.value( "/GRASS/lastMapset" ).toString();
}
first = false;
}
@@ -416,6 +417,8 @@ void QgsGrassSelect::accept()
mapset = emapset->currentText();
lastMapset = mapset;

settings.setValue( "/GRASS/lastMapset", lastMapset );

map = emap->currentText().trimmed();

if ( type != QgsGrassSelect::MAPSET && map.isEmpty() )

0 comments on commit 923be58

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