Переглянути джерело

wxGUI/datacatalog: select current location and expand it when loading tree

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61150 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 роки тому
батько
коміт
d23efe1a75
1 змінених файлів з 13 додано та 1 видалено
  1. 13 1
      gui/wxpython/lmgr/datacatalog.py

+ 13 - 1
gui/wxpython/lmgr/datacatalog.py

@@ -75,6 +75,7 @@ class DataCatalog(wx.Panel):
 
     def LoadItemsDone(self):
         self._loaded = True
+        self.tree.ExpandCurrent()
 
 class LocationMapTree(wx.TreeCtrl):
     def __init__(self, parent):
@@ -257,6 +258,17 @@ class LocationMapTree(wx.TreeCtrl):
             stringm = 'MAPSET='+mapset
             RunCommand('g.gisenv', set=stringm)
 
+    def ExpandCurrent(self):
+        """Expand current location"""
+        location = grass.gisenv()['LOCATION_NAME']
+        item = self.getItemByName(location, self.root)
+        if item is not None:
+            self.SelectItem(item)
+            self.ExpandAllChildren(item)
+            self.EnsureVisible(item)
+        else:
+            Debug.msg(1, "Location <%s> not found" % location)
+
 class DataCatalogTree(LocationMapTree):
     def __init__(self, parent):
         """Data Catalog Tree constructor."""
@@ -471,7 +483,7 @@ class DataCatalogTree(LocationMapTree):
         res = dlg.ShowModal()
         dlg.Destroy()
         return res
-    
+
     def _popupMenuLayer(self):
         """Create popup menu for layers"""
         menu = wx.Menu()