MCPcopy Create free account
hub / github.com/MyGUI/mygui / deleteItemFromProject

Method deleteItemFromProject

Tools/LayoutEditor/ProjectControl.cpp:418–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416 }
417
418 bool ProjectControl::deleteItemFromProject(size_t _index)
419 {
420 bool deleted = false;
421
422 MyGUI::UString fileName = common::concatenatePath(mProjectPath, mProjectName);
423
424 MyGUI::xml::Document doc;
425 if (!doc.open(fileName))
426 {
427 MYGUI_LOGGING(LogSection, Error, doc.getLastError());
428 return false;
429 }
430
431 MyGUI::xml::ElementPtr root = doc.getRoot();
432 if ((nullptr == root) || (root->getName() != "MyGUI"))
433 {
434 MYGUI_LOGGING(LogSection, Error, "'" << fileName << "', tag 'MyGUI' not found");
435 return false;
436 }
437
438 if (root->findAttribute("type") == "Resource")
439 {
440 // берем детей и крутимся
441 MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
442 while (element.next("Resource"))
443 {
444 if (element->findAttribute("type") == "ResourceLayout")
445 {
446 if (_index == 0)
447 {
448 root->removeChild(element.current());
449 deleted = true;
450 break;
451 }
452
453 _index--;
454 }
455 }
456 }
457
458 doc.save(fileName);
459
460 return deleted;
461 }
462
463 bool ProjectControl::renameItemInProject(size_t _index, const MyGUI::UString& _name)
464 {

Callers

nothing calls this directly

Calls 10

concatenatePathFunction · 0.85
getLastErrorMethod · 0.80
findAttributeMethod · 0.80
getElementEnumeratorMethod · 0.80
openMethod · 0.45
getRootMethod · 0.45
nextMethod · 0.45
removeChildMethod · 0.45
currentMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected