Create a group from selected nodes using the group creation dialog
(self, selected_nodes)
| 173 | super().keyPressEvent(event) |
| 174 | |
| 175 | def _create_group_from_selection(self, selected_nodes): |
| 176 | """Create a group from selected nodes using the group creation dialog""" |
| 177 | # Validate selection |
| 178 | try: |
| 179 | from core.group import validate_group_creation |
| 180 | except ImportError: |
| 181 | from src.core.group import validate_group_creation |
| 182 | |
| 183 | is_valid, error_message = validate_group_creation(selected_nodes) |
| 184 | |
| 185 | if not is_valid: |
| 186 | from PySide6.QtWidgets import QMessageBox |
| 187 | msg = QMessageBox() |
| 188 | msg.setWindowTitle("Invalid Selection") |
| 189 | msg.setText(f"Cannot create group: {error_message}") |
| 190 | msg.setIcon(QMessageBox.Warning) |
| 191 | msg.exec() |
| 192 | return |
| 193 | |
| 194 | # Show group creation dialog |
| 195 | try: |
| 196 | from ui.dialogs.group_creation_dialog import show_group_creation_dialog |
| 197 | except ImportError: |
| 198 | from src.ui.dialogs.group_creation_dialog import show_group_creation_dialog |
| 199 | |
| 200 | # Get the main window as parent for the dialog |
| 201 | main_window = None |
| 202 | views = self.views() |
| 203 | if views: |
| 204 | main_window = views[0].window() |
| 205 | |
| 206 | group_properties = show_group_creation_dialog(selected_nodes, main_window) |
| 207 | |
| 208 | if group_properties: |
| 209 | # Create and execute the group creation command |
| 210 | try: |
| 211 | from commands.create_group_command import CreateGroupCommand |
| 212 | except ImportError: |
| 213 | from src.commands.create_group_command import CreateGroupCommand |
| 214 | command = CreateGroupCommand(self, group_properties) |
| 215 | self.execute_command(command) |
| 216 | |
| 217 | def copy_selected(self): |
| 218 | """Copies selected nodes, their connections, and groups to the clipboard.""" |