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

Method positionRelative

tests/backend/Worksheet/WorksheetElementTest.cpp:985–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

983}
984
985void WorksheetElementTest::positionRelative() {
986 // WORKSHEETELEMENT_TEST()
987 SETUP_PROJECT
988 auto* element = new TextLabel(QStringLiteral("element"));
989 p->addChild(element);
990 auto* dock = new LabelWidget(nullptr);
991 // MACRO_NAME(element, dockSetElementsMethodName);
992 dock->setLabels({element});
993
994 // #define WORKSHEETELEMENT_MOUSE_MOVE(element, dockSetElementsMethodName)
995 element->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
996 auto pp = element->position();
997 pp.point = QPointF(0, 0);
998 element->setPosition(pp);
999 element->setCoordinateBindingEnabled(false);
1000
1001 QCOMPARE(element->positionLogical().x(), 0.0);
1002 QCOMPARE(element->positionLogical().y(), 0.0);
1003
1004 QCOMPARE(element->horizontalAlignment(), AbstractPlot::HorizontalAlignment::Center);
1005 QCOMPARE(element->verticalAlignment(), AbstractPlot::VerticalAlignment::Center);
1006
1007 pp = element->position();
1008 pp.horizontalPosition = AbstractPlot::HorizontalPosition::Relative;
1009 pp.verticalPosition = AbstractPlot::VerticalPosition::Relative;
1010 pp.point = QPointF(0.2, 0.8); // 20% and 80%
1011 element->setPosition(pp);
1012
1013 QCOMPARE(element->positionLogical().x(), 0.2);
1014 // TODO
1015 // QCOMPARE(element->positionLogical().y(), 0.8);
1016 QCOMPARE(element->positionLogical().y(), 0.2);
1017
1018 QCOMPARE(dock->ui.sbPositionX->value(), 0.2 * 100.0);
1019 QCOMPARE(dock->ui.sbPositionY->value(), 0.8 * 100.0);
1020}
1021
1022void WorksheetElementTest::positionRelativeWithBinding() {
1023 // WORKSHEETELEMENT_TEST()

Callers

nothing calls this directly

Calls 13

setLabelsMethod · 0.80
positionMethod · 0.80
xMethod · 0.80
horizontalAlignmentMethod · 0.80
verticalAlignmentMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
setPositionMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected