##// END OF EJS Templates
pie: make slice added/removed signals public (again)
Jani Honkonen -
r1213:7e0a0b1297ee
parent child
Show More
@@ -415,9 +415,8 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
415 if(series->type() == QAbstractSeries::SeriesTypePie)
415 if(series->type() == QAbstractSeries::SeriesTypePie)
416 {
416 {
417 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
417 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
418 QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries);
418 QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
419 QObject::connect(d, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
419 QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
420 QObject::connect(d, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
421 }
420 }
422
421
423 updateLayout();
422 updateLayout();
@@ -438,9 +437,8 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
438 if(series->type() == QAbstractSeries::SeriesTypePie)
437 if(series->type() == QAbstractSeries::SeriesTypePie)
439 {
438 {
440 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
439 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
441 QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries);
440 QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
442 QObject::disconnect(d, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
441 QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
443 QObject::disconnect(d, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
444 }
442 }
445
443
446 updateLayout();
444 updateLayout();
@@ -449,10 +447,10 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
449 void QLegendPrivate::handleUpdatePieSeries()
447 void QLegendPrivate::handleUpdatePieSeries()
450 {
448 {
451 //TODO: reimplement to be optimal
449 //TODO: reimplement to be optimal
452 QPieSeriesPrivate* d = qobject_cast<QPieSeriesPrivate *> (sender());
450 QPieSeries* series = qobject_cast<QPieSeries *> (sender());
453 Q_ASSERT(d->q_func());
451 Q_ASSERT(series);
454 handleSeriesRemoved(d->q_func());
452 handleSeriesRemoved(series);
455 handleSeriesAdded(d->q_func(), 0);
453 handleSeriesAdded(series, 0);
456 }
454 }
457
455
458 #include "moc_qlegend.cpp"
456 #include "moc_qlegend.cpp"
@@ -37,9 +37,9 PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter)
37 {
37 {
38 Q_ASSERT(series);
38 Q_ASSERT(series);
39
39
40 connect(series, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>)));
41 connect(series, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>)));
40 QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*series);
42 QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*series);
41 connect(d, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>)));
42 connect(d, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>)));
43 connect(d, SIGNAL(piePositionChanged()), this, SLOT(updateLayout()));
43 connect(d, SIGNAL(piePositionChanged()), this, SLOT(updateLayout()));
44 connect(d, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout()));
44 connect(d, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout()));
45
45
@@ -165,7 +165,7 bool QPieSeries::append(QList<QPieSlice*> slices)
165 connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
165 connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
166 }
166 }
167
167
168 emit d->added(slices);
168 emit added(slices);
169
169
170 return true;
170 return true;
171 }
171 }
@@ -224,7 +224,7 bool QPieSeries::insert(int index, QPieSlice* slice)
224 connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked()));
224 connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked()));
225 connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
225 connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool)));
226
226
227 emit d->added(QList<QPieSlice*>() << slice);
227 emit added(QList<QPieSlice*>() << slice);
228
228
229 return true;
229 return true;
230 }
230 }
@@ -243,7 +243,7 bool QPieSeries::remove(QPieSlice* slice)
243
243
244 d->updateDerivativeData();
244 d->updateDerivativeData();
245
245
246 emit d->removed(QList<QPieSlice*>() << slice);
246 emit removed(QList<QPieSlice*>() << slice);
247
247
248 delete slice;
248 delete slice;
249 slice = 0;
249 slice = 0;
@@ -268,7 +268,7 void QPieSeries::clear()
268
268
269 d->updateDerivativeData();
269 d->updateDerivativeData();
270
270
271 emit d->removed(slices);
271 emit removed(slices);
272 }
272 }
273
273
274 /*!
274 /*!
@@ -79,6 +79,8 public:
79 QPieModelMapper* modelMapper() const;
79 QPieModelMapper* modelMapper() const;
80
80
81 Q_SIGNALS:
81 Q_SIGNALS:
82 void added(QList<QPieSlice*> slices);
83 void removed(QList<QPieSlice*> slices);
82 void clicked(QPieSlice* slice);
84 void clicked(QPieSlice* slice);
83 void hovered(QPieSlice* slice, bool state);
85 void hovered(QPieSlice* slice, bool state);
84
86
@@ -47,8 +47,6 public:
47 static QPieSeriesPrivate* seriesData(QPieSeries &series);
47 static QPieSeriesPrivate* seriesData(QPieSeries &series);
48
48
49 Q_SIGNALS:
49 Q_SIGNALS:
50 void added(QList<QPieSlice*> slices);
51 void removed(QList<QPieSlice*> slices);
52 void piePositionChanged();
50 void piePositionChanged();
53 void pieSizeChanged();
51 void pieSizeChanged();
54
52
General Comments 0
You need to be logged in to leave comments. Login now