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

Method renameItemInProject

Tools/LayoutEditor/ProjectControl.cpp:463–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 }
462
463 bool ProjectControl::renameItemInProject(size_t _index, const MyGUI::UString& _name)
464 {
465 bool renamed = false;
466
467 MyGUI::UString fileName = common::concatenatePath(mProjectPath, mProjectName);
468
469 MyGUI::xml::Document doc;
470 if (!doc.open(fileName))
471 {
472 MYGUI_LOGGING(LogSection, Error, doc.getLastError());
473 return false;
474 }
475
476 MyGUI::xml::ElementPtr root = doc.getRoot();
477 if ((nullptr == root) || (root->getName() != "MyGUI"))
478 {
479 MYGUI_LOGGING(LogSection, Error, "'" << fileName << "', tag 'MyGUI' not found");
480 return false;
481 }
482
483 if (root->findAttribute("type") == "Resource")
484 {
485 // берем детей и крутимся
486 MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
487 while (element.next("Resource"))
488 {
489 if (element->findAttribute("type") == "ResourceLayout")
490 {
491 if (_index == 0)
492 {
493 element->setAttribute("name", _name);
494 renamed = true;
495 break;
496 }
497
498 _index--;
499 }
500 }
501 }
502
503 doc.save(fileName);
504
505 return renamed;
506 }
507
508 void ProjectControl::notifyMessageBoxResultDelete(MyGUI::Message* _sender, MyGUI::MessageBoxStyle _result)
509 {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected