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

Method rangeFormatXDataChanged

tests/cartesianplot/CartesianPlotTest.cpp:618–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616}
617
618void CartesianPlotTest::rangeFormatXDataChanged() {
619 Project project;
620
621 Spreadsheet* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false);
622 project.addChild(sheet);
623
624 sheet->setColumnCount(2);
625 sheet->setRowCount(3);
626
627 sheet->column(0)->setColumnMode(AbstractColumn::ColumnMode::DateTime);
628 sheet->column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer);
629
630 sheet->column(0)->setDateTimeAt(0, QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate));
631 sheet->column(0)->setDateTimeAt(1, QDateTime::fromString(QStringLiteral("2022-02-04 12:23:00"), Qt::ISODate));
632 sheet->column(0)->setDateTimeAt(2, QDateTime::fromString(QStringLiteral("2022-02-05 12:23:00"), Qt::ISODate));
633
634 QCOMPARE(sheet->column(0)->dateTimeAt(0), QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate));
635
636 sheet->column(1)->setValueAt(0, 0);
637 sheet->column(1)->setValueAt(1, 1);
638 sheet->column(1)->setValueAt(2, 2);
639
640 auto* worksheet = new Worksheet(QStringLiteral("Worksheet"));
641 project.addChild(worksheet);
642
643 auto* plot = new CartesianPlot(QStringLiteral("plot"));
644 worksheet->addChild(plot);
645 plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
646
647 auto* curve = new XYCurve(QStringLiteral("curve"));
648 plot->addChild(curve);
649
650 curve->setXColumn(sheet->column(1));
651 curve->setYColumn(sheet->column(0));
652
653 QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::Numeric);
654 QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::DateTime);
655
656 // simulate data change
657 plot->dataChanged(curve, Dimension::X);
658
659 QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::Numeric);
660 QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::DateTime);
661}
662
663void CartesianPlotTest::rangeFormatNonDefaultRange() {
664 Project project;

Callers

nothing calls this directly

Calls 13

setYColumnMethod · 0.80
rangeFormatMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
setColumnModeMethod · 0.45
columnMethod · 0.45
setDateTimeAtMethod · 0.45
dateTimeAtMethod · 0.45
setValueAtMethod · 0.45
setTypeMethod · 0.45
setXColumnMethod · 0.45

Tested by

no test coverage detected