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

Method onAddGroup

Source/GUI/StructEditor/StructEditorWidget.cpp:872–902  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

870}
871
872void 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
904void StructEditorWidget::onAddStruct()
905{

Callers

nothing calls this directly

Calls 2

isNameAvailableMethod · 0.80
addGroupMethod · 0.45

Tested by

no test coverage detected