Kaynağa Gözat

wxGUI/layertree: fix layer selection (results in wrong layer order when loading workspace)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56371 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 yıl önce
ebeveyn
işleme
05c3b7293c
1 değiştirilmiş dosya ile 10 ekleme ve 9 silme
  1. 10 9
      gui/wxpython/lmgr/layertree.py

+ 10 - 9
gui/wxpython/lmgr/layertree.py

@@ -848,9 +848,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         
         self.first = True
         
+        selectedLayer = self.GetSelectedLayer()
         # deselect active item
-        if self.layer_selected:
-            self.SelectItem(self.layer_selected, select = False)
+        if selectedLayer:
+            self.SelectItem(selectedLayer, select=False)
         
         Debug.msg (3, "LayerTree().AddLayer(): ltype=%s" % (ltype))
         
@@ -870,11 +871,11 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             ctrl.SetToolTipString(_("Click to edit layer settings"))
             self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenu, ctrl)
         # add layer to the layer tree
-        if self.layer_selected and self.layer_selected != self.GetRootItem():
-            if self.GetLayerInfo(self.layer_selected, key = 'type') == 'group' \
-                and self.IsExpanded(self.layer_selected):
+        if selectedLayer and selectedLayer != self.GetRootItem():
+            if self.GetLayerInfo(selectedLayer, key = 'type') == 'group' \
+                and self.IsExpanded(selectedLayer):
                 # add to group (first child of self.layer_selected) if group expanded
-                layer = self.PrependItem(parent = self.layer_selected,
+                layer = self.PrependItem(parent = selectedLayer,
                                          text = '', ct_type = 1, wnd = ctrl)
             else:
                 # prepend to individual layer or non-expanded group
@@ -891,13 +892,13 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                                             text = '', ct_type = 1, wnd = ctrl)
                 elif lgroup is None:
                     # -> previous sibling of selected layer
-                    parent = self.GetItemParent(self.layer_selected)
+                    parent = self.GetItemParent(selectedLayer)
                     layer = self.InsertItem(parentId = parent,
-                                            input = self.GetPrevSibling(self.layer_selected),
+                                            input = self.GetPrevSibling(selectedLayer),
                                             text = '', ct_type = 1, wnd = ctrl)
         else: # add first layer to the layer tree (first child of root)
             layer = self.PrependItem(parent = self.root, text = '', ct_type = 1, wnd = ctrl)
-        
+
         # layer is initially unchecked as inactive (beside 'command')
         # use predefined value if given
         if lchecked is not None: