From 614787b7b70d529cc91b579f069cc6b0bf9a9dc1 2012-05-22 12:40:40 From: Jani Honkonen Date: 2012-05-22 12:40:40 Subject: [PATCH] Bugfix: remove restrictions from pie start & end angles Before it was not possible to start the pie from 9 o'clock for example. --- diff --git a/demos/piechartcustomization/mainwidget.cpp b/demos/piechartcustomization/mainwidget.cpp index b65e862..f66ac57 100644 --- a/demos/piechartcustomization/mainwidget.cpp +++ b/demos/piechartcustomization/mainwidget.cpp @@ -104,14 +104,14 @@ MainWidget::MainWidget(QWidget* parent) m_sizeFactor->setValue(m_series->pieSize()); m_startAngle = new QDoubleSpinBox(); - m_startAngle->setMinimum(0.0); - m_startAngle->setMaximum(360); + m_startAngle->setMinimum(-720); + m_startAngle->setMaximum(720); m_startAngle->setValue(m_series->pieStartAngle()); m_startAngle->setSingleStep(1); m_endAngle = new QDoubleSpinBox(); - m_endAngle->setMinimum(0.0); - m_endAngle->setMaximum(360); + m_endAngle->setMinimum(-720); + m_endAngle->setMaximum(720); m_endAngle->setValue(m_series->pieEndAngle()); m_endAngle->setSingleStep(1); diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index efc3577..a25d96f 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -341,8 +341,10 @@ qreal QPieSeries::pieSize() const void QPieSeries::setPieStartAngle(qreal angle) { Q_D(QPieSeries); - if (d->setRealValue(d->m_pieStartAngle, angle, d->m_pieEndAngle)) - d->updateDerivativeData(); + if (qFuzzyIsNull(d->m_pieStartAngle - angle)) + return; + d->m_pieStartAngle = angle; + d->updateDerivativeData(); } qreal QPieSeries::pieStartAngle() const @@ -363,9 +365,10 @@ qreal QPieSeries::pieStartAngle() const void QPieSeries::setPieEndAngle(qreal angle) { Q_D(QPieSeries); - - if (d->setRealValue(d->m_pieEndAngle, angle, 360.0, d->m_pieStartAngle)) - d->updateDerivativeData(); + if (qFuzzyIsNull(d->m_pieEndAngle - angle)) + return; + d->m_pieEndAngle = angle; + d->updateDerivativeData(); } /*! diff --git a/tests/auto/qpieseries/tst_qpieseries.cpp b/tests/auto/qpieseries/tst_qpieseries.cpp index 7a448bb..3f8dba6 100644 --- a/tests/auto/qpieseries/tst_qpieseries.cpp +++ b/tests/auto/qpieseries/tst_qpieseries.cpp @@ -234,6 +234,13 @@ void tst_qpieseries::calculatedValues() if (!ok) return; + // modify pie angles + s.setPieStartAngle(-90); + s.setPieEndAngle(90); + verifyCalculatedData(s, &ok); + if (!ok) + return; + // clear all s.clear(); verifyCalculatedData(s, &ok);