diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-04-07 12:13:48 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-04-08 15:11:48 +0000 |
commit | dfbcbe4fdd8215dabf3d1b3b853ae644c6581390 (patch) | |
tree | bee5de2c741b5750e74374975e4d0d9ce3b22e90 | |
parent | d92b784fbc8e26dce8b283e98c2f1382899a2176 (diff) |
Fix QChartView rubberband zoom
Rubberband flag handling was changed from using equality operator
to testFlag() when a new flag was added. This change broke the case
where both horizontal and vertical flags were specified.
Fixed the logic to account for all cases properly.
Fixes: QTBUG-102286
Change-Id: Ib19cc3a2d7852097567fe36f04ff021232d49d3c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
(cherry picked from commit 9fd4d2f8a2a77990a78be929d0ff2be78f5720ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/charts/qchartview.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/charts/qchartview.cpp b/src/charts/qchartview.cpp index e7ca9db1..3e57f186 100644 --- a/src/charts/qchartview.cpp +++ b/src/charts/qchartview.cpp @@ -234,17 +234,18 @@ void QChartView::mouseReleaseEvent(QMouseEvent *event) // Since plotArea uses QRectF and rubberband uses QRect, we can't just blindly use // rubberband's dimensions for vertical and horizontal rubberbands, where one // dimension must match the corresponding plotArea dimension exactly. - if (d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { - rect.setX(d_ptr->m_chart->plotArea().x()); - rect.setWidth(d_ptr->m_chart->plotArea().width()); - } else if (d_ptr->m_rubberBandFlags.testFlag(HorizontalRubberBand)) { - rect.setY(d_ptr->m_chart->plotArea().y()); - rect.setHeight(d_ptr->m_chart->plotArea().height()); + if (!d_ptr->m_rubberBandFlags.testFlag(RectangleRubberBand)) { + if (d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { + rect.setX(d_ptr->m_chart->plotArea().x()); + rect.setWidth(d_ptr->m_chart->plotArea().width()); + } else if (d_ptr->m_rubberBandFlags.testFlag(HorizontalRubberBand)) { + rect.setY(d_ptr->m_chart->plotArea().y()); + rect.setHeight(d_ptr->m_chart->plotArea().height()); + } } d_ptr->m_chart->zoomIn(rect); event->accept(); } - } else if (d_ptr->m_rubberBand && event->button() == Qt::RightButton) { // If vertical or horizontal rubberband mode, restrict zoom out to specified axis. // Since there is no suitable API for that, use zoomIn with rect bigger than the @@ -255,13 +256,12 @@ void QChartView::mouseReleaseEvent(QMouseEvent *event) if (d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) { qreal adjustment = rect.height() / 2; rect.adjust(0, -adjustment, 0, adjustment); - } else if (d_ptr->m_rubberBandFlags.testFlag(HorizontalRubberBand)) { + } + if (d_ptr->m_rubberBandFlags.testFlag(HorizontalRubberBand)) { qreal adjustment = rect.width() / 2; rect.adjust(-adjustment, 0, adjustment, 0); } d_ptr->m_chart->zoomIn(rect); - } else { - d_ptr->m_chart->zoomOut(); } event->accept(); } else { |