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

Method load

src/backend/worksheet/WorksheetElement.cpp:564–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564bool WorksheetElement::load(XmlStreamReader* reader, bool preview) {
565 if (preview)
566 return true;
567
568 Q_D(WorksheetElement);
569 auto attribs = reader->attributes();
570
571 auto str = attribs.value(QStringLiteral("x")).toString();
572 if (str.isEmpty())
573 reader->raiseMissingAttributeWarning(QStringLiteral("x"));
574 else
575 d->position.point.setX(str.toDouble());
576
577 str = attribs.value(QStringLiteral("y")).toString();
578 if (str.isEmpty())
579 reader->raiseMissingAttributeWarning(QStringLiteral("y"));
580 else
581 d->position.point.setY(str.toDouble());
582
583 READ_INT_VALUE("horizontalPosition", position.horizontalPosition, HorizontalPosition);
584 READ_INT_VALUE("verticalPosition", position.verticalPosition, VerticalPosition);
585 if (Project::xmlVersion() < 11) {
586 // In earlier versions 3 was custom which is now center. But now 3 is relative
587 if ((int)d->position.horizontalPosition == 3) {
588 d->position.horizontalPosition = HorizontalPosition::Center;
589 }
590 if ((int)d->position.verticalPosition == 3) {
591 d->position.verticalPosition = VerticalPosition::Center;
592 }
593 }
594 if (Project::xmlVersion() < 1) {
595 // Before 2.9.0 the position.point is only used when horizontalPosition or
596 // vertical position was set to Custom, otherwise the label was attached to the
597 // "position" and it was not possible to arrange relative to this anchor point
598 // From 2.9.0, the horizontalPosition and verticalPosition indicate the anchor
599 // point and position.point indicates the distance to them
600 if (d->position.horizontalPosition != HorizontalPosition::Relative) {
601 d->position.point.setX(0);
602 if (d->position.horizontalPosition == HorizontalPosition::Left)
603 d->horizontalAlignment = HorizontalAlignment::Left;
604 else if (d->position.horizontalPosition == HorizontalPosition::Right)
605 d->horizontalAlignment = HorizontalAlignment::Right;
606 } else // TODO
607 d->position.horizontalPosition = HorizontalPosition::Center;
608
609 if (d->position.verticalPosition != VerticalPosition::Relative) {
610 d->position.point.setY(0);
611 if (d->position.verticalPosition == VerticalPosition::Top)
612 d->verticalAlignment = VerticalAlignment::Top;
613 else if (d->position.verticalPosition == VerticalPosition::Bottom)
614 d->verticalAlignment = VerticalAlignment::Bottom;
615 } else // TODO
616 d->position.verticalPosition = VerticalPosition::Center;
617
618 // in the old format the order was reversed, multiply by -1 here
619 d->position.point.setY(-d->position.point.y());
620 } else {
621 READ_INT_VALUE("horizontalAlignment", horizontalAlignment, HorizontalAlignment);

Callers

nothing calls this directly

Calls 10

setXMethod · 0.80
setYMethod · 0.80
setRotationMethod · 0.80
toStringMethod · 0.45
valueMethod · 0.45
isEmptyMethod · 0.45
yMethod · 0.45
xmlVersionMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected