Skip to content
Permalink
Browse files

[GRASS][feature] delete vector layer browser action

  • Loading branch information
blazek committed May 4, 2015
1 parent f800ac6 commit 9e09646410c60fe8fe99f263cd2c8e882f01aea3
@@ -447,38 +447,22 @@ void QgsGrassBrowser::deleteMap()
QString mapset = mModel->itemMapset( *it );
QString map = mModel->itemMap( *it );

QString typeName;
if ( type == QgsGrassModel::Raster )
typeName = "rast";
else if ( type == QgsGrassModel::Vector )
typeName = "vect";
else if ( type == QgsGrassModel::Region )
typeName = "region";

if ( mapset != QgsGrass::getDefaultMapset() )
{
continue; // should not happen
}

QString module = "g.remove";
#ifdef WIN32
module.append( ".exe" );
#endif
QProcess process( this );
QStringList args( typeName + "=" + map );
process.start( module, QStringList( typeName + "=" + map ) );
if ( !process.waitForFinished() || process.exitCode() != 0 )
{
QString output( process.readAllStandardOutput() );
QString error( process.readAllStandardError() );
QMessageBox::warning( 0, tr( "Warning" ),
tr( "Cannot delete map %1" )
.arg( map )
+ tr( "<br>command: %1 %2<br>%3<br>%4" )
.arg( map ).arg( module ).arg( args.join( " " ) )
.arg( output ).arg( error ) );
}
else
QgsGrassObject::Type mapType;
if ( type == QgsGrassModel::Raster )
mapType = QgsGrassObject::Raster;
else if ( type == QgsGrassModel::Vector )
mapType = QgsGrassObject::Vector;
else if ( type == QgsGrassModel::Region )
mapType = QgsGrassObject::Region;

QgsGrassObject object( gisbase, location, mapset, map, mapType );

if ( QgsGrass::deleteObject( object ) )
{
refresh();
}
@@ -528,17 +512,17 @@ bool QgsGrassBrowser::getItemRegion( const QModelIndex & index, struct Cell_head
QString mapset = mModel->itemMapset( index );
QString map = mModel->itemMap( index );

int mapType = QgsGrass::Raster; //default in case no case matches
QgsGrassObject::Type mapType = QgsGrassObject::Raster; //default in case no case matches
switch ( type )
{
case QgsGrassModel::Raster :
mapType = QgsGrass::Raster;
mapType = QgsGrassObject::Raster;
break;
case QgsGrassModel::Vector :
mapType = QgsGrass::Vector;
mapType = QgsGrassObject::Vector;
break;
case QgsGrassModel::Region :
mapType = QgsGrass::Region;
mapType = QgsGrassObject::Region;
break;
default:
break;
@@ -512,7 +512,7 @@ QStringList QgsGrassMapcalc::checkRegion()
if ( mm.size() > 1 )
mapset = mm.at( 1 );

if ( !QgsGrass::mapRegion( QgsGrass::Raster,
if ( !QgsGrass::mapRegion( QgsGrassObject::Raster,
QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(), mapset, map,
&window ) )
@@ -570,7 +570,7 @@ bool QgsGrassMapcalc::inputRegion( struct Cell_head *window, QgsCoordinateRefere
if ( mm.size() > 1 )
mapset = mm.at( 1 );

if ( !QgsGrass::mapRegion( QgsGrass::Raster,
if ( !QgsGrass::mapRegion( QgsGrassObject::Raster,
QgsGrass::getDefaultGisdbase(),
QgsGrass::getDefaultLocation(), mapset, map,
&mapWindow ) )
@@ -986,14 +986,14 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
if ( !item )
continue;

QgsGrass::MapType mapType = QgsGrass::Vector;
QgsGrassObject::Type mapType = QgsGrassObject::Vector;
switch ( item->type() )
{
case QgsGrassModuleInput::Raster :
mapType = QgsGrass::Raster;
mapType = QgsGrassObject::Raster;
break;
case QgsGrassModuleInput::Vector :
mapType = QgsGrass::Vector;
mapType = QgsGrassObject::Vector;
break;
}

@@ -1165,15 +1165,15 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo
if ( !all && !item->useRegion() )
continue;

QgsGrass::MapType mapType = QgsGrass::Vector;
QgsGrassObject::Type mapType = QgsGrassObject::Vector;

switch ( item->type() )
{
case QgsGrassModuleInput::Raster :
mapType = QgsGrass::Raster;
mapType = QgsGrassObject::Raster;
break;
case QgsGrassModuleInput::Vector :
mapType = QgsGrass::Vector;
mapType = QgsGrassObject::Vector;
break;
}

@@ -20,9 +20,9 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION)
SET(GRASS_MAJOR_VERSION ${GRASS_MAJOR_VERSION${GRASS_BUILD_VERSION}})
SET(GRASS_MINOR_VERSION ${GRASS_MINOR_VERSION${GRASS_BUILD_VERSION}})

QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS ../qgsgrassprovider.h)
QT4_WRAP_CPP(GRASS_LIBRARY_MOC_SRCS ../qgsgrassprovider.h)

ADD_LIBRARY(qgisgrass${GRASS_BUILD_VERSION} SHARED ../qgsgrass.cpp ../qgsgrassfeatureiterator.cpp ../qgsgrassprovider.cpp ${GRASS_PROVIDER_MOC_SRCS})
ADD_LIBRARY(qgisgrass${GRASS_BUILD_VERSION} SHARED ../qgsgrass.cpp ../qgsgrassfeatureiterator.cpp ../qgsgrassprovider.cpp ${GRASS_LIBRARY_MOC_SRCS})

SET_TARGET_PROPERTIES(qgisgrass${GRASS_BUILD_VERSION} PROPERTIES
CLEAN_DIRECT_OUTPUT 1
@@ -78,7 +78,8 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION)
#
# GRASS vector provider
#
ADD_LIBRARY(grassprovider${GRASS_BUILD_VERSION} MODULE ../qgsgrassprovidermodule.cpp)
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS ../qgsgrassprovidermodule.h)
ADD_LIBRARY(grassprovider${GRASS_BUILD_VERSION} MODULE ../qgsgrassprovidermodule.cpp ${GRASS_PROVIDER_MOC_SRCS})
SET_TARGET_PROPERTIES(grassprovider${GRASS_BUILD_VERSION} PROPERTIES
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\" \"-DGRASS_EXPORT=${DLLEXPORT}\" \"-DGRASS_LIB_EXPORT=${DLLIMPORT}\""
)

0 comments on commit 9e09646

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