MCPcopy Create free account
hub / github.com/aldelaro5/dolphin-memory-engine / onAddStruct

Method onAddStruct

Source/GUI/StructEditor/StructEditorWidget.cpp:904–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902}
903
904void 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
937void StructEditorWidget::onDuplicateStruct()
938{

Callers

nothing calls this directly

Calls 4

isNameAvailableMethod · 0.80
addStructMethod · 0.80
getNameSpaceMethod · 0.80
getStructDefMethod · 0.80

Tested by

no test coverage detected