Skip to content

Commit 7765d8d

Browse files
committed
[GRASS] plugin: removed add raster/vector layer actions, substituted by QGIS browser
1 parent 4d62566 commit 7765d8d

9 files changed

+0
-178
lines changed

src/plugins/grass/qgsgrass_plugin.qrc

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<RCC>
22
<qresource prefix="/images/themes/default/grass">
33
<file alias="grass_add_map.png">themes/default/grass_add_map.png</file>
4-
<file alias="grass_add_raster.png">themes/default/grass_add_raster.png</file>
5-
<file alias="grass_add_vector.png">themes/default/grass_add_vector.png</file>
64
<file alias="grass_add_vertex.png">themes/default/grass_add_vertex.png</file>
75
<file alias="grass_browser_raster_layer.png">themes/default/grass_browser_raster_layer.png</file>
86
<file alias="grass_browser_vector_layer.png">themes/default/grass_browser_vector_layer.png</file>

src/plugins/grass/qgsgrassplugin.cpp

-170
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
7777
, mOpenMapsetAction( 0 )
7878
, mNewMapsetAction( 0 )
7979
, mCloseMapsetAction( 0 )
80-
, mAddVectorAction( 0 )
81-
, mAddRasterAction( 0 )
8280
, mOpenToolsAction( 0 )
8381
, mEditRegionAction( 0 )
8482
, mEditAction( 0 )
@@ -162,12 +160,6 @@ void QgsGrassPlugin::initGui()
162160
mCloseMapsetAction = new QAction( QIcon(), tr( "Close Mapset" ), this );
163161
mCloseMapsetAction->setObjectName( "mCloseMapsetAction" );
164162

165-
mAddVectorAction = new QAction( QIcon(), tr( "Add GRASS Vector Layer" ), this );
166-
mAddVectorAction->setObjectName( "mAddVectorAction" );
167-
mAddVectorAction->setWhatsThis( tr( "Adds a GRASS vector layer to the map canvas" ) );
168-
mAddRasterAction = new QAction( QIcon(), tr( "Add GRASS raster layer" ), this );
169-
mAddRasterAction->setObjectName( "mAddRasterAction" );
170-
mAddRasterAction->setWhatsThis( tr( "Adds a GRASS raster layer to the map canvas" ) );
171163
mOpenToolsAction = new QAction( QIcon(), tr( "Open GRASS Tools" ), this );
172164
mOpenToolsAction->setObjectName( "mOpenToolsAction" );
173165
mOpenToolsAction->setWhatsThis( tr( "Open GRASS tools" ) );
@@ -187,8 +179,6 @@ void QgsGrassPlugin::initGui()
187179
mNewVectorAction->setObjectName( "mNewVectorAction" );
188180

189181
// Connect the action
190-
connect( mAddVectorAction, SIGNAL( triggered() ), this, SLOT( addVector() ) );
191-
connect( mAddRasterAction, SIGNAL( triggered() ), this, SLOT( addRaster() ) );
192182
connect( mOpenToolsAction, SIGNAL( triggered() ), this, SLOT( openTools() ) );
193183
connect( mEditAction, SIGNAL( triggered() ), this, SLOT( edit() ) );
194184
connect( mNewVectorAction, SIGNAL( triggered() ), this, SLOT( newVector() ) );
@@ -202,8 +192,6 @@ void QgsGrassPlugin::initGui()
202192
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenMapsetAction );
203193
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mNewMapsetAction );
204194
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mCloseMapsetAction );
205-
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mAddVectorAction );
206-
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mAddRasterAction );
207195
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mNewVectorAction );
208196
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mEditAction );
209197
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenToolsAction );
@@ -219,8 +207,6 @@ void QgsGrassPlugin::initGui()
219207
mToolBarPointer->addAction( mNewMapsetAction );
220208
mToolBarPointer->addAction( mCloseMapsetAction );
221209
mToolBarPointer->addSeparator();
222-
mToolBarPointer->addAction( mAddVectorAction );
223-
mToolBarPointer->addAction( mAddRasterAction );
224210
mToolBarPointer->addAction( mNewVectorAction );
225211
mToolBarPointer->addAction( mEditAction );
226212
mToolBarPointer->addAction( mOpenToolsAction );
@@ -312,156 +298,6 @@ void QgsGrassPlugin::saveMapset()
312298
QgsGrass::getDefaultMapset() );
313299
}
314300

