| 332 | } |
| 333 | |
| 334 | NodeModels 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 | |
| 387 | NodeModels SidepanelEditor::importFromSkills(const QString &fileName) |
| 388 | { |
nothing calls this directly
no test coverage detected