##// END OF EJS Templates
Added isZoomed method to ChartView...
Titta Heikkala -
r2813:643291cd617f
parent child
Show More
@@ -265,6 +265,11 QT_CHARTS_BEGIN_NAMESPACE
265 */
265 */
266
266
267 /*!
267 /*!
268 \qmlmethod ChartView::isZoomed()
269 Returns true if any series has a zoomed domain.
270 */
271
272 /*!
268 \qmlmethod ChartView::scrollLeft(real pixels)
273 \qmlmethod ChartView::scrollLeft(real pixels)
269 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
274 Scrolls to left by \a pixels. This is a convenience function that suits for example for key navigation.
270 */
275 */
@@ -879,6 +884,11 void DeclarativeChart::zoomReset()
879 m_chart->zoomReset();
884 m_chart->zoomReset();
880 }
885 }
881
886
887 bool DeclarativeChart::isZoomed()
888 {
889 return m_chart->isZoomed();
890 }
891
882 void DeclarativeChart::scrollLeft(qreal pixels)
892 void DeclarativeChart::scrollLeft(qreal pixels)
883 {
893 {
884 m_chart->scroll(-pixels, 0);
894 m_chart->scroll(-pixels, 0);
@@ -173,6 +173,7 public:
173 Q_REVISION(5) Q_INVOKABLE void zoomIn(const QRectF &rectangle);
173 Q_REVISION(5) Q_INVOKABLE void zoomIn(const QRectF &rectangle);
174 Q_REVISION(5) Q_INVOKABLE void zoomOut();
174 Q_REVISION(5) Q_INVOKABLE void zoomOut();
175 Q_REVISION(5) Q_INVOKABLE void zoomReset();
175 Q_REVISION(5) Q_INVOKABLE void zoomReset();
176 Q_REVISION(5) Q_INVOKABLE bool isZoomed();
176 Q_INVOKABLE void scrollLeft(qreal pixels);
177 Q_INVOKABLE void scrollLeft(qreal pixels);
177 Q_INVOKABLE void scrollRight(qreal pixels);
178 Q_INVOKABLE void scrollRight(qreal pixels);
178 Q_INVOKABLE void scrollUp(qreal pixels);
179 Q_INVOKABLE void scrollUp(qreal pixels);
@@ -1119,6 +1119,7 Module {
1119 }
1119 }
1120 Method { name: "zoomOut"; revision: 5 }
1120 Method { name: "zoomOut"; revision: 5 }
1121 Method { name: "zoomReset"; revision: 5 }
1121 Method { name: "zoomReset"; revision: 5 }
1122 Method { name: "isZoomed"; revision: 5; type: "bool" }
1122 Method {
1123 Method {
1123 name: "scrollLeft"
1124 name: "scrollLeft"
1124 Parameter { name: "pixels"; type: "double" }
1125 Parameter { name: "pixels"; type: "double" }
@@ -94,6 +94,7 Rectangle {
94
94
95 // zoom x 2.5
95 // zoom x 2.5
96 chartView.zoom(1.5);
96 chartView.zoom(1.5);
97 verify(chartView.isZoomed());
97 verify(chartView.axisX().max < xMax);
98 verify(chartView.axisX().max < xMax);
98 verify(chartView.axisX().min > xMin);
99 verify(chartView.axisX().min > xMin);
99 verify(chartView.axisY().max < yMax);
100 verify(chartView.axisY().max < yMax);
@@ -105,6 +106,7 Rectangle {
105
106
106 // zoom x 0.5
107 // zoom x 0.5
107 chartView.zoom(0.5);
108 chartView.zoom(0.5);
109 verify(chartView.isZoomed());
108 verify(chartView.axisX().max > xMax);
110 verify(chartView.axisX().max > xMax);
109 verify(chartView.axisX().min < xMin);
111 verify(chartView.axisX().min < xMin);
110 verify(chartView.axisY().max > yMax);
112 verify(chartView.axisY().max > yMax);
@@ -117,6 +119,7 Rectangle {
117 // zoom x -1
119 // zoom x -1
118 // negative value has no effect
120 // negative value has no effect
119 chartView.zoom(-1);
121 chartView.zoom(-1);
122 verify(chartView.isZoomed());
120 verify(chartView.axisX().max === xMax);
123 verify(chartView.axisX().max === xMax);
121 verify(chartView.axisX().min === xMin);
124 verify(chartView.axisX().min === xMin);
122 verify(chartView.axisY().max === yMax);
125 verify(chartView.axisY().max === yMax);
@@ -124,6 +127,7 Rectangle {
124
127
125 // zoom in
128 // zoom in
126 chartView.zoomIn();
129 chartView.zoomIn();
130 verify(chartView.isZoomed());
127 verify(chartView.axisX().max < xMax);
131 verify(chartView.axisX().max < xMax);
128 verify(chartView.axisX().min > xMin);
132 verify(chartView.axisX().min > xMin);
129 verify(chartView.axisY().max < yMax);
133 verify(chartView.axisY().max < yMax);
@@ -139,6 +143,7 Rectangle {
139 zoomRect.width = 120;
143 zoomRect.width = 120;
140 zoomRect.height = 120;
144 zoomRect.height = 120;
141 chartView.zoomIn(zoomRect);
145 chartView.zoomIn(zoomRect);
146 verify(chartView.isZoomed());
142 verify(chartView.axisX().max < xMax);
147 verify(chartView.axisX().max < xMax);
143 verify(chartView.axisX().min > xMin);
148 verify(chartView.axisX().min > xMin);
144 verify(chartView.axisY().max < yMax);
149 verify(chartView.axisY().max < yMax);
@@ -150,6 +155,7 Rectangle {
150
155
151 // zoom out
156 // zoom out
152 chartView.zoomOut();
157 chartView.zoomOut();
158 verify(chartView.isZoomed());
153 verify(chartView.axisX().max > xMax);
159 verify(chartView.axisX().max > xMax);
154 verify(chartView.axisX().min < xMin);
160 verify(chartView.axisX().min < xMin);
155 verify(chartView.axisY().max > yMax);
161 verify(chartView.axisY().max > yMax);
@@ -161,6 +167,7 Rectangle {
161
167
162 // zoom reset
168 // zoom reset
163 chartView.zoomReset();
169 chartView.zoomReset();
170 verify(!chartView.isZoomed());
164 verify(chartView.axisX().max === xMaxOriginal);
171 verify(chartView.axisX().max === xMaxOriginal);
165 verify(chartView.axisX().min === xMinOriginal);
172 verify(chartView.axisX().min === xMinOriginal);
166 verify(chartView.axisY().max === yMaxOriginal);
173 verify(chartView.axisY().max === yMaxOriginal);
General Comments 0
You need to be logged in to leave comments. Login now