MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / importFromXML

Method importFromXML

bt_editor/sidepanel_editor.cpp:334–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334NodeModels SidepanelEditor::importFromXML(QFile* file)
335{
336 QDomDocument doc;
337
338
339 if (!file->open(QIODevice::ReadOnly))
340 {
341 QMessageBox::warning(this,"Error loading TreeNodeModel form file",
342 "The XML was not correctly loaded");
343 return {};
344 }
345
346 QString errorMsg;
347 int errorLine;
348 if( ! doc.setContent(file, &errorMsg, &errorLine ) )
349 {
350 auto error = tr("Error parsing XML (line %1): %2").arg(errorLine).arg(errorMsg);
351 QMessageBox::warning(this,"Error loading TreeNodeModel form file", error);
352 file->close();
353 return {};
354 }
355 file->close();
356
357 NodeModels custom_models;
358
359 QDomElement xml_root = doc.documentElement();
360 if ( xml_root.isNull() || xml_root.tagName() != "root")
361 {
362 QMessageBox::warning(this,"Error loading TreeNodeModel form file",
363 "The XML must have a root node called <root>");
364 return custom_models;
365 }
366
367 auto manifest_root = xml_root.firstChildElement("TreeNodesModel");
368
369 if ( manifest_root.isNull() )
370 {
371 QMessageBox::warning(this,"Error loading TreeNodeModel form file",
372 "Expecting <TreeNodesModel> under <root>");
373 return custom_models;
374 }
375
376 for( QDomElement model_element = manifest_root.firstChildElement();
377 !model_element.isNull();
378 model_element = model_element.nextSiblingElement() )
379 {
380 auto model = buildTreeNodeModelFromXML(model_element);
381 custom_models.insert( { model.registration_ID, model } );
382 }
383
384 return custom_models;
385}
386
387NodeModels SidepanelEditor::importFromSkills(const QString &fileName)
388{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected