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 20:09:18 +0000 |
commit | a2e6f9a05065c8ad40b56a68ca78b2eb11af04e7 (patch) | |
tree | 0847ac0069881ad415b4814322fe976ece80cb6e | |
parent | 0ea92fb2819aa2381446e828de2a68c59b37ad68 (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 { |