| 870 | } |
| 871 | |
| 872 | void StructEditorWidget::onAddGroup() |
| 873 | { |
| 874 | const QModelIndexList selectedIndexes{m_structSelectView->selectionModel()->selectedIndexes()}; |
| 875 | const QModelIndex lastIndex = selectedIndexes.empty() ? QModelIndex{} : selectedIndexes.back(); |
| 876 | const StructTreeNode* parentNode = selectedIndexes.empty() ? |
| 877 | m_structRootNode : |
| 878 | static_cast<StructTreeNode*>(lastIndex.internalPointer()); |
| 879 | |
| 880 | bool ok = false; |
| 881 | QString textIn; |
| 882 | while (true) |
| 883 | { |
| 884 | textIn = QInputDialog::getText(this, "Add a struct group", |
| 885 | "Enter the group name:", QLineEdit::Normal, "", &ok); |
| 886 | |
| 887 | if (!ok || textIn.isEmpty()) |
| 888 | return; |
| 889 | |
| 890 | if (parentNode->isNameAvailable(textIn)) |
| 891 | break; |
| 892 | |
| 893 | QString msg = "Cannot use this name for a group. It is already in use:\n" + textIn + |
| 894 | "\n\nPlease enter a different name."; |
| 895 | QMessageBox::critical(this, "Error - duplicate name", msg); |
| 896 | } |
| 897 | |
| 898 | // May want to enclose the selected indices in a new node... In this case, we would need to emit |
| 899 | // name changes for any struct that was moved... |
| 900 | m_structSelectModel->addGroup(textIn, lastIndex); |
| 901 | m_unsavedChanges = true; |
| 902 | } |
| 903 | |
| 904 | void StructEditorWidget::onAddStruct() |
| 905 | { |
nothing calls this directly
no test coverage detected