From 5883c94a00fe464e14aa0979e417ff7f2f7524fb 2012-05-29 08:30:00 From: Marek Rosa Date: 2012-05-29 08:30:00 Subject: [PATCH] Fixed spline's broken signals --- diff --git a/src/splinechart/qsplineseries.cpp b/src/splinechart/qsplineseries.cpp index 78cb91d..1ef5ce7 100644 --- a/src/splinechart/qsplineseries.cpp +++ b/src/splinechart/qsplineseries.cpp @@ -59,6 +59,10 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE QSplineSeries::QSplineSeries(QObject *parent) : QLineSeries(*new QSplineSeriesPrivate(this),parent) { + Q_D(QSplineSeries); + QObject::connect(this,SIGNAL(pointAdded(int)), d, SLOT(updateControlPoints())); + QObject::connect(this,SIGNAL(pointRemoved(int)), d, SLOT(updateControlPoints())); + QObject::connect(this,SIGNAL(pointReplaced(int)), d, SLOT(updateControlPoints())); } QSplineSeries::~QSplineSeries() @@ -78,9 +82,9 @@ QAbstractSeries::SeriesType QSplineSeries::type() const QSplineSeriesPrivate::QSplineSeriesPrivate(QSplineSeries* q):QLineSeriesPrivate(q) { - QObject::connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); - QObject::connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); - QObject::connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); +// QObject::connect(this,SIGNAL(pointAdded(int)), this, SLOT(updateControlPoints())); +// QObject::connect(this,SIGNAL(pointRemoved(int)), this, SLOT(updateControlPoints())); +// QObject::connect(this,SIGNAL(pointReplaced(int)), this, SLOT(updateControlPoints())); }; /*! diff --git a/tests/tablemodelchart/tablewidget.cpp b/tests/tablemodelchart/tablewidget.cpp index 7e525cc..124507e 100644 --- a/tests/tablemodelchart/tablewidget.cpp +++ b/tests/tablemodelchart/tablewidget.cpp @@ -210,7 +210,7 @@ void TableWidget::updateChartType(bool toggle) if (m_lineRadioButton->isChecked()) { - m_chart->setAnimationOptions(QChart::NoAnimation); + m_chart->setAnimationOptions(QChart::NoAnimation); // series 1 m_series = new QLineSeries(this); @@ -221,7 +221,7 @@ void TableWidget::updateChartType(bool toggle) mapper->setXColumn(0); mapper->setYColumn(1); mapper->setFirst(3); - mapper->setCount(4); + mapper->setCount(4); // m_series->setModelMapping(0,1, Qt::Vertical); // m_series->setModelMappingRange(3, 4); @@ -262,23 +262,25 @@ void TableWidget::updateChartType(bool toggle) } else if (m_splineRadioButton->isChecked()) { - // m_chart->setAnimationOptions(QChart::NoAnimation); + m_chart->setAnimationOptions(QChart::NoAnimation); - // // series 1 - // m_series = new QSplineSeries; - // m_series->setModel(m_model); + // series 1 + m_series = new QSplineSeries; +// m_series->setModel(m_model); - // QXYModelMapper *mapper = new QXYModelMapper; - // mapper->setMapX(0); - // mapper->setMapY(1); - // mapper->setFirst(0); - // mapper->setCount(-1); + QVXYModelMapper *mapper = new QVXYModelMapper; + mapper->setSeries(m_series); + mapper->setModel(m_model); + mapper->setXColumn(0); + mapper->setYColumn(1); + mapper->setFirst(0); + mapper->setCount(-1); - // m_series->setModelMapper(mapper); +// m_series->setModelMapper(mapper); - // m_chart->addSeries(m_series); - // seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); - // m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); + m_chart->addSeries(m_series); + seriesColorHex = "#" + QString::number(m_series->pen().color().rgb(), 16).right(6).toUpper(); + m_model->addMapping(seriesColorHex, QRect(0, 0, 2, 1000)); // // series 2 // m_series = new QSplineSeries; @@ -524,9 +526,9 @@ void TableWidget::testPie3() void TableWidget::testXY() { -// if (m_series->type() != QAbstractSeries::SeriesTypeLine) { -// m_series->append(QPointF(150, 75)); -// } + // if (m_series->type() != QAbstractSeries::SeriesTypeLine) { + // m_series->append(QPointF(150, 75)); + // } if (m_series->count() > 0) { m_series->remove(m_series->points().last());