From ea40708618786541ae7c0048c92a7a8cf9095f2f 2012-07-04 13:48:53 From: Michal Klocek Date: 2012-07-04 13:48:53 Subject: [PATCH] Fixes tst_qchartview --- diff --git a/src/axis/qbarcategoriesaxis.cpp b/src/axis/qbarcategoriesaxis.cpp index 9588a96..e3d6119 100644 --- a/src/axis/qbarcategoriesaxis.cpp +++ b/src/axis/qbarcategoriesaxis.cpp @@ -371,10 +371,7 @@ ChartAxis* QBarCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) void QBarCategoriesAxisPrivate::emitRange() { - Q_Q( QBarCategoriesAxis); - if(!q->signalsBlocked()) { - emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); - } + emit changed(m_min -0.5, m_max +0.5, qCeil(m_max + 0.5) -qCeil(m_min - 0.5) +1, false); } diff --git a/src/axis/qvaluesaxis.cpp b/src/axis/qvaluesaxis.cpp index e500182..252c441 100644 --- a/src/axis/qvaluesaxis.cpp +++ b/src/axis/qvaluesaxis.cpp @@ -162,6 +162,7 @@ qreal QValuesAxis::max() const void QValuesAxis::setRange(qreal min, qreal max) { Q_D(QValuesAxis); + bool changed = false; if (!qFuzzyIsNull(d->m_min - min)) { d->m_min = min; @@ -258,6 +259,7 @@ void QValuesAxisPrivate::setMin(const QVariant &min) void QValuesAxisPrivate::setMax(const QVariant &max) { + Q_Q(QValuesAxis); bool ok; qreal value = max.toReal(&ok); @@ -292,10 +294,7 @@ ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) void QValuesAxisPrivate::emitRange() { - Q_Q(QValuesAxis); - if(!q->signalsBlocked()) { - emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); - } + emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); } #include "moc_qvaluesaxis.cpp" diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index 8e80aef..b1e4749 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -261,6 +261,7 @@ void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) { //for performance reasons block, signals and scale "full" domain one by one. Gives twice less screen updates + blockAxisSignals(true); QMapIterator i(m_seriesDomainMap); @@ -293,13 +294,13 @@ void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) void ChartDataSet::blockAxisSignals(bool enabled) { QMapIterator i(m_seriesDomainMap); - +Q_UNUSED(enabled); while (i.hasNext()) { i.next(); QAbstractAxis* axisX = m_seriesAxisXMap.value(i.key()); QAbstractAxis* axisY = m_seriesAxisYMap.value(i.key()); - if(axisX) axisX->blockSignals(enabled); - if(axisY) axisY->blockSignals(enabled); + if(axisX) axisX->d_ptr->blockSignals(true); + if(axisY) axisY->d_ptr->blockSignals(true); } } diff --git a/tests/auto/qchartview/tst_qchartview.cpp b/tests/auto/qchartview/tst_qchartview.cpp index 262e092..4b6924f 100644 --- a/tests/auto/qchartview/tst_qchartview.cpp +++ b/tests/auto/qchartview/tst_qchartview.cpp @@ -23,6 +23,7 @@ #include #include #include +#include QTCOMMERCIALCHART_USE_NAMESPACE @@ -143,6 +144,7 @@ void tst_QChartView::rubberBand() *line << QPointF(0, 0) << QPointF(200, 200); m_view->chart()->addSeries(line); + m_view->chart()->createDefaultAxes(); m_view->resize(200 + padding.left() + padding.right(), 200 + padding.top()+ padding.bottom()); m_view->show(); @@ -166,11 +168,14 @@ void tst_QChartView::rubberBand() //this is hack since view does not get events otherwise m_view->setMouseTracking(false); - //TODO: QVERIFY(axisX->min() - minX < 1); - //TODO: QVERIFY(axisX->max() - maxX < 1); - //TODO: QVERIFY(axisY->min() - minY < 1); - //TODO: QVERIFY(axisY->max() - maxY < 1); - qFatal("implement TODO"); + QValuesAxis* vaxisX = qobject_cast(axisX); + QValuesAxis* vaxisY = qobject_cast(axisY); + + QVERIFY(vaxisX->min() - minX < 1); + QVERIFY(vaxisX->max() - maxX < 1); + QVERIFY(vaxisY->min() - minY < 1); + QVERIFY(vaxisY->max() - maxY < 1); + } QTEST_MAIN(tst_QChartView)