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

Method addNew

src/frontend/worksheet/WorksheetView.cpp:1291–1404  ·  view source on GitHub ↗

"Add new" related slots

Source from the content-addressed store, hash-verified

1289
1290//"Add new" related slots
1291void WorksheetView::addNew(QAction* action) {
1292 bool restorePointers = false;
1293 WorksheetElement* aspect = nullptr;
1294 if (action == addCartesianPlot1Action) {
1295 auto* plot = new CartesianPlot(i18n("Plot Area"));
1296 plot->setType(CartesianPlot::Type::FourAxes);
1297 plot->setMouseMode(m_cartesianPlotMouseMode);
1298 aspect = plot;
1299 if (tbNewCartesianPlot)
1300 tbNewCartesianPlot->setDefaultAction(addCartesianPlot1Action);
1301 } else if (action == addCartesianPlot2Action) {
1302 auto* plot = new CartesianPlot(i18n("Plot Area"));
1303 plot->setType(CartesianPlot::Type::TwoAxes);
1304 plot->setMouseMode(m_cartesianPlotMouseMode);
1305 aspect = plot;
1306 if (tbNewCartesianPlot)
1307 tbNewCartesianPlot->setDefaultAction(addCartesianPlot2Action);
1308 } else if (action == addCartesianPlot3Action) {
1309 auto* plot = new CartesianPlot(i18n("Plot Area"));
1310 plot->setType(CartesianPlot::Type::TwoAxesCentered);
1311 plot->setMouseMode(m_cartesianPlotMouseMode);
1312 aspect = plot;
1313 if (tbNewCartesianPlot)
1314 tbNewCartesianPlot->setDefaultAction(addCartesianPlot3Action);
1315 } else if (action == addCartesianPlot4Action) {
1316 auto* plot = new CartesianPlot(i18n("Plot Area"));
1317 plot->setType(CartesianPlot::Type::TwoAxesCenteredZero);
1318 plot->setMouseMode(m_cartesianPlotMouseMode);
1319 aspect = plot;
1320 if (tbNewCartesianPlot)
1321 tbNewCartesianPlot->setDefaultAction(addCartesianPlot4Action);
1322 } else if (action == addCartesianPlotTemplateAction) {
1323#ifndef SDK
1324 // open dialog
1325 PlotTemplateDialog d;
1326 if (d.exec() != QDialog::Accepted)
1327 return;
1328
1329 auto* plot = d.generatePlot();
1330 if (!plot)
1331 return;
1332
1333 restorePointers = true;
1334 aspect = plot;
1335 if (tbNewCartesianPlot)
1336 tbNewCartesianPlot->setDefaultAction(addCartesianPlotTemplateAction);
1337#endif
1338 } else if (action == addTextLabelAction) {
1339 auto* l = new TextLabel(i18n("Text Label"));
1340 l->setText(i18n("Text Label"));
1341 aspect = l;
1342 } else if (action == addImageAction) {
1343 Image* image = new Image(i18n("Image"));
1344 aspect = image;
1345 }
1346 if (!aspect)
1347 return;
1348

Callers

nothing calls this directly

Calls 15

setMouseModeMethod · 0.80
execMethod · 0.80
generatePlotMethod · 0.80
retransformElementsMethod · 0.80
positionMethod · 0.80
alignMethod · 0.80
horizontalAlignmentMethod · 0.80
verticalAlignmentMethod · 0.80
setTypeMethod · 0.45
setTextMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected