Browse Source

wxGUI/gmodeler: fix moving item down, re-select origninaly selected items

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58186 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
e43ee21802
1 changed files with 9 additions and 1 deletions
  1. 9 1
      gui/wxpython/gmodeler/dialogs.py

+ 9 - 1
gui/wxpython/gmodeler/dialogs.py

@@ -921,13 +921,21 @@ class ItemListCtrl(ModelListCtrl):
         modelActions = model.GetItems(objType=ModelAction)
         modelActions = model.GetItems(objType=ModelAction)
         idxList = dict()
         idxList = dict()
         for i in items:
         for i in items:
-            idxList[model.GetItemIndex(modelActions[i])] =  model.GetItemIndex(modelActions[i-1])
+            if up:
+                idx = i-1
+            else:
+                idx = i+1
+            idxList[model.GetItemIndex(modelActions[i])] = model.GetItemIndex(modelActions[idx])
         
         
         # reorganize model items
         # reorganize model items
         model.ReorderItems(idxList)
         model.ReorderItems(idxList)
         model.Normalize()
         model.Normalize()
         self.Populate(model.GetItems(objType=ModelAction))
         self.Populate(model.GetItems(objType=ModelAction))
         
         
+        # re-selected originaly selected item
+        for item in idxList.itervalues():
+            self.SetItemState(item,  wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED | wx.LIST_STATE_FOCUSED)
+
 class ItemCheckListCtrl(ItemListCtrl, listmix.CheckListCtrlMixin):
 class ItemCheckListCtrl(ItemListCtrl, listmix.CheckListCtrlMixin):
     def __init__(self, parent, shape, columns, frame, **kwargs):
     def __init__(self, parent, shape, columns, frame, **kwargs):
         self.parent = parent
         self.parent = parent