| 1342 | } |
| 1343 | |
| 1344 | void CartesianPlotTest::spreadsheetInsertRows() { |
| 1345 | Project project; |
| 1346 | |
| 1347 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1348 | project.addChild(worksheet); |
| 1349 | |
| 1350 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 1351 | worksheet->addChild(plot); |
| 1352 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 1353 | plot->setNiceExtend(false); |
| 1354 | |
| 1355 | auto* sheet = new Spreadsheet(QStringLiteral("data"), false); |
| 1356 | project.addChild(sheet); |
| 1357 | sheet->setColumnCount(2); |
| 1358 | |
| 1359 | const auto& columns = sheet->children<Column>(); |
| 1360 | QCOMPARE(columns.count(), 2); |
| 1361 | Column* xColumn = columns.at(0); |
| 1362 | Column* yColumn = columns.at(1); |
| 1363 | |
| 1364 | xColumn->replaceValues(-1, |
| 1365 | { |
| 1366 | 1., |
| 1367 | 2., |
| 1368 | 3., |
| 1369 | 4., |
| 1370 | 5., |
| 1371 | }); |
| 1372 | yColumn->replaceValues(-1, |
| 1373 | { |
| 1374 | 0., |
| 1375 | 4., |
| 1376 | 6., |
| 1377 | 8., |
| 1378 | 10., |
| 1379 | }); |
| 1380 | |
| 1381 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 1382 | plot->addChild(curve); |
| 1383 | curve->setXColumn(xColumn); |
| 1384 | curve->setYColumn(yColumn); |
| 1385 | |
| 1386 | CHECK_RANGE(plot, curve, Dimension::X, 1., 5.); |
| 1387 | CHECK_RANGE(plot, curve, Dimension::Y, 0., 10.); |
| 1388 | |
| 1389 | sheet->insertRows(4, 1); |
| 1390 | QCOMPARE(xColumn->rowCount(), 6); |
| 1391 | QCOMPARE(yColumn->rowCount(), 6); |
| 1392 | |
| 1393 | xColumn->replaceValues(5, {13}); |
| 1394 | yColumn->replaceValues(5, {25}); |
| 1395 | |
| 1396 | CHECK_RANGE(plot, curve, Dimension::X, 1., 13.); |
| 1397 | CHECK_RANGE(plot, curve, Dimension::Y, 0., 25.); |
| 1398 | |
| 1399 | project.undoStack()->undo(); // xColumn replace values |
| 1400 | project.undoStack()->undo(); // yColumn replace values |
| 1401 | project.undoStack()->undo(); // spreadsheet insertRows |
nothing calls this directly
no test coverage detected