| 166 | } |
| 167 | |
| 168 | void XYFunctionCurveTest::removeColumnFromCurve() { |
| 169 | Project project; |
| 170 | auto* ws = new Worksheet(QStringLiteral("Worksheet")); |
| 171 | QVERIFY(ws != nullptr); |
| 172 | project.addChild(ws); |
| 173 | |
| 174 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 175 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 176 | QVERIFY(p != nullptr); |
| 177 | ws->addChild(p); |
| 178 | |
| 179 | p->addChild(new XYEquationCurve(QLatin1String("eq"))); |
| 180 | |
| 181 | // Generate data and |
| 182 | Spreadsheet* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 183 | project.addChild(sheet); |
| 184 | sheet->setColumnCount(2); |
| 185 | sheet->setRowCount(11); |
| 186 | sheet->column(0)->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 187 | sheet->column(1)->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 188 | |
| 189 | for (int i = 0; i < sheet->rowCount(); i++) { |
| 190 | sheet->column(0)->setValueAt(i, i); |
| 191 | sheet->column(1)->setValueAt(i, 2 * i + 1); |
| 192 | } |
| 193 | |
| 194 | auto* curve = new XYCurve(QStringLiteral("curve1")); |
| 195 | p->addChild(curve); |
| 196 | curve->setCoordinateSystemIndex(0); |
| 197 | curve->setXColumn(sheet->column(0)); |
| 198 | curve->setYColumn(sheet->column(1)); |
| 199 | |
| 200 | p->addChild(new XYFunctionCurve(QLatin1String("eq2"))); |
| 201 | auto functionCurves = p->children(AspectType::XYFunctionCurve); |
| 202 | QCOMPARE(functionCurves.count(), 1); |
| 203 | auto* functionCurve = static_cast<XYFunctionCurve*>(functionCurves.at(0)); |
| 204 | |
| 205 | auto dock = XYFunctionCurveDock(nullptr); |
| 206 | dock.setupGeneral(); |
| 207 | dock.setCurves({functionCurve}); |
| 208 | |
| 209 | functionCurve->setFunction(QStringLiteral("2*x"), {QStringLiteral("x")}, {curve}); |
| 210 | |
| 211 | sheet->column(1)->remove(); |
| 212 | |
| 213 | QCOMPARE(functionCurve->xColumn()->rowCount(), 0); |
| 214 | } |
| 215 | |
| 216 | void XYFunctionCurveTest::removeCurveRenameAutomaticAdd() { |
| 217 | Project project; |
nothing calls this directly
no test coverage detected