| 278 | |
| 279 | |
| 280 | void Template::saveTemplateConfiguration(QXmlStreamWriter& xml, bool open, const QDir* map_dir) const |
| 281 | { |
| 282 | xml.writeStartElement(QString::fromLatin1("template")); |
| 283 | xml.writeAttribute(QString::fromLatin1("type"), QString::fromUtf8(getTemplateType())); |
| 284 | xml.writeAttribute(QString::fromLatin1("open"), QString::fromLatin1(open ? "true" : "false")); |
| 285 | xml.writeAttribute(QString::fromLatin1("name"), getTemplateFilename()); |
| 286 | auto primary_path = getTemplatePath(); |
| 287 | auto relative_path = getTemplateRelativePath(map_dir); |
| 288 | if (suppressAbsolutePaths && QFileInfo(primary_path).isAbsolute()) |
| 289 | primary_path = relative_path; |
| 290 | xml.writeAttribute(QString::fromLatin1("path"), primary_path); |
| 291 | xml.writeAttribute(QString::fromLatin1("relpath"), relative_path); |
| 292 | |
| 293 | if (template_group) |
| 294 | { |
| 295 | xml.writeAttribute(QString::fromLatin1("group"), QString::number(template_group)); |
| 296 | } |
| 297 | |
| 298 | if (is_georeferenced) |
| 299 | { |
| 300 | xml.writeAttribute(QString::fromLatin1("georef"), QString::fromLatin1("true")); |
| 301 | } |
| 302 | else |
| 303 | { |
| 304 | ScopedOffsetReversal no_offset{*const_cast<Template*>(this)}; |
| 305 | |
| 306 | xml.writeStartElement(QString::fromLatin1("transformations")); |
| 307 | if (adjusted) |
| 308 | xml.writeAttribute(QString::fromLatin1("adjusted"), QString::fromLatin1("true")); |
| 309 | if (adjustment_dirty) |
| 310 | xml.writeAttribute(QString::fromLatin1("adjustment_dirty"), QString::fromLatin1("true")); |
| 311 | int num_passpoints = (int)passpoints.size(); |
| 312 | xml.writeAttribute(QString::fromLatin1("passpoints"), QString::number(num_passpoints)); |
| 313 | |
| 314 | transform.save(xml, QString::fromLatin1("active")); |
| 315 | other_transform.save(xml, QString::fromLatin1("other")); |
| 316 | |
| 317 | for (int i = 0; i < num_passpoints; ++i) |
| 318 | passpoints[i].save(xml); |
| 319 | |
| 320 | map_to_template.save(xml, QString::fromLatin1("map_to_template")); |
| 321 | template_to_map.save(xml, QString::fromLatin1("template_to_map")); |
| 322 | template_to_map_other.save(xml, QString::fromLatin1("template_to_map_other")); |
| 323 | |
| 324 | xml.writeEndElement(/*transformations*/); |
| 325 | } |
| 326 | |
| 327 | saveTypeSpecificTemplateConfiguration(xml); |
| 328 | |
| 329 | xml.writeEndElement(/*template*/); |
| 330 | } |
| 331 | |
| 332 | std::unique_ptr<Template> Template::loadTemplateConfiguration(QXmlStreamReader& xml, Map& map, bool& open) |
| 333 | { |
no test coverage detected