| 938 | } |
| 939 | |
| 940 | void WorksheetView::mouseMoveEvent(QMouseEvent* event) { |
| 941 | if (m_suppressSelectionChangedEvent) |
| 942 | return QGraphicsView::mouseMoveEvent(event); |
| 943 | if (m_mouseMode == MouseMode::Selection && m_cartesianPlotMouseMode != CartesianPlot::MouseMode::Selection) { |
| 944 | // check whether there is a cartesian plot under the cursor |
| 945 | // and set the cursor appearance according to the current mouse mode for the cartesian plots |
| 946 | if (plotAt(event->pos())) { |
| 947 | if (m_cartesianPlotMouseMode == CartesianPlot::MouseMode::ZoomSelection) |
| 948 | setCursor(Qt::CrossCursor); |
| 949 | else if (m_cartesianPlotMouseMode == CartesianPlot::MouseMode::ZoomXSelection) |
| 950 | setCursor(Qt::SizeHorCursor); |
| 951 | else if (m_cartesianPlotMouseMode == CartesianPlot::MouseMode::ZoomYSelection) |
| 952 | setCursor(Qt::SizeVerCursor); |
| 953 | } else |
| 954 | setCursor(Qt::ArrowCursor); |
| 955 | } else if (m_mouseMode == MouseMode::Selection && m_cartesianPlotMouseMode == CartesianPlot::MouseMode::Selection) |
| 956 | setCursor(Qt::ArrowCursor); |
| 957 | else if (m_selectionBandIsShown) { |
| 958 | QRect rect = QRect(m_selectionStart, m_selectionEnd).normalized(); |
| 959 | m_selectionEnd = event->pos(); |
| 960 | rect = rect.united(QRect(m_selectionStart, m_selectionEnd).normalized()); |
| 961 | qreal penWidth = 5 / transform().m11(); |
| 962 | rect.setX(rect.x() - penWidth); |
| 963 | rect.setY(rect.y() - penWidth); |
| 964 | rect.setHeight(rect.height() + 2 * penWidth); |
| 965 | rect.setWidth(rect.width() + 2 * penWidth); |
| 966 | viewport()->repaint(rect); |
| 967 | } |
| 968 | |
| 969 | // show the magnification window |
| 970 | if (magnificationFactor /*&& m_mouseMode == SelectAndEditMode*/) { |
| 971 | if (!m_magnificationWindow) { |
| 972 | m_magnificationWindow = new QGraphicsPixmapItem(nullptr); |
| 973 | m_magnificationWindow->setZValue(std::numeric_limits<int>::max()); |
| 974 | scene()->addItem(m_magnificationWindow); |
| 975 | } |
| 976 | |
| 977 | updateMagnificationWindow(mapToScene(event->pos())); |
| 978 | } else if (m_magnificationWindow) |
| 979 | m_magnificationWindow->setVisible(false); |
| 980 | |
| 981 | QGraphicsView::mouseMoveEvent(event); |
| 982 | } |
| 983 | |
| 984 | /*! |
| 985 | * Updates the magnified content of the scene under the cursor that is shown in the magnification window. |