Skip to content

Commit 9e09646

Browse files
committedMay 4, 2015
[GRASS][feature] delete vector layer browser action
1 parent f800ac6 commit 9e09646

File tree

9 files changed

+306
-101
lines changed

9 files changed

+306
-101
lines changed
 

‎src/plugins/grass/qgsgrassbrowser.cpp

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -447,38 +447,22 @@ void QgsGrassBrowser::deleteMap()
447447
QString mapset = mModel->itemMapset( *it );
448448
QString map = mModel->itemMap( *it );
449449

450-
QString typeName;
451-
if ( type == QgsGrassModel::Raster )
452-
typeName = "rast";
453-
else if ( type == QgsGrassModel::Vector )
454-
typeName = "vect";
455-
else if ( type == QgsGrassModel::Region )
456-
typeName = "region";
457-
458450
if ( mapset != QgsGrass::getDefaultMapset() )
459451
{
460452
continue; // should not happen
461453
}
462454

463-
QString module = "g.remove";
464-
#ifdef WIN32
465-
module.append( ".exe" );
466-
#endif
467-
QProcess process( this );
468-
QStringList args( typeName + "=" + map );
469-
process.start( module, QStringList( typeName + "=" + map ) );
470-
if ( !process.waitForFinished() || process.exitCode() != 0 )
471-
{
472-
QString output( process.readAllStandardOutput() );
473-
QString error( process.readAllStandardError() );
474-
QMessageBox::warning( 0, tr( "Warning" ),
475-
tr( "Cannot delete map %1" )
476-
.arg( map )
477-
+ tr( "<br>command: %1 %2<br>%3<br>%4" )
478-
.arg( map ).arg( module ).arg( args.join( " " ) )
479-
.arg( output ).arg( error ) );
480-
}
481-
else
455+
QgsGrassObject::Type mapType;
456+
if ( type == QgsGrassModel::Raster )
457+
mapType = QgsGrassObject::Raster;
458+
else if ( type == QgsGrassModel::Vector )
459+
mapType = QgsGrassObject::Vector;
460+
else if ( type == QgsGrassModel::Region )
461+
mapType = QgsGrassObject::Region;
462+
463+
QgsGrassObject object( gisbase, location, mapset, map, mapType );
464+
465+
if ( QgsGrass::deleteObject( object ) )
482466
{
483467
refresh();
484468
}
@@ -528,17 +512,17 @@ bool QgsGrassBrowser::getItemRegion( const QModelIndex & index, struct Cell_head
528512
QString mapset = mModel->itemMapset( index );
529513
QString map = mModel->itemMap( index );
530514

531-
int mapType = QgsGrass::Raster; //default in case no case matches
515+
QgsGrassObject::Type mapType = QgsGrassObject::Raster; //default in case no case matches
532516
switch ( type )
533517
{
534518
case QgsGrassModel::Raster :
535-
mapType = QgsGrass::Raster;
519+
mapType = QgsGrassObject::Raster;
536520
break;
537521
case QgsGrassModel::Vector :
538-
mapType = QgsGrass::Vector;
522+
mapType = QgsGrassObject::Vector;
539523
break;
540524
case QgsGrassModel::Region :
541-
mapType = QgsGrass::Region;
525+
mapType = QgsGrassObject::Region;
542526
break;
543527
default:
544528
break;

‎src/plugins/grass/qgsgrassmapcalc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ QStringList QgsGrassMapcalc::checkRegion()
512512
if ( mm.size() > 1 )
513513
mapset = mm.at( 1 );
514514

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

573-
if ( !QgsGrass::mapRegion( QgsGrass::Raster,
573+
if ( !QgsGrass::mapRegion( QgsGrassObject::Raster,
574574
QgsGrass::getDefaultGisdbase(),
575575
QgsGrass::getDefaultLocation(), mapset, map,
576576
&mapWindow ) )

‎src/plugins/grass/qgsgrassmodule.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -986,14 +986,14 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
986986
if ( !item )
987987
continue;
988988

989-
QgsGrass::MapType mapType = QgsGrass::Vector;
989+
QgsGrassObject::Type mapType = QgsGrassObject::Vector;
990990
switch ( item->type() )
991991
{
992992
case QgsGrassModuleInput::Raster :
993-
mapType = QgsGrass::Raster;
993+
mapType = QgsGrassObject::Raster;
994994
break;
995995
case QgsGrassModuleInput::Vector :
996-
mapType = QgsGrass::Vector;
996+
mapType = QgsGrassObject::Vector;
997997
break;
998998
}
999999

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

1168-
QgsGrass::MapType mapType = QgsGrass::Vector;
1168+
QgsGrassObject::Type mapType = QgsGrassObject::Vector;
11691169

11701170
switch ( item->type() )
11711171
{
11721172
case QgsGrassModuleInput::Raster :
1173-
mapType = QgsGrass::Raster;
1173+
mapType = QgsGrassObject::Raster;
11741174
break;
11751175
case QgsGrassModuleInput::Vector :
1176-
mapType = QgsGrass::Vector;
1176+
mapType = QgsGrassObject::Vector;
11771177
break;
11781178
}
11791179

‎src/providers/grass/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION)
2020
SET(GRASS_MAJOR_VERSION ${GRASS_MAJOR_VERSION${GRASS_BUILD_VERSION}})
2121
SET(GRASS_MINOR_VERSION ${GRASS_MINOR_VERSION${GRASS_BUILD_VERSION}})
2222

23-
QT4_WRAP_CPP(GRASS_PROVIDER_MOC_SRCS ../qgsgrassprovider.h)
23+
QT4_WRAP_CPP(GRASS_LIBRARY_MOC_SRCS ../qgsgrassprovider.h)
2424

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.