From 7e0a0b1297ee2d4de750af0c39ec8d421ce4e889 2012-05-23 08:57:20 From: Jani Honkonen Date: 2012-05-23 08:57:20 Subject: [PATCH] pie: make slice added/removed signals public (again) --- diff --git a/src/legend/qlegend.cpp b/src/legend/qlegend.cpp index 1e306f3..033e0c8 100644 --- a/src/legend/qlegend.cpp +++ b/src/legend/qlegend.cpp @@ -415,9 +415,8 @@ void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) if(series->type() == QAbstractSeries::SeriesTypePie) { QPieSeries *pieSeries = static_cast(series); - QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries); - QObject::connect(d, SIGNAL(added(QList)), this, SLOT(handleUpdatePieSeries())); - QObject::connect(d, SIGNAL(removed(QList)), this, SLOT(handleUpdatePieSeries())); + QObject::connect(pieSeries, SIGNAL(added(QList)), this, SLOT(handleUpdatePieSeries())); + QObject::connect(pieSeries, SIGNAL(removed(QList)), this, SLOT(handleUpdatePieSeries())); } updateLayout(); @@ -438,9 +437,8 @@ void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) if(series->type() == QAbstractSeries::SeriesTypePie) { QPieSeries *pieSeries = static_cast(series); - QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries); - QObject::disconnect(d, SIGNAL(added(QList)), this, SLOT(handleUpdatePieSeries())); - QObject::disconnect(d, SIGNAL(removed(QList)), this, SLOT(handleUpdatePieSeries())); + QObject::disconnect(pieSeries, SIGNAL(added(QList)), this, SLOT(handleUpdatePieSeries())); + QObject::disconnect(pieSeries, SIGNAL(removed(QList)), this, SLOT(handleUpdatePieSeries())); } updateLayout(); @@ -449,10 +447,10 @@ void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) void QLegendPrivate::handleUpdatePieSeries() { //TODO: reimplement to be optimal - QPieSeriesPrivate* d = qobject_cast (sender()); - Q_ASSERT(d->q_func()); - handleSeriesRemoved(d->q_func()); - handleSeriesAdded(d->q_func(), 0); + QPieSeries* series = qobject_cast (sender()); + Q_ASSERT(series); + handleSeriesRemoved(series); + handleSeriesAdded(series, 0); } #include "moc_qlegend.cpp" diff --git a/src/piechart/piechartitem.cpp b/src/piechart/piechartitem.cpp index b054007..e206945 100644 --- a/src/piechart/piechartitem.cpp +++ b/src/piechart/piechartitem.cpp @@ -37,9 +37,9 @@ PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter) { Q_ASSERT(series); + connect(series, SIGNAL(added(QList)), this, SLOT(handleSlicesAdded(QList))); + connect(series, SIGNAL(removed(QList)), this, SLOT(handleSlicesRemoved(QList))); QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*series); - connect(d, SIGNAL(added(QList)), this, SLOT(handleSlicesAdded(QList))); - connect(d, SIGNAL(removed(QList)), this, SLOT(handleSlicesRemoved(QList))); connect(d, SIGNAL(piePositionChanged()), this, SLOT(updateLayout())); connect(d, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout())); diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index a25d96f..e5287d7 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -165,7 +165,7 @@ bool QPieSeries::append(QList slices) connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); } - emit d->added(slices); + emit added(slices); return true; } @@ -224,7 +224,7 @@ bool QPieSeries::insert(int index, QPieSlice* slice) connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); - emit d->added(QList() << slice); + emit added(QList() << slice); return true; } @@ -243,7 +243,7 @@ bool QPieSeries::remove(QPieSlice* slice) d->updateDerivativeData(); - emit d->removed(QList() << slice); + emit removed(QList() << slice); delete slice; slice = 0; @@ -268,7 +268,7 @@ void QPieSeries::clear() d->updateDerivativeData(); - emit d->removed(slices); + emit removed(slices); } /*! diff --git a/src/piechart/qpieseries.h b/src/piechart/qpieseries.h index 3c03d0e..d8c2a14 100644 --- a/src/piechart/qpieseries.h +++ b/src/piechart/qpieseries.h @@ -79,6 +79,8 @@ public: QPieModelMapper* modelMapper() const; Q_SIGNALS: + void added(QList slices); + void removed(QList slices); void clicked(QPieSlice* slice); void hovered(QPieSlice* slice, bool state); diff --git a/src/piechart/qpieseries_p.h b/src/piechart/qpieseries_p.h index 96b9f83..157b2f8 100644 --- a/src/piechart/qpieseries_p.h +++ b/src/piechart/qpieseries_p.h @@ -47,8 +47,6 @@ public: static QPieSeriesPrivate* seriesData(QPieSeries &series); Q_SIGNALS: - void added(QList slices); - void removed(QList slices); void piePositionChanged(); void pieSizeChanged();