Load from XML
| 438 | |
| 439 | //! Load from XML |
| 440 | bool RunChart::load(XmlStreamReader* reader, bool preview) { |
| 441 | Q_D(RunChart); |
| 442 | |
| 443 | if (!readBasicAttributes(reader)) |
| 444 | return false; |
| 445 | |
| 446 | QXmlStreamAttributes attribs; |
| 447 | QString str; |
| 448 | |
| 449 | while (!reader->atEnd()) { |
| 450 | reader->readNext(); |
| 451 | if (reader->isEndElement() && reader->name() == QLatin1String("RunChart")) |
| 452 | break; |
| 453 | |
| 454 | if (!reader->isStartElement()) |
| 455 | continue; |
| 456 | |
| 457 | if (reader->name() == QLatin1String("comment")) { |
| 458 | if (!readCommentElement(reader)) |
| 459 | return false; |
| 460 | } else if (!preview && reader->name() == QLatin1String("general")) { |
| 461 | attribs = reader->attributes(); |
| 462 | READ_COLUMN(dataColumn); |
| 463 | READ_COLUMN(xColumn); |
| 464 | READ_COLUMN(xCenterColumn); |
| 465 | READ_COLUMN(yCenterColumn); |
| 466 | READ_INT_VALUE("centerMetric", centerMetric, RunChart::CenterMetric); |
| 467 | |
| 468 | str = attribs.value(QStringLiteral("visible")).toString(); |
| 469 | if (str.isEmpty()) |
| 470 | reader->raiseMissingAttributeWarning(QStringLiteral("visible")); |
| 471 | else |
| 472 | d->setVisible(str.toInt()); |
| 473 | } else if (reader->name() == QLatin1String("column")) { |
| 474 | attribs = reader->attributes(); |
| 475 | bool rc = false; |
| 476 | const auto& name = attribs.value(QStringLiteral("name")); |
| 477 | if (name == QLatin1String("x")) |
| 478 | rc = d->xColumn->load(reader, preview); |
| 479 | else if (name == QLatin1String("xCenter")) |
| 480 | rc = d->xCenterColumn->load(reader, preview); |
| 481 | else if (name == QLatin1String("yCenter")) |
| 482 | rc = d->yCenterColumn->load(reader, preview); |
| 483 | |
| 484 | if (!rc) |
| 485 | return false; |
| 486 | } else if (reader->name() == QLatin1String("xyCurve")) { |
| 487 | attribs = reader->attributes(); |
| 488 | bool rc = false; |
| 489 | if (attribs.value(QStringLiteral("name")) == QLatin1String("data")) |
| 490 | rc = d->dataCurve->load(reader, preview); |
| 491 | else if (attribs.value(QStringLiteral("name")) == QLatin1String("center")) |
| 492 | rc = d->centerCurve->load(reader, preview); |
| 493 | |
| 494 | if (!rc) |
| 495 | return false; |
| 496 | } else { // unknown element |
| 497 | reader->raiseUnknownElementWarning(); |
nothing calls this directly
no test coverage detected