MCPcopy Create free account
hub / github.com/KDE/labplot / load

Method load

src/backend/worksheet/plots/cartesian/ReferenceLine.cpp:354–411  ·  view source on GitHub ↗

Load from XML

Source from the content-addressed store, hash-verified

352
353//! Load from XML
354bool ReferenceLine::load(XmlStreamReader* reader, bool preview) {
355 Q_D(ReferenceLine);
356
357 if (!readBasicAttributes(reader))
358 return false;
359
360 QXmlStreamAttributes attribs;
361 QString str;
362
363 while (!reader->atEnd()) {
364 reader->readNext();
365 if (reader->isEndElement() && reader->name() == QLatin1String("referenceLine"))
366 break;
367
368 if (!reader->isStartElement())
369 continue;
370
371 if (!preview && reader->name() == QLatin1String("comment")) {
372 if (!readCommentElement(reader))
373 return false;
374 } else if (!preview && reader->name() == QLatin1String("general")) {
375 // old logic for the position for xml version < 6
376 Q_D(ReferenceLine);
377 attribs = reader->attributes();
378 auto str = attribs.value(QStringLiteral("position")).toString();
379 if (str.isEmpty())
380 reader->raiseMissingAttributeWarning(QStringLiteral("position"));
381 else {
382 d->positionLogical.setX(str.toDouble());
383 d->positionLogical.setY(str.toDouble());
384 }
385 d->coordinateBindingEnabled = true;
386
387 READ_INT_VALUE("orientation", orientation, Orientation);
388 d->updatePositionLimit(); // set the position limit after the orientation was set
389 READ_INT_VALUE_DIRECT("plotRangeIndex", m_cSystemIndex, int);
390
391 str = attribs.value(QStringLiteral("visible")).toString();
392 if (str.isEmpty())
393 reader->raiseMissingAttributeWarning(QStringLiteral("visible"));
394 else
395 d->setVisible(str.toInt());
396 } else if (!preview && reader->name() == QLatin1String("geometry")) {
397 attribs = reader->attributes();
398 // new logic for the position for xmlVersion >= 6
399 READ_INT_VALUE("orientation", orientation, Orientation);
400 d->updatePositionLimit(); // set the position limit after the orientation was set
401 WorksheetElement::load(reader, preview);
402 } else if (!preview && reader->name() == QLatin1String("line")) {
403 d->line->load(reader, preview);
404 } else { // unknown element
405 reader->raiseUnknownElementWarning();
406 if (!reader->skipToEndElement())
407 return false;
408 }
409 }
410 return true;
411}

Callers

nothing calls this directly

Calls 12

atEndMethod · 0.80
setXMethod · 0.80
setYMethod · 0.80
skipToEndElementMethod · 0.80
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
isEmptyMethod · 0.45
updatePositionLimitMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected