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

Method copyPaste

tests/backend/core/AbstractAspectTest.cpp:175–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void AbstractAspectTest::copyPaste() {
176 Project project;
177
178 auto* worksheet = new Worksheet(QStringLiteral("Worksheet"));
179 project.addChild(worksheet);
180
181 auto* plot = new CartesianPlot(QStringLiteral("plot"));
182 worksheet->addChild(plot);
183 plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
184 plot->setNiceExtend(false);
185
186 auto* equationCurve{new XYEquationCurve(QStringLiteral("f(x)"))};
187 equationCurve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex());
188 plot->addChild(equationCurve);
189
190 XYEquationCurve::EquationData data;
191 data.min = QStringLiteral("0");
192 data.max = QStringLiteral("1");
193 data.count = 10;
194 data.expression1 = QStringLiteral("x");
195 equationCurve->setEquationData(data);
196 equationCurve->recalculate();
197
198 worksheet->copy();
199 project.paste();
200
201 const auto& worksheets = project.children(AspectType::Worksheet);
202 QCOMPARE(worksheets.count(), 2);
203 QVERIFY(worksheets.at(0)->uuid() != worksheets.at(1)->uuid());
204
205 const auto& childrenWorksheet1 =
206 worksheets.at(0)->children(AspectType::AbstractAspect, {AbstractAspect::ChildIndexFlag::IncludeHidden, AbstractAspect::ChildIndexFlag::Recursive});
207 const auto& childrenWorksheet2 =
208 worksheets.at(1)->children(AspectType::AbstractAspect, {AbstractAspect::ChildIndexFlag::IncludeHidden, AbstractAspect::ChildIndexFlag::Recursive});
209
210 QCOMPARE(childrenWorksheet1.count(), childrenWorksheet2.count());
211
212 for (int i = 0; i < childrenWorksheet1.count(); i++) {
213 QVERIFY(childrenWorksheet1.at(i)->type() == childrenWorksheet2.at(i)->type());
214 if (childrenWorksheet1.at(i)->type() == AspectType::AbstractAspect)
215 continue; // unique will change the triggered for those aspects, and therefore when changing for the second from "1" to "2" it happens that "2"
216 // already exists and therefore it receives "3"
217 QVERIFY(childrenWorksheet1.at(i)->name() == childrenWorksheet2.at(i)->name());
218 QVERIFY(childrenWorksheet1.at(i)->uuid() != childrenWorksheet2.at(i)->uuid());
219 }
220}
221
222/*!
223 * check copy&paste (duplicate) of a XYFitCurve with the data source type "Spreadsheet",

Callers

nothing calls this directly

Calls 14

setNiceExtendMethod · 0.80
setEquationDataMethod · 0.80
pasteMethod · 0.80
uuidMethod · 0.80
addChildMethod · 0.45
setTypeMethod · 0.45
recalculateMethod · 0.45
copyMethod · 0.45
childrenMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected