diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp index 51cdba3..a8910f4 100644 --- a/src/chartsqml2/declarativechart.cpp +++ b/src/chartsqml2/declarativechart.cpp @@ -265,6 +265,11 @@ QT_CHARTS_BEGIN_NAMESPACE */ /*! + \qmlmethod ChartView::isZoomed() + Returns true if any series has a zoomed domain. +*/ + +/*! \qmlmethod ChartView::scrollLeft(real pixels) Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation. */ @@ -879,6 +884,11 @@ void DeclarativeChart::zoomReset() m_chart->zoomReset(); } +bool DeclarativeChart::isZoomed() +{ + return m_chart->isZoomed(); +} + void DeclarativeChart::scrollLeft(qreal pixels) { m_chart->scroll(-pixels, 0); diff --git a/src/chartsqml2/declarativechart.h b/src/chartsqml2/declarativechart.h index 397061a..80505d4 100644 --- a/src/chartsqml2/declarativechart.h +++ b/src/chartsqml2/declarativechart.h @@ -173,6 +173,7 @@ public: Q_REVISION(5) Q_INVOKABLE void zoomIn(const QRectF &rectangle); Q_REVISION(5) Q_INVOKABLE void zoomOut(); Q_REVISION(5) Q_INVOKABLE void zoomReset(); + Q_REVISION(5) Q_INVOKABLE bool isZoomed(); Q_INVOKABLE void scrollLeft(qreal pixels); Q_INVOKABLE void scrollRight(qreal pixels); Q_INVOKABLE void scrollUp(qreal pixels); diff --git a/src/chartsqml2/plugins.qmltypes b/src/chartsqml2/plugins.qmltypes index af019e2..43f0faa 100644 --- a/src/chartsqml2/plugins.qmltypes +++ b/src/chartsqml2/plugins.qmltypes @@ -1119,6 +1119,7 @@ Module { } Method { name: "zoomOut"; revision: 5 } Method { name: "zoomReset"; revision: 5 } + Method { name: "isZoomed"; revision: 5; type: "bool" } Method { name: "scrollLeft" Parameter { name: "pixels"; type: "double" } diff --git a/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml b/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml index 763d99e..f47ebaa 100644 --- a/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml +++ b/tests/auto/qml-qtquicktest/tst_chartviewfunctions.qml @@ -94,6 +94,7 @@ Rectangle { // zoom x 2.5 chartView.zoom(1.5); + verify(chartView.isZoomed()); verify(chartView.axisX().max < xMax); verify(chartView.axisX().min > xMin); verify(chartView.axisY().max < yMax); @@ -105,6 +106,7 @@ Rectangle { // zoom x 0.5 chartView.zoom(0.5); + verify(chartView.isZoomed()); verify(chartView.axisX().max > xMax); verify(chartView.axisX().min < xMin); verify(chartView.axisY().max > yMax); @@ -117,6 +119,7 @@ Rectangle { // zoom x -1 // negative value has no effect chartView.zoom(-1); + verify(chartView.isZoomed()); verify(chartView.axisX().max === xMax); verify(chartView.axisX().min === xMin); verify(chartView.axisY().max === yMax); @@ -124,6 +127,7 @@ Rectangle { // zoom in chartView.zoomIn(); + verify(chartView.isZoomed()); verify(chartView.axisX().max < xMax); verify(chartView.axisX().min > xMin); verify(chartView.axisY().max < yMax); @@ -139,6 +143,7 @@ Rectangle { zoomRect.width = 120; zoomRect.height = 120; chartView.zoomIn(zoomRect); + verify(chartView.isZoomed()); verify(chartView.axisX().max < xMax); verify(chartView.axisX().min > xMin); verify(chartView.axisY().max < yMax); @@ -150,6 +155,7 @@ Rectangle { // zoom out chartView.zoomOut(); + verify(chartView.isZoomed()); verify(chartView.axisX().max > xMax); verify(chartView.axisX().min < xMin); verify(chartView.axisY().max > yMax); @@ -161,6 +167,7 @@ Rectangle { // zoom reset chartView.zoomReset(); + verify(!chartView.isZoomed()); verify(chartView.axisX().max === xMaxOriginal); verify(chartView.axisX().min === xMinOriginal); verify(chartView.axisY().max === yMaxOriginal);