Helper method to paste using PasteNodesCommand.
(self, data, paste_pos)
| 299 | print("Clipboard does not contain valid graph data.") |
| 300 | |
| 301 | def _paste_with_command(self, data, paste_pos): |
| 302 | """Helper method to paste using PasteNodesCommand.""" |
| 303 | if not data or not data.get('nodes'): |
| 304 | print("No nodes to paste.") |
| 305 | return |
| 306 | |
| 307 | # Convert data format to match PasteNodesCommand expectations |
| 308 | clipboard_data = self._convert_data_format(data) |
| 309 | |
| 310 | # Set paste operation flag to prevent Group.itemChange from moving nodes automatically |
| 311 | self._is_pasting = True |
| 312 | |
| 313 | try: |
| 314 | # Create and execute paste command |
| 315 | from commands.node_commands import PasteNodesCommand |
| 316 | paste_cmd = PasteNodesCommand(self, clipboard_data, paste_pos) |
| 317 | result = self.execute_command(paste_cmd) |
| 318 | |
| 319 | if not result: |
| 320 | print("Failed to paste nodes.") |
| 321 | finally: |
| 322 | # Always clear the paste flag |
| 323 | self._is_pasting = False |
| 324 | |
| 325 | def _convert_data_format(self, data): |
| 326 | """Convert deserialize format to PasteNodesCommand format.""" |
no test coverage detected