Skip to content

Commit 56329d2

Browse files
author
rblazek
committed
reload browser if mapset changed
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5199 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 74cd48d commit 56329d2

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

src/plugins/grass/qgsgrassbrowser.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,7 @@ void QgsGrassBrowser::currentChanged(const QModelIndex & current, const QModelIn
537537
#endif
538538
}
539539

540+
void QgsGrassBrowser::setLocation( const QString &gisbase, const QString &location )
541+
{
542+
mModel->setLocation(gisbase, location);
543+
}

src/plugins/grass/qgsgrassbrowser.h

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public slots:
6262
// Write region
6363
void writeRegion ( struct Cell_head *window );
6464

65+
// Set Location
66+
void setLocation ( const QString &gisbase, const QString &location );
67+
6568
// Refresh model
6669
void refresh();
6770

src/plugins/grass/qgsgrassmodel.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,12 @@ QString QgsGrassModel::uri ( const QModelIndex &index ) const
913913

914914
void QgsGrassModel::setLocation( const QString &gisbase, const QString &location )
915915
{
916+
removeItems(mRoot, QStringList());
916917
mGisbase = gisbase;
917918
mLocation = location;
919+
mRoot->mGisbase = gisbase;
920+
mRoot->mLocation = location;
921+
refreshItem(mRoot);
918922
}
919923

920924
QVariant QgsGrassModel::headerData(int section,

src/plugins/grass/qgsgrassplugin.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ void QgsGrassPlugin::initGui()
239239

240240
void QgsGrassPlugin::mapsetChanged ()
241241
{
242-
if ( mTools ) mTools->closeTools();
243-
244242
if ( !QgsGrass::activeMode() ) {
245243
mOpenToolsAction->setEnabled(false);
246244
mRegionAction->setEnabled(false);
@@ -274,7 +272,6 @@ void QgsGrassPlugin::mapsetChanged ()
274272
mTools->mapsetChanged();
275273
}
276274
}
277-
278275
}
279276

280277
void QgsGrassPlugin::saveMapset()

src/plugins/grass/qgsgrasstools.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ QgsGrassTools::QgsGrassTools ( QgisApp *qgisApp, QgisIface *iface,
159159
// Add map browser
160160
// Warning: if browser is on the first page modules are
161161
// displayed over the browser
162-
QgsGrassBrowser *browser = new QgsGrassBrowser ( mIface, this );
163-
mTabWidget->addTab( browser, "Browser" );
162+
mBrowser = new QgsGrassBrowser ( mIface, this );
163+
mTabWidget->addTab( mBrowser, "Browser" );
164164

165-
connect( browser, SIGNAL(regionChanged()),
165+
connect( mBrowser, SIGNAL(regionChanged()),
166166
this, SLOT(emitRegionChanged()) );
167167
}
168168

@@ -385,7 +385,8 @@ void QgsGrassTools::mapsetChanged()
385385
+ "/" + QgsGrass::getDefaultMapset();
386386
setCaption(title);
387387

388-
// TODO: Close opened tools (tabs) ?
388+
closeTools();
389+
mBrowser->setLocation( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() );
389390
}
390391

391392
QgsGrassTools::~QgsGrassTools()

src/plugins/grass/qgsgrasstools.h

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class QDomElement;
3030
#include "qgisiface.h"
3131

3232
class QgsGrassProvider;
33+
class QgsGrassBrowser;
3334
#include <QDialog>
3435
#include <QTabBar>
3536
class QSize;
@@ -115,6 +116,9 @@ public slots:
115116
//! QGIS directory
116117
QString mAppDir;
117118

119+
//! Browser
120+
QgsGrassBrowser *mBrowser;
121+
118122
QgsGrassToolsTabWidget *mTabWidget;
119123
Q3ListView *mModulesListView;
120124
};

0 commit comments

Comments
 (0)