Browse Source

wxGUI: fully-qualified names only for input/map

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48807 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 years ago
parent
commit
d09d7cb201
2 changed files with 18 additions and 8 deletions
  1. 15 7
      gui/wxpython/gui_modules/gselect.py
  2. 3 1
      gui/wxpython/gui_modules/menuform.py

+ 15 - 7
gui/wxpython/gui_modules/gselect.py

@@ -56,7 +56,8 @@ wxGdalSelect, EVT_GDALSELECT = NewEvent()
 class Select(wx.combo.ComboCtrl):
 class Select(wx.combo.ComboCtrl):
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
                  type = None, multiple = False, mapsets = None,
                  type = None, multiple = False, mapsets = None,
-                 updateOnPopup = True, onPopup = None):
+                 updateOnPopup = True, onPopup = None,
+                 fullyQualified = True):
         """!Custom control to create a ComboBox with a tree control to
         """!Custom control to create a ComboBox with a tree control to
         display and select GIS elements within acessible mapsets.
         display and select GIS elements within acessible mapsets.
         Elements can be selected with mouse. Can allow multiple
         Elements can be selected with mouse. Can allow multiple
@@ -68,6 +69,7 @@ class Select(wx.combo.ComboCtrl):
         @param mapsets force list of mapsets (otherwise search path)
         @param mapsets force list of mapsets (otherwise search path)
         @param updateOnPopup True for updating list of elements on popup
         @param updateOnPopup True for updating list of elements on popup
         @param onPopup function to be called on Popup
         @param onPopup function to be called on Popup
+        @param fullyQualified True to provide fully qualified names (map@mapset)
         """
         """
         wx.combo.ComboCtrl.__init__(self, parent=parent, id=id, size=size)
         wx.combo.ComboCtrl.__init__(self, parent=parent, id=id, size=size)
         self.GetChildren()[0].SetName("Select")
         self.GetChildren()[0].SetName("Select")
@@ -79,7 +81,8 @@ class Select(wx.combo.ComboCtrl):
         if type:
         if type:
             self.tcp.SetData(type = type, mapsets = mapsets,
             self.tcp.SetData(type = type, mapsets = mapsets,
                              multiple = multiple,
                              multiple = multiple,
-                             updateOnPopup = updateOnPopup, onPopup = onPopup)
+                             updateOnPopup = updateOnPopup, onPopup = onPopup,
+                             fullyQualified = fullyQualified)
         self.GetChildren()[0].Bind(wx.EVT_KEY_UP, self.OnKeyUp)
         self.GetChildren()[0].Bind(wx.EVT_KEY_UP, self.OnKeyUp)
      
      
     def OnKeyUp(self, event):
     def OnKeyUp(self, event):
@@ -150,6 +153,7 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
         self.mapsets = None
         self.mapsets = None
         self.updateOnPopup = True
         self.updateOnPopup = True
         self.onPopup = None
         self.onPopup = None
+        self.fullyQualified = True
         
         
         self.SetFilter(None)
         self.SetFilter(None)
         
         
@@ -471,8 +475,9 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
                 self.value = [] 
                 self.value = [] 
             else:
             else:
                 mapsetItem = self.seltree.GetItemParent(item)
                 mapsetItem = self.seltree.GetItemParent(item)
-                fullName = self.seltree.GetItemText(item) + '@' + \
-                    self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
+                fullName = self.seltree.GetItemText(item)
+                if self.fullyQualified:
+                    fullName += '@' + self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
                 
                 
                 if self.multiple is True:
                 if self.multiple is True:
                     # text item should be unique
                     # text item should be unique
@@ -502,8 +507,9 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
                 self.value = [] # cannot select mapset item
                 self.value = [] # cannot select mapset item
             else:
             else:
                 mapsetItem = self.seltree.GetItemParent(item)
                 mapsetItem = self.seltree.GetItemParent(item)
-                fullName = self.seltree.GetItemText(item) + '@' + \
-                    self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
+                fullName = self.seltree.GetItemText(item)
+                if self.fullyQualified:
+                    fullName += '@' + self.seltree.GetItemText(mapsetItem).split(':', -1)[1].strip()
                 
                 
                 if self.multiple is True:
                 if self.multiple is True:
                     # text item should be unique
                     # text item should be unique
@@ -527,7 +533,9 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
             self.updateOnPopup = kargs['updateOnPopup']
             self.updateOnPopup = kargs['updateOnPopup']
         if 'onPopup' in kargs:
         if 'onPopup' in kargs:
             self.onPopup = kargs['onPopup']
             self.onPopup = kargs['onPopup']
-
+        if 'fullyQualified' in kargs:
+            self.fullyQualified = kargs['fullyQualified']
+        
     def GetType(self):
     def GetType(self):
         """!Get element type
         """!Get element type
         """
         """

+ 3 - 1
gui/wxpython/gui_modules/menuform.py

@@ -1143,7 +1143,9 @@ class cmdPanel(wx.Panel):
                         selection = gselect.Select(parent = which_panel, id = wx.ID_ANY,
                         selection = gselect.Select(parent = which_panel, id = wx.ID_ANY,
                                                    size = globalvar.DIALOG_GSELECT_SIZE,
                                                    size = globalvar.DIALOG_GSELECT_SIZE,
                                                    type = p.get('element', ''),
                                                    type = p.get('element', ''),
-                                                   multiple = multiple, mapsets = mapsets)
+                                                   multiple = multiple, mapsets = mapsets,
+                                                   fullyQualified = p.get('age', 'old') == 'old')
+                        
                         value = self._getValue(p)
                         value = self._getValue(p)
                         if value:
                         if value:
                             selection.SetValue(value)
                             selection.SetValue(value)