| 4375 | } |
| 4376 | |
| 4377 | void CartesianPlotPrivate::keyPressEvent(QKeyEvent* event) { |
| 4378 | const auto key = event->key(); |
| 4379 | // const bool ctrl = event->modifiers() & Qt::KeyboardModifier::ControlModifier; |
| 4380 | // const bool shift = event->modifiers() & Qt::KeyboardModifier::ShiftModifier; |
| 4381 | // const bool alt = event->modifiers() & Qt::KeyboardModifier::AltModifier; |
| 4382 | Action a = evaluateKeys(key, event->modifiers()); |
| 4383 | |
| 4384 | if (a == Action::Abort) { |
| 4385 | m_selectionBandIsShown = false; |
| 4386 | } else if (a & Action::Move) { |
| 4387 | const auto* worksheet = static_cast<const Worksheet*>(q->parentAspect()); |
| 4388 | if (worksheet->layout() == Worksheet::Layout::NoLayout) { |
| 4389 | // no layout is active -> use arrow keys to move the plot on the worksheet |
| 4390 | const int delta = 5; |
| 4391 | QRectF rect = q->rect(); |
| 4392 | |
| 4393 | if (a == Action::MoveLeft) { |
| 4394 | rect.setX(rect.x() - delta); |
| 4395 | rect.setWidth(rect.width() - delta); |
| 4396 | } else if (a == Action::MoveRight) { |
| 4397 | rect.setX(rect.x() + delta); |
| 4398 | rect.setWidth(rect.width() + delta); |
| 4399 | } else if (a == Action::MoveUp) { |
| 4400 | rect.setY(rect.y() - delta); |
| 4401 | rect.setHeight(rect.height() - delta); |
| 4402 | } else if (a == Action::MoveDown) { |
| 4403 | rect.setY(rect.y() + delta); |
| 4404 | rect.setHeight(rect.height() + delta); |
| 4405 | } |
| 4406 | |
| 4407 | q->setRect(rect); |
| 4408 | } |
| 4409 | } else if (a == Action::NavigateNextCurve) // (key == Qt::Key_Tab) |
| 4410 | navigateNextPrevCurve(); |
| 4411 | else if (a == Action::NavigatePrevCurve) // (key == Qt::SHIFT + Qt::Key_Tab) |
| 4412 | navigateNextPrevCurve(false /*next*/); |
| 4413 | else if (a & Action::New) { |
| 4414 | const auto* cSystem{defaultCoordinateSystem()}; |
| 4415 | if (cSystem->isValid()) { |
| 4416 | logicalPos = cSystem->mapSceneToLogical(scenePos, AbstractCoordinateSystem::MappingFlag::Limit); |
| 4417 | calledFromContextMenu = true; |
| 4418 | } |
| 4419 | if (a == Action::NewTextLabel) |
| 4420 | q->addTextLabel(); |
| 4421 | else if (a == Action::NewReferenceLine) |
| 4422 | q->addReferenceLine(); |
| 4423 | else if (a == Action::NewReferenceRange) |
| 4424 | q->addReferenceRange(); |
| 4425 | else if (a == Action::NewCustomPoint) |
| 4426 | q->addCustomPoint(); |
| 4427 | else if (a == Action::NewImage) |
| 4428 | q->addImage(); |
| 4429 | } |
| 4430 | QGraphicsItem::keyPressEvent(event); |
| 4431 | } |
| 4432 | |
| 4433 | void CartesianPlotPrivate::navigateNextPrevCurve(bool next) const { |
| 4434 | const auto& curves = q->children<XYCurve>(); |
nothing calls this directly
no test coverage detected