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

Method positionRelativeDock

tests/backend/Worksheet/WorksheetElementTest.cpp:1063–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1061}
1062
1063void WorksheetElementTest::positionRelativeDock() {
1064 // WORKSHEETELEMENT_TEST()
1065 SETUP_PROJECT
1066 auto* element = new TextLabel(QStringLiteral("element"));
1067 p->addChild(element);
1068 auto* dock = new LabelWidget(nullptr);
1069 // MACRO_NAME(element, dockSetElementsMethodName);
1070 dock->setLabels({element});
1071
1072 // #define WORKSHEETELEMENT_MOUSE_MOVE(element, dockSetElementsMethodName)
1073 element->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
1074 auto pp = element->position();
1075 pp.point = QPointF(0, 0);
1076 element->setPosition(pp);
1077 element->setCoordinateBindingEnabled(false);
1078
1079 QCOMPARE(element->positionLogical().x(), 0.0);
1080 QCOMPARE(element->positionLogical().y(), 0.0);
1081
1082 QCOMPARE(element->horizontalAlignment(), AbstractPlot::HorizontalAlignment::Center);
1083 QCOMPARE(element->verticalAlignment(), AbstractPlot::VerticalAlignment::Center);
1084
1085 pp = element->position();
1086 pp.horizontalPosition = AbstractPlot::HorizontalPosition::Relative;
1087 pp.verticalPosition = AbstractPlot::VerticalPosition::Relative;
1088 // element->setPositionHorizontal(AbstractPlot::HorizontalAlignment::Relative);
1089 // element->setPositionVertical(AbstractPlot::VerticalAlignment::Relative);
1090
1091 // Set values in dock
1092 dock->ui.sbPositionX->setValue(20);
1093 dock->ui.sbPositionY->setValue(80);
1094
1095 // TODO
1096 // QCOMPARE(element->positionLogical().x(), 0.2);
1097 // QCOMPARE(element->positionLogical().y(), 0.8);
1098 QCOMPARE(element->positionLogical().x(), 20.5);
1099 QCOMPARE(element->positionLogical().y(), 80.5);
1100
1101 QCOMPARE(dock->ui.sbPositionX->value(), 0.2 * 100.0);
1102 QCOMPARE(dock->ui.sbPositionY->value(), 0.8 * 100.0);
1103}
1104
1105void WorksheetElementTest::positionRelativeDockWithBinding() {
1106 // WORKSHEETELEMENT_TEST()

Callers

nothing calls this directly

Calls 14

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