Initialize delete multiple command. Args: node_graph: The NodeGraph instance selected_items: List of items (nodes and connections) to delete
(self, node_graph, selected_items: List)
| 369 | """Command for deleting multiple items as a single undo unit.""" |
| 370 | |
| 371 | def __init__(self, node_graph, selected_items: List): |
| 372 | """ |
| 373 | Initialize delete multiple command. |
| 374 | |
| 375 | Args: |
| 376 | node_graph: The NodeGraph instance |
| 377 | selected_items: List of items (nodes and connections) to delete |
| 378 | """ |
| 379 | # Import here to avoid circular imports |
| 380 | from core.node import Node |
| 381 | from core.reroute_node import RerouteNode |
| 382 | from core.connection import Connection |
| 383 | from core.group import Group |
| 384 | |
| 385 | # Create individual delete commands |
| 386 | commands = [] |
| 387 | node_count = 0 |
| 388 | connection_count = 0 |
| 389 | group_count = 0 |
| 390 | |
| 391 | for item in selected_items: |
| 392 | if isinstance(item, (Node, RerouteNode)): |
| 393 | commands.append(DeleteNodeCommand(node_graph, item)) |
| 394 | node_count += 1 |
| 395 | elif isinstance(item, Connection): |
| 396 | from commands.connection_commands import DeleteConnectionCommand |
| 397 | commands.append(DeleteConnectionCommand(node_graph, item)) |
| 398 | connection_count += 1 |
| 399 | elif isinstance(item, Group): |
| 400 | from commands.delete_group_command import DeleteGroupCommand |
| 401 | commands.append(DeleteGroupCommand(node_graph, item)) |
| 402 | group_count += 1 |
| 403 | |
| 404 | # Generate description based on what's being deleted |
| 405 | description_parts = [] |
| 406 | if node_count > 0: |
| 407 | if node_count == 1: |
| 408 | # Try to get the node title for single node deletion |
| 409 | node_item = None |
| 410 | for item in selected_items: |
| 411 | if isinstance(item, (Node, RerouteNode)): |
| 412 | node_item = item |
| 413 | break |
| 414 | node_title = getattr(node_item, 'title', 'node') |
| 415 | description_parts.append(f"'{node_title}'") |
| 416 | else: |
| 417 | description_parts.append(f"{node_count} nodes") |
| 418 | |
| 419 | if group_count > 0: |
| 420 | if group_count == 1 and len(selected_items) == 1: |
| 421 | # Single group deletion |
| 422 | group_name = getattr(selected_items[0], 'name', 'group') |
| 423 | description_parts.append(f"group '{group_name}'") |
| 424 | else: |
| 425 | description_parts.append(f"{group_count} groups") |
| 426 | |
| 427 | if connection_count > 0: |
| 428 | if connection_count == 1 and len(selected_items) == 1: |
nothing calls this directly
no test coverage detected