|
@@ -74,7 +74,8 @@ import grass.script as gscript
|
|
|
from grass.script import gisenv
|
|
|
from grass.grassdb.data import map_exists
|
|
|
from grass.grassdb.checks import (get_mapset_owner, is_mapset_locked,
|
|
|
- is_different_mapset_owner)
|
|
|
+ is_different_mapset_owner,
|
|
|
+ is_current_mapset_in_demolocation)
|
|
|
from grass.exceptions import CalledModuleError
|
|
|
|
|
|
|
|
@@ -328,6 +329,7 @@ class DataCatalogTree(TreeView):
|
|
|
self._restricted = True
|
|
|
|
|
|
self.showNotification = Signal('Tree.showNotification')
|
|
|
+ self.showImportDataInfo = Signal('Tree.showImportDataInfo')
|
|
|
self.parent = parent
|
|
|
self.contextMenu.connect(self.OnRightClick)
|
|
|
self.itemActivated.connect(self.OnDoubleClick)
|
|
@@ -984,7 +986,9 @@ class DataCatalogTree(TreeView):
|
|
|
|
|
|
def CreateLocation(self, grassdb_node):
|
|
|
"""
|
|
|
- Creates new location interactively and adds it to the tree.
|
|
|
+ Creates new location interactively and adds it to the tree and switch
|
|
|
+ to its new PERMANENT mapset.
|
|
|
+ If a user was in Demolocation, it shows data import infobar.
|
|
|
"""
|
|
|
grassdatabase, location, mapset = (
|
|
|
create_location_interactively(self, grassdb_node.data['name'])
|
|
@@ -995,6 +999,13 @@ class DataCatalogTree(TreeView):
|
|
|
element='location',
|
|
|
action='new')
|
|
|
|
|
|
+ # show data import infobar for first-time user with proper layout
|
|
|
+ if is_current_mapset_in_demolocation():
|
|
|
+ self.showImportDataInfo.emit()
|
|
|
+
|
|
|
+ # switch to PERMANENT mapset in newly created location
|
|
|
+ self.SwitchMapset(grassdatabase, location, mapset)
|
|
|
+
|
|
|
def OnCreateLocation(self, event):
|
|
|
"""Create new location"""
|
|
|
self.CreateLocation(self.selected_grassdb[0])
|
|
@@ -1525,14 +1536,12 @@ class DataCatalogTree(TreeView):
|
|
|
event.Veto()
|
|
|
return
|
|
|
|
|
|
- def OnSwitchMapset(self, event):
|
|
|
- """Switch to location and mapset"""
|
|
|
- genv = gisenv()
|
|
|
- grassdb = self.selected_grassdb[0].data['name']
|
|
|
- location = self.selected_location[0].data['name']
|
|
|
- mapset = self.selected_mapset[0].data['name']
|
|
|
-
|
|
|
+ def SwitchMapset(self, grassdb, location, mapset):
|
|
|
+ """
|
|
|
+ Switch to location and mapset interactively.
|
|
|
+ """
|
|
|
if can_switch_mapset_interactive(self, grassdb, location, mapset):
|
|
|
+ genv = gisenv()
|
|
|
# Switch to mapset in the same location
|
|
|
if (grassdb == genv['GISDBASE'] and location == genv['LOCATION_NAME']):
|
|
|
switch_mapset_interactively(self, self._giface, None, None, mapset)
|
|
@@ -1543,6 +1552,13 @@ class DataCatalogTree(TreeView):
|
|
|
else:
|
|
|
switch_mapset_interactively(self, self._giface, grassdb, location, mapset)
|
|
|
|
|
|
+ def OnSwitchMapset(self, event):
|
|
|
+ """Switch to location and mapset"""
|
|
|
+ grassdb = self.selected_grassdb[0].data['name']
|
|
|
+ location = self.selected_location[0].data['name']
|
|
|
+ mapset = self.selected_mapset[0].data['name']
|
|
|
+ self.SwitchMapset(grassdb, location, mapset)
|
|
|
+
|
|
|
def _updateAfterGrassdbChanged(self, action, element, grassdb, location, mapset=None,
|
|
|
map=None, newname=None):
|
|
|
"""Update tree after grassdata changed"""
|