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

Method changeSelectedItemsPosition

src/frontend/datapicker/DatapickerImageView.cpp:678–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678void DatapickerImageView::changeSelectedItemsPosition(QAction* action) {
679 if (scene()->selectedItems().isEmpty())
680 return;
681
682 QPointF shift(0, 0);
683 if (action == shiftLeftAction)
684 shift.setX(1);
685 else if (action == shiftRightAction)
686 shift.setX(-1);
687 else if (action == shiftUpAction)
688 shift.setY(-1);
689 else if (action == shiftDownAction)
690 shift.setY(1);
691
692 m_image->beginMacro(i18n("%1: change position of selected DatapickerPoints.", m_image->name()));
693 const QVector<DatapickerPoint*> axisPoints = m_image->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden);
694 for (auto* point : axisPoints) {
695 if (!point->graphicsItem()->isSelected())
696 continue;
697
698 QPointF newPos = point->position();
699 newPos = newPos + shift;
700 point->setPosition(newPos);
701
702 int pointIndex = m_image->indexOfChild<DatapickerPoint>(point, AbstractAspect::ChildIndexFlag::IncludeHidden);
703 if (pointIndex == -1)
704 continue;
705 DatapickerImage::ReferencePoints points = m_image->axisPoints();
706 points.scenePos[pointIndex].setX(point->position().x());
707 points.scenePos[pointIndex].setY(point->position().y());
708 m_image->setUndoAware(false);
709 m_image->setAxisPoints(points);
710 m_image->setUndoAware(true);
711 }
712
713 for (auto* curve : m_image->parentAspect()->children<DatapickerCurve>()) {
714 for (auto* point : curve->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden)) {
715 if (!point->graphicsItem()->isSelected())
716 continue;
717
718 QPointF newPos = point->position();
719 newPos = newPos + shift;
720 point->setPosition(newPos);
721 }
722 }
723
724 m_image->endMacro();
725 if (m_image->m_magnificationWindow && m_image->m_magnificationWindow->isVisible())
726 updateMagnificationWindow();
727}
728
729void DatapickerImageView::magnificationChanged(QAction* action) {
730 if (action == noMagnificationAction) {

Callers

nothing calls this directly

Calls 15

selectedItemsMethod · 0.80
setXMethod · 0.80
setYMethod · 0.80
beginMacroMethod · 0.80
positionMethod · 0.80
xMethod · 0.80
setUndoAwareMethod · 0.80
setAxisPointsMethod · 0.80
parentAspectMethod · 0.80
endMacroMethod · 0.80
isEmptyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected