Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GRASS] fixed saving mapset to project
  • Loading branch information
blazek committed Aug 24, 2015
1 parent 3c0fe13 commit 42953e6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/plugins/grass/qgsgrassplugin.cpp
Expand Up @@ -93,6 +93,7 @@ QgsGrassPlugin::~QgsGrassPlugin()
{
mEdit->closeEdit();
}
disconnect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), this, SLOT( mapsetChanged() ) );
QgsGrass::instance()->closeMapsetWarn();
}

Expand Down Expand Up @@ -181,7 +182,7 @@ void QgsGrassPlugin::initGui()
connect( mRegionAction, SIGNAL( toggled( bool ) ), this, SLOT( switchRegion( bool ) ) );
connect( mOpenMapsetAction, SIGNAL( triggered() ), this, SLOT( openMapset() ) );
connect( mNewMapsetAction, SIGNAL( triggered() ), this, SLOT( newMapset() ) );
connect( mCloseMapsetAction, SIGNAL( triggered() ), QgsGrass::instance(), SLOT( closeMapsetWarn() ) );
connect( mCloseMapsetAction, SIGNAL( triggered() ), SLOT( closeMapset() ) );

// Add actions to a GRASS plugin menu
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenMapsetAction );
Expand Down Expand Up @@ -527,6 +528,13 @@ void QgsGrassPlugin::openMapset()
QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open the mapset. %1" ).arg( err ) );
return;
}
QgsGrass::saveMapset();
}

void QgsGrassPlugin::closeMapset()
{
QgsGrass::instance()->closeMapsetWarn();
QgsGrass::saveMapset();
}

void QgsGrassPlugin::newMapset()
Expand Down Expand Up @@ -577,6 +585,7 @@ void QgsGrassPlugin::projectRead()
QgsGrass::instance()->closeMapsetWarn();

QString err = QgsGrass::openMapset( gisdbase, location, mapset );
QgsGrass::saveMapset();

if ( !err.isNull() )
{
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/grass/qgsgrassplugin.h
Expand Up @@ -97,8 +97,10 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
void openTools( void );
//! Create new mapset
void newMapset();
//! Open existing mapset
//! Open existing mapset and save it to project
void openMapset();
//! Close mapset and save it to project
void closeMapset();
//! Current mapset changed (opened/closed)
void mapsetChanged();
//! Create new vector
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/grass/qgsgrasstools.cpp
Expand Up @@ -153,7 +153,7 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface, QWidget * parent, const char
setupUi( this );
QPushButton * closeMapsetButton = new QPushButton( QgsApplication::getThemeIcon( "mActionFileExit.png" ), tr( "Close mapset" ), this );
mTabWidget->setCornerWidget( closeMapsetButton );
connect( closeMapsetButton, SIGNAL( clicked() ), QgsGrass::instance(), SLOT( closeMapsetWarn() ) );
connect( closeMapsetButton, SIGNAL( clicked() ), SLOT( closeMapset() ) );

qRegisterMetaType<QgsDetailedItemData>();

Expand Down Expand Up @@ -537,6 +537,12 @@ void QgsGrassTools::removeEmptyItems( QStandardItem *item )
}
}

void QgsGrassTools::closeMapset()
{
QgsGrass::instance()->closeMapsetWarn();
QgsGrass::saveMapset();
}

void QgsGrassTools::mapsetChanged()
{
QgsDebugMsg( "entered." );
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/grass/qgsgrasstools.h
Expand Up @@ -77,6 +77,9 @@ class QgsGrassTools: public QDockWidget, private Ui::QgsGrassToolsBase
//! Save window position
void saveWindowLocation();

//! Close mapset and save it to project
void closeMapset();

//! Current mapset changed
void mapsetChanged();

Expand Down
2 changes: 0 additions & 2 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -856,7 +856,6 @@ QString QgsGrass::openMapset( const QString& gisdbase,

mMapsetLock = lock;

saveMapset();
emit QgsGrass::instance()->mapsetChanged();
return QString::null;
}
Expand Down Expand Up @@ -919,7 +918,6 @@ QString QgsGrass::closeMapset()
}
}

saveMapset();
emit QgsGrass::instance()->mapsetChanged();
return QString::null;
}
Expand Down
2 changes: 2 additions & 0 deletions src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -626,7 +626,9 @@ void QgsGrassMapsetItem::openMapset()
if ( !error.isEmpty() )
{
QgsGrass::warning( error );
return;
}
QgsGrass::saveMapset();
}

//----------------------- QgsGrassObjectItemBase ------------------------------
Expand Down

0 comments on commit 42953e6

Please sign in to comment.