瀏覽代碼

wxGUI/modeler: fix moving item in the loop

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58606 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 年之前
父節點
當前提交
d887a4ea6e
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. 14 2
      gui/wxpython/gmodeler/model.py

+ 14 - 2
gui/wxpython/gmodeler/model.py

@@ -840,9 +840,15 @@ class ModelObject(object):
         """!Get id"""
         return self.id
 
-    def SetId(self, id):
+    def SetId(self, newId):
         """!Set id"""
-        self.id = id
+        if self.inBlock:
+            for loop in self.inBlock:
+                # update block item
+                loop.UpdateItem(self.id, newId)
+        
+        self.id = newId
+
 
     def AddRelation(self, rel):
         """!Record new relation
@@ -1546,6 +1552,12 @@ class ModelLoop(ModelItem, ogl.RectangleShape):
         """!Set items (id)"""
         self.itemIds = items
 
+    def UpdateItem(self, oldId, newId):
+        """!Update item in the list"""
+        idx = self.itemIds.index(oldId)
+        if idx != -1:
+            self.itemIds[idx] = newId
+        
     def OnDraw(self, dc):
         """!Draw loop in canvas"""
         self._setBrush()