Bug on Copy/Cut/Paste comments fixed
authorlbessard
Thu, 28 Feb 2008 14:11:16 +0100
changeset 178 a9035374eb05
parent 177 a3f6670949ba
child 179 32f269883027
Bug on Copy/Cut/Paste comments fixed
Viewer.py
--- a/Viewer.py	Wed Feb 27 11:30:43 2008 +0100
+++ b/Viewer.py	Thu Feb 28 14:11:16 2008 +0100
@@ -2202,7 +2202,7 @@
 #-------------------------------------------------------------------------------
     
     def Cut(self):
-        if self.IsBlock(self.SelectedElement):
+        if self.IsBlock(self.SelectedElement) or self.IsComment(self.SelectedElement):
             self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self))
             rect = self.SelectedElement.GetRedrawRect(1, 1)
             self.SelectedElement.Delete()
@@ -2212,7 +2212,7 @@
             self.RefreshRect(self.GetScrolledRect(rect), False)
         
     def Copy(self):
-        if self.IsBlock(self.SelectedElement):
+        if self.IsBlock(self.SelectedElement) or self.IsComment(self.SelectedElement):
             self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self))
             
     def Paste(self):
@@ -2253,43 +2253,45 @@
         else:
             name = None
             block = element.Clone(self, id, pos=pos)
-        self.AddBlock(block)
         if isinstance(block, Comment):
+            self.AddComment(block)
             self.Controler.AddEditedElementComment(self.TagName, id)
             self.RefreshCommentModel(block)
-        elif isinstance(block, FBD_Block):
-            self.Controler.AddEditedElementBlock(self.TagName, id, block.GetType(), name)
-            self.RefreshBlockModel(block)
-        elif isinstance(block, FBD_Variable):
-            self.Controler.AddEditedElementVariable(self.TagName, id, block.GetType())
-            self.RefreshVariableModel(block)
-        elif isinstance(block, FBD_Connector):
-            self.Controler.AddEditedElementConnection(self.TagName, id, block.GetType())
-            self.RefreshConnectionModel(block)
-        elif isinstance(block, LD_Contact):
-            self.Controler.AddEditedElementContact(self.TagName, id)
-            self.RefreshContactModel(block)
-        elif isinstance(block, LD_Coil):
-            self.Controler.AddEditedElementCoil(self.TagName, id)
-            self.RefreshCoilModel(block)
-        elif isinstance(block, LD_PowerRail):
-            self.Controler.AddEditedElementPowerRail(self.TagName, id, block.GetType())
-            self.RefreshPowerRailModel(block)
-        elif isinstance(block, SFC_Step):
-            self.Controler.AddEditedElementStep(self.TagName, id)
-            self.RefreshStepModel(block)    
-        elif isinstance(block, SFC_Transition):
-            self.Controler.AddEditedElementTransition(self.TagName, id)
-            self.RefreshTransitionModel(block)       
-        elif isinstance(block, SFC_Divergence):
-            self.Controler.AddEditedElementDivergence(self.TagName, id, block.GetType())
-            self.RefreshActionDivergenceModel(block)
-        elif isinstance(block, SFC_Jump):
-            self.Controler.AddEditedElementJump(self.TagName, id)
-            self.RefreshJumpModel(block)       
-        elif isinstance(block, SFC_ActionBlock):
-            self.Controler.AddEditedElementActionBlock(self.TagName, id)
-            self.RefreshActionBlockModel(block)
+        else:
+            self.AddBlock(block)
+            if isinstance(block, FBD_Block):
+                self.Controler.AddEditedElementBlock(self.TagName, id, block.GetType(), name)
+                self.RefreshBlockModel(block)
+            elif isinstance(block, FBD_Variable):
+                self.Controler.AddEditedElementVariable(self.TagName, id, block.GetType())
+                self.RefreshVariableModel(block)
+            elif isinstance(block, FBD_Connector):
+                self.Controler.AddEditedElementConnection(self.TagName, id, block.GetType())
+                self.RefreshConnectionModel(block)
+            elif isinstance(block, LD_Contact):
+                self.Controler.AddEditedElementContact(self.TagName, id)
+                self.RefreshContactModel(block)
+            elif isinstance(block, LD_Coil):
+                self.Controler.AddEditedElementCoil(self.TagName, id)
+                self.RefreshCoilModel(block)
+            elif isinstance(block, LD_PowerRail):
+                self.Controler.AddEditedElementPowerRail(self.TagName, id, block.GetType())
+                self.RefreshPowerRailModel(block)
+            elif isinstance(block, SFC_Step):
+                self.Controler.AddEditedElementStep(self.TagName, id)
+                self.RefreshStepModel(block)    
+            elif isinstance(block, SFC_Transition):
+                self.Controler.AddEditedElementTransition(self.TagName, id)
+                self.RefreshTransitionModel(block)       
+            elif isinstance(block, SFC_Divergence):
+                self.Controler.AddEditedElementDivergence(self.TagName, id, block.GetType())
+                self.RefreshActionDivergenceModel(block)
+            elif isinstance(block, SFC_Jump):
+                self.Controler.AddEditedElementJump(self.TagName, id)
+                self.RefreshJumpModel(block)       
+            elif isinstance(block, SFC_ActionBlock):
+                self.Controler.AddEditedElementActionBlock(self.TagName, id)
+                self.RefreshActionBlockModel(block)
         return block