| 597 | } |
| 598 | |
| 599 | void ProjectEditor::execRenameSheetDialog(int index) noexcept { |
| 600 | Schematic* schematic = mProject->getSchematicByIndex(index); |
| 601 | if (!schematic) return; |
| 602 | |
| 603 | bool ok = false; |
| 604 | const QString name = QInputDialog::getText( |
| 605 | qApp->activeWindow(), tr("Rename sheet"), tr("Choose new name:"), |
| 606 | QLineEdit::Normal, *schematic->getName(), &ok); |
| 607 | if (!ok) return; |
| 608 | |
| 609 | emit abortBlockingToolsInOtherEditors(nullptr); // Release undo stack. |
| 610 | |
| 611 | try { |
| 612 | std::unique_ptr<CmdSchematicEdit> cmd = |
| 613 | std::make_unique<CmdSchematicEdit>(*schematic); |
| 614 | cmd->setName(ElementName(cleanElementName(name))); // can throw |
| 615 | mUndoStack->execCmd(cmd.release()); |
| 616 | } catch (const Exception& e) { |
| 617 | QMessageBox::critical(qApp->activeWindow(), tr("Error"), e.getMsg()); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | void ProjectEditor::execDeleteSheetDialog(int index) noexcept { |
| 622 | Schematic* schematic = mProject->getSchematicByIndex(index); |
no test coverage detected