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

Method columnValueChanged

tests/backend/InfoElement/InfoElementTest.cpp:341–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void InfoElementTest::columnValueChanged() {
342 Project project;
343 auto* ws = new Worksheet(QStringLiteral("worksheet"));
344 QVERIFY(ws != nullptr);
345 project.addChild(ws);
346
347 auto* p = new CartesianPlot(QStringLiteral("plot"));
348 QVERIFY(p != nullptr);
349 ws->addChild(p);
350
351 auto* curve{new XYCurve(QStringLiteral("f(x)"))};
352 curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex());
353
354 auto* spreadsheet = new Spreadsheet(QStringLiteral("spreadsheet"));
355 spreadsheet->setColumnCount(2);
356 spreadsheet->setRowCount(11);
357 project.addChild(spreadsheet);
358 const auto& columns = spreadsheet->children<Column>();
359 QCOMPARE(columns.count(), 2);
360 QCOMPARE(spreadsheet->rowCount(), 11);
361
362 auto* xColumn = columns.at(0);
363 auto* yColumn = columns.at(1);
364
365 for (int i = 0; i < spreadsheet->rowCount(); i++) {
366 xColumn->setValueAt(i, i);
367 yColumn->setValueAt(i, i);
368 }
369
370 curve->setXColumn(xColumn);
371 curve->setYColumn(yColumn);
372 p->addChild(curve);
373
374 CHECK_RANGE(p, curve, Dimension::X, 0., 10.);
375 CHECK_RANGE(p, curve, Dimension::Y, 0., 10.);
376
377 auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9);
378 QVERIFY(ie != nullptr);
379 p->addChild(ie);
380
381 {
382 const auto points = ie->children<CustomPoint>();
383 QCOMPARE(ie->markerPointsCount(), 1);
384 QCOMPARE(ie->markerPointAt(0).curve, curve);
385 QCOMPARE(points.count(), 1);
386 QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0));
387 QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5));
388 }
389 QCOMPARE(ie->connectionLineCurveName(), curve->name());
390
391 // InfoElement is invalid
392 const auto& labels = ie->children<TextLabel>(AbstractAspect::ChildIndexFlag::IncludeHidden);
393 const auto& points = ie->children<CustomPoint>();
394 QCOMPARE(labels.count(), 1);
395 QCOMPARE(points.count(), 1);
396
397 QCOMPARE(ie->isValid(), true);
398 QCOMPARE(labels.at(0)->isVisible(), true);

Callers

nothing calls this directly

Calls 15

setYColumnMethod · 0.80
markerPointsCountMethod · 0.80
markerPointAtMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
countMethod · 0.45
rowCountMethod · 0.45
setValueAtMethod · 0.45

Tested by

no test coverage detected