Skip to content

Commit 71bd8b4

Browse files
committedAug 20, 2015
[GRASS] region dialog integrated to plugin dock widget
1 parent bed703e commit 71bd8b4

File tree

9 files changed

+336
-264
lines changed

9 files changed

+336
-264
lines changed
 

‎src/plugins/grass/qgsgrassplugin.cpp

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
6969
, qGisInterface( theQgisInterFace )
7070
, mCanvas( 0 )
7171
, mRegionAction( 0 )
72-
, mRegion( 0 )
7372
, mRegionBand( 0 )
7473
, mTools( 0 )
7574
, mNewMapset( 0 )
@@ -78,7 +77,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
7877
, mNewMapsetAction( 0 )
7978
, mCloseMapsetAction( 0 )
8079
, mOpenToolsAction( 0 )
81-
, mEditRegionAction( 0 )
8280
, mEditAction( 0 )
8381
, mNewVectorAction( 0 )
8482
{
@@ -135,7 +133,6 @@ void QgsGrassPlugin::initGui()
135133
mToolBarPointer = 0;
136134
mTools = 0;
137135
mNewMapset = 0;
138-
mRegion = 0;
139136

140137
QSettings settings;
141138
QgsGrass::init();
@@ -169,9 +166,6 @@ void QgsGrassPlugin::initGui()
169166
mRegionAction->setWhatsThis( tr( "Displays the current GRASS region as a rectangle on the map canvas" ) );
170167
mRegionAction->setCheckable( true );
171168

172-
mEditRegionAction = new QAction( QIcon(), tr( "Edit Current Grass Region" ), this );
173-
mEditRegionAction->setObjectName( "mEditRegionAction" );
174-
mEditRegionAction->setWhatsThis( tr( "Edit the current GRASS region" ) );
175169
mEditAction = new QAction( QIcon(), tr( "Edit Grass Vector layer" ), this );
176170
mEditAction->setObjectName( "mEditAction" );
177171
mEditAction->setWhatsThis( tr( "Edit the currently selected GRASS vector layer." ) );
@@ -183,7 +177,6 @@ void QgsGrassPlugin::initGui()
183177
connect( mEditAction, SIGNAL( triggered() ), this, SLOT( edit() ) );
184178
connect( mNewVectorAction, SIGNAL( triggered() ), this, SLOT( newVector() ) );
185179
connect( mRegionAction, SIGNAL( toggled( bool ) ), this, SLOT( switchRegion( bool ) ) );
186-
connect( mEditRegionAction, SIGNAL( triggered() ), this, SLOT( changeRegion() ) );
187180
connect( mOpenMapsetAction, SIGNAL( triggered() ), this, SLOT( openMapset() ) );
188181
connect( mNewMapsetAction, SIGNAL( triggered() ), this, SLOT( newMapset() ) );
189182
connect( mCloseMapsetAction, SIGNAL( triggered() ), this, SLOT( closeMapset() ) );
@@ -196,7 +189,6 @@ void QgsGrassPlugin::initGui()
196189
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mEditAction );
197190
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenToolsAction );
198191
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mRegionAction );
199-
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mEditRegionAction );
200192

201193
// Add the toolbar to the main window
202194
mToolBarPointer = qGisInterface->addToolBar( tr( "GRASS" ) );
@@ -211,7 +203,6 @@ void QgsGrassPlugin::initGui()
211203
mToolBarPointer->addAction( mEditAction );
212204
mToolBarPointer->addAction( mOpenToolsAction );
213205
mToolBarPointer->addAction( mRegionAction );
214-
mToolBarPointer->addAction( mEditRegionAction );
215206

216207
// Set icons to current theme
217208
setCurrentTheme( "" );
@@ -226,6 +217,7 @@ void QgsGrassPlugin::initGui()
226217
this, SLOT( setEditAction() ) );
227218

228219
connect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), SLOT( mapsetChanged() ) );
220+
connect( QgsGrass::instance(), SIGNAL( regionChanged() ), SLOT( displayRegion() ) );
229221
connect( QgsGrass::instance(), SIGNAL( regionPenChanged() ), SLOT( displayRegion() ) );
230222

