[GRASS-SVN] r54009 - grass/trunk/gui/wxpython/lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 24 04:26:58 PST 2012


Author: annakrat
Date: 2012-11-24 04:26:57 -0800 (Sat, 24 Nov 2012)
New Revision: 54009

Modified:
   grass/trunk/gui/wxpython/lmgr/frame.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
Log:
wxGUI/layertree: selected layer as a property

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-24 12:03:01 UTC (rev 54008)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-24 12:26:57 UTC (rev 54009)
@@ -1144,7 +1144,6 @@
         for maptree, layer in selected:
             if not maptree.IsSelected(layer):
                 maptree.SelectItem(layer, select = True)
-                maptree.layer_selected = layer
                 
         busy.Destroy()
             

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2012-11-24 12:03:01 UTC (rev 54008)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2012-11-24 12:26:57 UTC (rev 54009)
@@ -122,7 +122,6 @@
         self.root = None                     # ID of layer tree root node
         self.groupnode = 0                   # index value for layers
         self.optpage = {}                    # dictionary of notebook option pages for each map layer
-        self.layer_selected = None           # ID of currently selected layer
         self.saveitem = {}                   # dictionary to preserve layer attributes for drag and drop
         self.first = True                    # indicates if a layer is just added or not
         self.flag = ''                       # flag for drag and drop hittest
@@ -243,6 +242,20 @@
         self.Bind(wx.EVT_IDLE,                  self.OnIdle)
         self.Bind(wx.EVT_MOTION,                self.OnMotion)
 
+    def GetSelectedLayer(self):
+        """!Get selected layer.
+
+        @return None if no layer selected
+        @return first layer (GenericTreeItem instance) of all selected
+        """
+        layers = self.GetSelections()
+        if len(layers) >= 1:
+            return layers[0]
+        return None
+
+    layer_selected = property(fget = GetSelectedLayer)
+
+
     def _setGradient(self, iType = None):
         """!Set gradient for items
 
@@ -971,8 +984,7 @@
         
         # select new item
         self.SelectItem(layer, select = True)
-        self.layer_selected = layer
-        
+
         # use predefined layer name if given
         if lname:
             if ltype == 'group':
@@ -1078,7 +1090,6 @@
         """
         self.lmgr.WorkspaceChanged()
         layer = event.GetItem()
-        self.layer_selected = layer
         
         self.PropertiesDialog(layer)
         
@@ -1106,7 +1117,6 @@
 
         # unselect item
         self.Unselect()
-        self.layer_selected = None
 
         try:
             if self.GetPyData(item)[0]['type'] != 'group':
@@ -1276,8 +1286,6 @@
         else:
             self._setGradient()
         
-        self.layer_selected = layer
-        
         try:
             if self.IsSelected(oldlayer):
                 self.SetItemWindowEnabled(oldlayer, True)
@@ -1338,7 +1346,6 @@
     def OnExpandNode(self, event):
         """!Expand node
         """
-        self.layer_selected = event.GetItem()
         if self.GetPyData(self.layer_selected)[0]['type'] == 'group':
             self.SetItemImage(self.layer_selected, self.folder_open)
     



More information about the grass-commit mailing list