diff --git a/demos/dynamicspline/chart.cpp b/demos/dynamicspline/chart.cpp index fc50c82..de5bc2d 100644 --- a/demos/dynamicspline/chart.cpp +++ b/demos/dynamicspline/chart.cpp @@ -59,6 +59,6 @@ void Chart::handleTimeout() m_x += m_step; m_y = qrand() % 5 - 2.5; m_series->append(m_x, m_y); - scrollRight(); + scroll(10,0); if(m_x==100) m_timer.stop(); } diff --git a/examples/zoomlinechart/chart.cpp b/examples/zoomlinechart/chart.cpp index 8a013b3..a28e48d 100644 --- a/examples/zoomlinechart/chart.cpp +++ b/examples/zoomlinechart/chart.cpp @@ -49,7 +49,7 @@ bool Chart::gestureEvent(QGestureEvent* event) { if (QGesture *gesture = event->gesture(Qt::PanGesture)) { QPanGesture *pan = static_cast(gesture); - QChart::scroll(pan->delta()); + QChart::scroll(pan->delta().x(),pan->delta().y()); } if (QGesture *gesture = event->gesture(Qt::PinchGesture)) { diff --git a/examples/zoomlinechart/chartview.cpp b/examples/zoomlinechart/chartview.cpp index 79c299e..f154a51 100644 --- a/examples/zoomlinechart/chartview.cpp +++ b/examples/zoomlinechart/chartview.cpp @@ -82,16 +82,16 @@ void ChartView::keyPressEvent(QKeyEvent *event) break; //![1] case Qt::Key_Left: - chart()->scrollLeft(); + chart()->scroll(-10,0); break; case Qt::Key_Right: - chart()->scrollRight(); + chart()->scroll(10,0); break; case Qt::Key_Up: - chart()->scrollUp(); + chart()->scroll(0,10); break; case Qt::Key_Down: - chart()->scrollDown(); + chart()->scroll(0,-10); break; default: QGraphicsView::keyPressEvent(event); diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index 99e5d11..bed8044 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -422,22 +422,22 @@ void DeclarativeChart::zoom(qreal factor) void DeclarativeChart::scrollLeft(qreal pixels) { - m_chart->scroll(QPointF(pixels, 0)); + m_chart->scroll(pixels, 0); } void DeclarativeChart::scrollRight(qreal pixels) { - m_chart->scroll(QPointF(-pixels, 0)); + m_chart->scroll(-pixels, 0); } void DeclarativeChart::scrollUp(qreal pixels) { - m_chart->scroll(QPointF(0, pixels)); + m_chart->scroll(0, pixels); } void DeclarativeChart::scrollDown(qreal pixels) { - m_chart->scroll(QPointF(0, -pixels)); + m_chart->scroll(0, -pixels); } QAbstractSeries *DeclarativeChart::series(int index) diff --git a/src/qabstractseries.cpp b/src/qabstractseries.cpp index 9105aa4..f894523 100644 --- a/src/qabstractseries.cpp +++ b/src/qabstractseries.cpp @@ -153,6 +153,21 @@ QChart* QAbstractSeries::chart() const return d_ptr->m_chart; } +void QAbstractSeries::adjustView() +{ + //TODO: +} + +void QAbstractSeries::show() +{ + setVisible(true); +} + +void QAbstractSeries::hide() +{ + setVisible(false); +} + /////////////////////////////////////////////////////////////////////////////////////////////////// QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries* q): diff --git a/src/qchart.cpp b/src/qchart.cpp index 4911821..a9698a8 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -354,66 +354,11 @@ QChart::AnimationOptions QChart::animationOptions() const } /*! - Scrolls the visible area of the chart to the left by the distance between two x axis ticks - */ -void QChart::scrollLeft(qreal dx) -{ -<<<<<<< Updated upstream -// d_ptr->m_presenter->scroll(-d_ptr->m_presenter->geometry().width()/(axisX()->ticksCount()-1),0); -======= - //TODO: - Q_UNUSED(dx); - // d_ptr->m_presenter->scroll(-d_ptr->m_presenter->geometry().width()/(axisX()->d_ptr->ticksCount()-1),0); ->>>>>>> Stashed changes -} - -/*! - Scrolls the visible area of the chart to the right by the distance between two x axis ticks - */ -void QChart::scrollRight(qreal dx) -{ -<<<<<<< Updated upstream -// d_ptr->m_presenter->scroll(d_ptr->m_presenter->geometry().width()/(axisX()->ticksCount()-1),0); -======= - //TODO: - Q_UNUSED(dx); - // d_ptr->m_presenter->scroll(d_ptr->m_presenter->geometry().width()/(axisX()->ticksCount()-1),0); ->>>>>>> Stashed changes -} - -/*! - Scrolls the visible area of the chart up by the distance between two y axis ticks - */ -void QChart::scrollUp(qreal dy) -{ -<<<<<<< Updated upstream -======= - //TODO: - Q_UNUSED(dy); ->>>>>>> Stashed changes -// d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->geometry().width()/(axisY()->ticksCount()-1)); -} - -/*! - Scrolls the visible area of the chart down by the distance between two y axis ticks - */ -void QChart::scrollDown(qreal dy) -{ -<<<<<<< Updated upstream -// d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->geometry().width()/(axisY()->ticksCount()-1)); -======= - //TODO: - Q_UNUSED(dy); - // d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->geometry().width()/(axisY()->ticksCount()-1)); ->>>>>>> Stashed changes -} - -/*! Scrolls the visible area of the chart by the distance defined in the \a delta. */ -void QChart::scroll(const QPointF &delta) +void QChart::scroll(qreal dx, qreal dy) { - d_ptr->m_presenter->scroll(-delta.x(), delta.y()); + d_ptr->m_presenter->scroll(dx, dy); } void QChart::setBackgroundVisible(bool visible) diff --git a/src/qchart.h b/src/qchart.h index 1b63920..efa9598 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -107,11 +107,7 @@ public: void zoomIn(const QRectF &rect); void zoomOut(); void zoom(qreal factor); - void scrollLeft(qreal dx); - void scrollRight(qreal dx); - void scrollUp(qreal dy); - void scrollDown(qreal dy); - void scroll(const QPointF &delta); + void scroll(qreal dx, qreal dy); void adjustViewToSeries(QAbstractSeries* series= 0); diff --git a/tests/auto/qchart/tst_qchart.cpp b/tests/auto/qchart/tst_qchart.cpp index 34718ed..0723092 100644 --- a/tests/auto/qchart/tst_qchart.cpp +++ b/tests/auto/qchart/tst_qchart.cpp @@ -76,14 +76,8 @@ private slots: void removeAllSeries(); void removeSeries_data(); void removeSeries(); - void scrollDown_data(); - void scrollDown(); - void scrollLeft_data(); - void scrollLeft(); - void scrollRight_data(); - void scrollRight(); - void scrollUp_data(); - void scrollUp(); + void scroll_data(); + void scroll(); void theme_data(); void theme(); void title_data(); @@ -166,10 +160,7 @@ void tst_QChart::qchart() //QCOMPARE(m_chart->titleFont(),QFont()); m_chart->removeAllSeries(); - m_chart->scrollDown(); - m_chart->scrollLeft(); - m_chart->scrollRight(); - m_chart->scrollUp(); + m_chart->scroll(0,0); m_chart->zoomIn(); m_chart->zoomIn(QRectF()); @@ -468,62 +459,20 @@ void tst_QChart::removeSeries() QCOMPARE(deleteSpy.count(), 0); } -void tst_QChart::scrollDown_data() +void tst_QChart::scroll_data() { } -void tst_QChart::scrollDown() +void tst_QChart::scroll() { qFatal("implement me"); createTestData(); //TODO qreal min = m_chart->axisY()->min(); - m_chart->scrollDown(); + m_chart->scroll(0,0); //TODO QVERIFY(m_chart->axisY()->min()axisX()->min(); - m_chart->scrollLeft(); - //TODO QVERIFY(m_chart->axisX()->min()axisX()->min(); - m_chart->scrollRight(); - //TODO QVERIFY(m_chart->axisX()->min()>min); -} - -void tst_QChart::scrollUp_data() -{ - -} - -void tst_QChart::scrollUp() -{ - qFatal("implement me"); - createTestData(); - //TODO qreal min = m_chart->axisY()->min(); - m_chart->scrollUp(); - //TODO QVERIFY(m_chart->axisY()->min()>min); -} - void tst_QChart::theme_data() { QTest::addColumn("theme");