231223
mapsetChanged();
@@ -241,15 +233,13 @@ void QgsGrassPlugin::mapsetChanged()
241233
if ( !QgsGrass::activeMode() )
242234
{
243235
mRegionAction->setEnabled( false );
244-
mEditRegionAction->setEnabled( false );
245236
mRegionBand->reset();
246237
mCloseMapsetAction->setEnabled( false );
247238
mNewVectorAction->setEnabled( false );
248239
}
249240
else
250241
{
251242
mRegionAction->setEnabled( true );
252-
mEditRegionAction->setEnabled( true );
253243
mCloseMapsetAction->setEnabled( true );
254244
mNewVectorAction->setEnabled( true );
255245

@@ -458,15 +448,19 @@ void QgsGrassPlugin::postRender( QPainter *painter )
458448

459449
void QgsGrassPlugin::displayRegion()
460450
{
461-
// QgsDebugMsg("entered.");
451+
QgsDebugMsg( "entered" );
462452

463453
mRegionBand->reset();
464454
if ( !mRegionAction->isChecked() )
455+
{
465456
return;
457+
}
466458

467459
// Display region of current mapset if in active mode
468460
if ( !QgsGrass::activeMode() )
461+
{
469462
return;
463+
}
470464

471465
struct Cell_head window;
472466
try
@@ -512,29 +506,6 @@ void QgsGrassPlugin::redrawRegion()
512506
displayRegion();
513507
}
514508

515-
void QgsGrassPlugin::changeRegion( void )
516-
{
517-
// QgsDebugMsg("entered.");
518-
519-
if ( mRegion ) // running
520-
{
521-
mRegion->show();
522-
return;
523-
}
524-
525-
// Warning: don't use Qt::WType_Dialog, it would ignore restorePosition
526-
mRegion = new QgsGrassRegion( this, qGisInterface, qGisInterface->mainWindow() );
527-
528-
connect( mRegion, SIGNAL( destroyed( QObject * ) ), this, SLOT( regionClosed() ) );
529-
530-
mRegion->show();
531-
}
532-
533-
void QgsGrassPlugin::regionClosed()
534-
{
535-
mRegion = 0;
536-
}
537-
538509
void QgsGrassPlugin::openMapset()
539510
{
540511
// QgsDebugMsg("entered.");
@@ -647,7 +618,6 @@ void QgsGrassPlugin::unload()
647618
qGisInterface->removePluginMenu( tr( "&GRASS" ), mCloseMapsetAction );
648619
qGisInterface->removePluginMenu( tr( "&GRASS" ), mOpenToolsAction );
649620
qGisInterface->removePluginMenu( tr( "&GRASS" ), mRegionAction );
650-
qGisInterface->removePluginMenu( tr( "&GRASS" ), mEditRegionAction );
651621
qGisInterface->removePluginMenu( tr( "&GRASS" ), mEditAction );
652622
qGisInterface->removePluginMenu( tr( "&GRASS" ), mNewVectorAction );
653623

@@ -656,7 +626,6 @@ void QgsGrassPlugin::unload()
656626
delete mCloseMapsetAction;
657627
delete mOpenToolsAction;
658628
delete mRegionAction;
659-
delete mEditRegionAction;
660629
delete mEditAction;
661630
delete mNewVectorAction;
662631

@@ -690,7 +659,6 @@ void QgsGrassPlugin::setCurrentTheme( QString theThemeName )
690659

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

693-
mEditRegionAction->setIcon( getThemeIcon( "grass_region_edit.png" ) );
694662
mEditAction->setIcon( getThemeIcon( "grass_edit.png" ) );
695663
mNewVectorAction->setIcon( getThemeIcon( "grass_new_vector_layer.png" ) );
696664
}

‎src/plugins/grass/qgsgrassplugin.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
8989
void displayRegion();
9090
//! Switch region on/off
9191
void switchRegion( bool on );
92-
//! Change region
93-
void changeRegion( void );
94-
//! Region dialog closed
95-
void regionClosed();
9692
//! Redraw region
9793
void redrawRegion( void );
9894
//! Post render
@@ -133,8 +129,7 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
133129

134130
//! Pointer to Display region acction
135131
QAction *mRegionAction;
136-
//! Region dialog
137-
QgsGrassRegion *mRegion;
132+
138133
// Region rubber band
139134
QgsRubberBand *mRegionBand;
140135
//! GRASS tools
@@ -151,7 +146,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
151146
QAction *mNewMapsetAction;
152147
QAction *mCloseMapsetAction;
153148
QAction *mOpenToolsAction;
154-
QAction *mEditRegionAction;
155149
QAction *mEditAction;
156150
QAction *mNewVectorAction;
157151
};

0 commit comments

Comments
 (0)