| 902 | } |
| 903 | |
| 904 | void StructEditorWidget::onAddStruct() |
| 905 | { |
| 906 | const QModelIndexList selectedIndexes{m_structSelectView->selectionModel()->selectedIndexes()}; |
| 907 | const QModelIndex lastIndex = selectedIndexes.empty() ? QModelIndex{} : selectedIndexes.back(); |
| 908 | const StructTreeNode* parentNode = selectedIndexes.empty() ? |
| 909 | m_structRootNode : |
| 910 | static_cast<StructTreeNode*>(lastIndex.internalPointer()); |
| 911 | |
| 912 | bool ok = false; |
| 913 | QString text; |
| 914 | while (true) |
| 915 | { |
| 916 | text = QInputDialog::getText(this, "Add a struct", "Enter the struct name:", QLineEdit::Normal, |
| 917 | "", &ok); |
| 918 | |
| 919 | if (!ok || text.isEmpty()) |
| 920 | return; |
| 921 | |
| 922 | if (parentNode->isNameAvailable(text)) |
| 923 | break; |
| 924 | |
| 925 | QString msg = "This struct name is in use: " + text + ".\nPlease enter a different name."; |
| 926 | QMessageBox::critical(this, "Error - duplicate struct name", msg); |
| 927 | } |
| 928 | |
| 929 | StructTreeNode* addedNode = m_structSelectModel->addStruct(text, lastIndex); |
| 930 | m_unsavedChanges = true; |
| 931 | |
| 932 | emit structAddedRemoved(addedNode->getNameSpace(), addedNode->getStructDef()); |
| 933 | |
| 934 | onEditStruct(addedNode); |
| 935 | } |
| 936 | |
| 937 | void StructEditorWidget::onDuplicateStruct() |
| 938 | { |
nothing calls this directly
no test coverage detected