| 330 | } |
| 331 | |
| 332 | std::unique_ptr<Template> Template::loadTemplateConfiguration(QXmlStreamReader& xml, Map& map, bool& open) |
| 333 | { |
| 334 | Q_ASSERT(xml.name() == QLatin1String("template")); |
| 335 | |
| 336 | QXmlStreamAttributes attributes = xml.attributes(); |
| 337 | if (attributes.hasAttribute(QLatin1String("open"))) |
| 338 | open = (attributes.value(QLatin1String("open")) == QLatin1String("true")); |
| 339 | |
| 340 | auto const type = attributes.value(QLatin1String("type")); |
| 341 | QString path = attributes.value(QLatin1String("path")).toString(); |
| 342 | auto temp = templateForType(type, path, &map); |
| 343 | if (!temp && type.length() == 0) |
| 344 | temp = templateForPath(path, &map); |
| 345 | if (!temp) |
| 346 | temp = std::make_unique<TemplatePlaceholder>(type.toUtf8(), path, &map); |
| 347 | |
| 348 | temp->setTemplateRelativePath(attributes.value(QLatin1String("relpath")).toString()); |
| 349 | if (attributes.hasAttribute(QLatin1String("name"))) |
| 350 | temp->template_file = attributes.value(QLatin1String("name")).toString(); |
| 351 | temp->is_georeferenced = (attributes.value(QLatin1String("georef")) == QLatin1String("true")); |
| 352 | if (attributes.hasAttribute(QLatin1String("group"))) |
| 353 | temp->template_group = attributes.value(QLatin1String("group")).toInt(); |
| 354 | |
| 355 | while (xml.readNextStartElement()) |
| 356 | { |
| 357 | if (!temp->is_georeferenced && xml.name() == QLatin1String("transformations")) |
| 358 | { |
| 359 | temp->adjusted = (xml.attributes().value(QLatin1String("adjusted")) == QLatin1String("true")); |
| 360 | temp->adjustment_dirty = (xml.attributes().value(QLatin1String("adjustment_dirty")) == QLatin1String("true")); |
| 361 | int num_passpoints = xml.attributes().value(QLatin1String("passpoints")).toInt(); |
| 362 | Q_ASSERT(temp->passpoints.size() == 0); |
| 363 | temp->passpoints.reserve(qMin(num_passpoints, 10)); // 10 is not a limit |
| 364 | |
| 365 | while (xml.readNextStartElement()) |
| 366 | { |
| 367 | QStringRef role = xml.attributes().value(QLatin1String("role")); |
| 368 | if (xml.name() == QLatin1String("transformation")) |
| 369 | { |
| 370 | if (role == QLatin1String("active")) |
| 371 | temp->transform.load(xml); |
| 372 | else if (xml.attributes().value(QLatin1String("role")) == QLatin1String("other")) |
| 373 | temp->other_transform.load(xml); |
| 374 | else |
| 375 | { |
| 376 | qDebug("%s", xml.qualifiedName().toLocal8Bit().constData()); |
| 377 | xml.skipCurrentElement(); // unsupported |
| 378 | } |
| 379 | } |
| 380 | else if (xml.name() == QLatin1String("passpoint")) |
| 381 | { |
| 382 | temp->passpoints.push_back(PassPoint::load(xml)); |
| 383 | } |
| 384 | else if (xml.name() == QLatin1String("matrix")) |
| 385 | { |
| 386 | if (role == QLatin1String("map_to_template")) |
| 387 | temp->map_to_template.load(xml); |
| 388 | else if (role == QLatin1String("template_to_map")) |
| 389 | temp->template_to_map.load(xml); |
nothing calls this directly
no test coverage detected