"Add new" related slots
| 1289 | |
| 1290 | //"Add new" related slots |
| 1291 | void 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 |
nothing calls this directly
no test coverage detected