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

Method createContextMenu

src/backend/worksheet/plots/cartesian/XYCurve.cpp:253–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253QMenu* XYCurve::createContextMenu() {
254 Q_D(const XYCurve);
255 if (!m_menusInitialized)
256 initActions();
257
258 QMenu* menu = WorksheetElement::createContextMenu();
259 QAction* visibilityAction = this->visibilityAction(); // skip the first action because of the "title-action", second is visible
260
261 //"data analysis" menu
262 menu->insertMenu(visibilityAction, d->m_plot->analysisMenu());
263 menu->insertSeparator(visibilityAction);
264
265 //"Navigate to spreadsheet"-action, show only if x- or y-columns have data from a spreadsheet
266 AbstractAspect* parentSpreadsheet = nullptr;
267 if (xColumn() && dynamic_cast<Spreadsheet*>(xColumn()->parentAspect()))
268 parentSpreadsheet = xColumn()->parentAspect();
269 else if (yColumn() && dynamic_cast<Spreadsheet*>(yColumn()->parentAspect()))
270 parentSpreadsheet = yColumn()->parentAspect();
271
272 if (parentSpreadsheet) {
273 navigateToAction->setText(i18n("Navigate to \"%1\"", parentSpreadsheet->name()));
274 navigateToAction->setData(parentSpreadsheet->path());
275 menu->insertAction(visibilityAction, navigateToAction);
276 menu->insertSeparator(visibilityAction);
277 }
278
279 // if the context menu is called on an item that is not selected yet, select it
280 if (!graphicsItem()->isSelected())
281 graphicsItem()->setSelected(true);
282
283 return menu;
284}
285
286/*!
287 Returns an icon to be used in the project explorer.

Callers

nothing calls this directly

Calls 9

visibilityActionMethod · 0.80
analysisMenuMethod · 0.80
parentAspectMethod · 0.80
setTextMethod · 0.45
nameMethod · 0.45
setDataMethod · 0.45
pathMethod · 0.45
isSelectedMethod · 0.45
setSelectedMethod · 0.45

Tested by

no test coverage detected