315-
// Slot called when the "Add GRASS vector layer" menu item is triggered
316-
void QgsGrassPlugin::addVector()
317-
{
318-
// QgsDebugMsg("entered.");
319-
QString uri;
320-
321-
QgsGrassSelect *sel = new QgsGrassSelect( qGisInterface->mainWindow(), QgsGrassSelect::VECTOR );
322-
if ( sel->exec() )
323-
{
324-
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + sel->map + "/" + sel->layer;
325-
}
326-
// QgsDebugMsg(QString("plugin URI: %1").arg(uri));
327-
if ( uri.length() == 0 )
328-
{
329-
// QgsDebugMsg("Nothing was selected");
330-
return;
331-
}
332-
else
333-
{
334-
// QgsDebugMsg("Add new vector layer");
335-
336-
// create vector name: vector layer
337-
QString name = sel->map;
338-
339-
QString field;
340-
QString type;
341-
342-
if ( !sel->layer.startsWith( "topo_" ) )
343-
{
344-
QRegExp rx( "(\\d+)_(.+)" );
345-
if ( rx.indexIn( sel->layer ) != -1 )
346-
{
347-
field = rx.cap( 1 );
348-
type = rx.cap( 2 );
349-
}
350-
}
351-
352-
// Set location
353-
QgsGrass::setLocation( sel->gisdbase, sel->location );
354-
355-
/* Open vector */
356-
try
357-
{
358-
//Vect_set_open_level( 2 );
359-
struct Map_info map;
360-
int level = Vect_open_old_head( &map, sel->map.toUtf8().data(),
361-
sel->mapset.toUtf8().data() );
362-
363-
if ( level == 1 )
364-
{
365-
QgsDebugMsg( "Cannot open vector on level 2" );
366-
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector %1 in mapset %2 on level 2 (topology not available, try to rebuild topology using v.build module)." ).arg( sel->map ).arg( sel->mapset ) );
367-
Vect_close( &map );
368-
return;
369-
}
370-
else if ( level < 1 )
371-
{
372-
QgsDebugMsg( "Cannot open vector" );
373-
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector %1 in mapset %2" ).arg( sel->map ).arg( sel->mapset ) );
374-
return;
375-
}
376-
377-
if ( level >= 2 )
378-
{
379-
if ( !sel->layer.startsWith( "topo_" ) )
380-
{
381-
// Count layers
382-
int cnt = 0;
383-
int ncidx = Vect_cidx_get_num_fields( &map );
384-
385-
for ( int i = 0; i < ncidx; i++ )
386-
{
387-
int field = Vect_cidx_get_field_number( &map, i );
388-
389-
if ( Vect_cidx_get_type_count( &map, field, GV_POINT | GV_LINE | GV_AREA ) > 0 ||
390-
( field > 1 && Vect_cidx_get_type_count( &map, field, GV_BOUNDARY ) ) )
391-
{
392-
cnt++;
393-
}
394-
}
395-
396-
if ( cnt > 1 )
397-
{
398-
name.append( " " + field );
399-
400-
// No need to ad type, the type is obvious from the legend
401-
}
402-
}
403-
else
404-
{
405-
name.append( " " + sel->layer );
406-
}
407-
}
408-
409-
Vect_close( &map );
410-
}
411-
catch ( QgsGrass::Exception &e )
412-
{
413-
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open GRASS vector:\n %1" ).arg( e.what() ) );
414-
}
415-
416-
qGisInterface->addVectorLayer( uri, name, "grass" );
417-
}
418-
}
419-
420-
// Slot called when the "Add GRASS raster layer" menu item is triggered
421-
void QgsGrassPlugin::addRaster()
422-
{
423-
// QgsDebugMsg("entered.");
424-
QString uri;
425-
426-
QgsGrassSelect *sel = new QgsGrassSelect( qGisInterface->mainWindow(), QgsGrassSelect::RASTER );
427-
if ( sel->exec() )
428-
{
429-
QString element;
430-
if ( sel->selectedType == QgsGrassSelect::RASTER )
431-
{
432-
element = "cellhd";
433-
}
434-
else // GROUP
435-
{
436-
element = "group";
437-
}
438-
439-
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + element + "/" + sel->map;
440-
}
441-
442-
// QgsDebugMsg(QString("plugin URI: %1").arg(uri));
443-
444-
if ( uri.length() == 0 )
445-
{
446-
// QgsDebugMsg("Nothing was selected");
447-
return;
448-
}
449-
else
450-
{
451-
452-
// QgsDebugMsg("Add new raster layer");
453-
454-
// create raster name
455-
int pos = uri.lastIndexOf( '/' );
456-
pos = uri.lastIndexOf( '/', pos - 1 );
457-
QString name = uri.right( uri.length() - pos - 1 );
458-
name.replace( '/', ' ' );
459-
460-
//qGisInterface->addRasterLayer( uri, sel->map );
461-
qGisInterface->addRasterLayer( uri, sel->map, "grassraster" );
462-
}
463-
}
464-
465301
// Open tools
466302
void QgsGrassPlugin::openTools()
467303
{
@@ -859,8 +695,6 @@ void QgsGrassPlugin::unload()
859695
qGisInterface->removePluginMenu( tr( "&GRASS" ), mOpenMapsetAction );
860696
qGisInterface->removePluginMenu( tr( "&GRASS" ), mNewMapsetAction );
861697
qGisInterface->removePluginMenu( tr( "&GRASS" ), mCloseMapsetAction );
862-
qGisInterface->removePluginMenu( tr( "&GRASS" ), mAddVectorAction );
863-
qGisInterface->removePluginMenu( tr( "&GRASS" ), mAddRasterAction );
864698
qGisInterface->removePluginMenu( tr( "&GRASS" ), mOpenToolsAction );
865699
qGisInterface->removePluginMenu( tr( "&GRASS" ), mRegionAction );
866700
qGisInterface->removePluginMenu( tr( "&GRASS" ), mEditRegionAction );
@@ -870,8 +704,6 @@ void QgsGrassPlugin::unload()
870704
delete mOpenMapsetAction;
871705
delete mNewMapsetAction;
872706
delete mCloseMapsetAction;
873-
delete mAddVectorAction;
874-
delete mAddRasterAction;
875707
delete mOpenToolsAction;
876708
delete mRegionAction;
877709
delete mEditRegionAction;
@@ -904,8 +736,6 @@ void QgsGrassPlugin::setCurrentTheme( QString theThemeName )
904736
mNewMapsetAction->setIcon( getThemeIcon( "grass_new_mapset.png" ) );
905737
mCloseMapsetAction->setIcon( getThemeIcon( "grass_close_mapset.png" ) );
906738

907-
mAddVectorAction->setIcon( getThemeIcon( "grass_add_vector.png" ) );
908-
mAddRasterAction->setIcon( getThemeIcon( "grass_add_raster.png" ) );
909739
mOpenToolsAction->setIcon( getThemeIcon( "grass_tools.png" ) );
910740

911741
mRegionAction->setIcon( getThemeIcon( "grass_region.png" ) );

src/plugins/grass/qgsgrassplugin.h

-6
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
8585
public slots:
8686
//! init the gui
8787
virtual void initGui() override;
88-
//! Show the dialog box for new vector
89-
void addVector();
90-
//! Show the dialog box for new raster
91-
void addRaster();
9288
//! Start vector editing
9389
void edit();
9490
//! unload the plugin
@@ -164,8 +160,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
164160
QAction *mOpenMapsetAction;
165161
QAction *mNewMapsetAction;
166162
QAction *mCloseMapsetAction;
167-
QAction *mAddVectorAction;
168-
QAction *mAddRasterAction;
169163
QAction *mOpenToolsAction;
170164
QAction *mEditRegionAction;
171165
QAction *mEditAction;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)