| 4431 | } |
| 4432 | |
| 4433 | void CartesianPlotPrivate::navigateNextPrevCurve(bool next) const { |
| 4434 | const auto& curves = q->children<XYCurve>(); |
| 4435 | if (curves.isEmpty()) |
| 4436 | return; |
| 4437 | |
| 4438 | // determine the current selected curve |
| 4439 | const XYCurve* selectedCurve = nullptr; |
| 4440 | int index = 0; |
| 4441 | for (const auto* curve : curves) { |
| 4442 | if (curve->graphicsItem()->isSelected()) { |
| 4443 | selectedCurve = curve; |
| 4444 | break; |
| 4445 | } |
| 4446 | ++index; |
| 4447 | } |
| 4448 | |
| 4449 | int newIndex = 0; |
| 4450 | if (selectedCurve) { |
| 4451 | if (next) { // havigate to the next curve |
| 4452 | if (index < curves.size() - 1) |
| 4453 | newIndex = index + 1; |
| 4454 | } else { // navigate to the previous curve |
| 4455 | if (index > 0) |
| 4456 | newIndex = index - 1; |
| 4457 | else |
| 4458 | newIndex = curves.size() - 1; |
| 4459 | } |
| 4460 | } |
| 4461 | |
| 4462 | auto* w = static_cast<Worksheet*>(q->parent(AspectType::Worksheet)); |
| 4463 | |
| 4464 | // deselect the current curve |
| 4465 | if (selectedCurve) |
| 4466 | w->setItemSelectedInView(selectedCurve->graphicsItem(), false); |
| 4467 | else { |
| 4468 | // no curve is selected, either the plot itself or some |
| 4469 | // other children like axis, etc. are selected. |
| 4470 | // deselect all of them |
| 4471 | w->setItemSelectedInView(this, false); // deselect the plot |
| 4472 | |
| 4473 | // deselect children |
| 4474 | const auto& elements = q->children<WorksheetElement>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 4475 | for (auto* element : elements) |
| 4476 | w->setItemSelectedInView(element->graphicsItem(), false); |
| 4477 | } |
| 4478 | |
| 4479 | // select the new curve |
| 4480 | w->setItemSelectedInView(curves.at(newIndex)->graphicsItem(), true); |
| 4481 | } |
| 4482 | |
| 4483 | void CartesianPlotPrivate::hoverMoveEvent(QGraphicsSceneHoverEvent* event) { |
| 4484 | QPointF point = event->pos(); |
nothing calls this directly
no test coverage detected