##// END OF EJS Templates
Polish QPieSlice API by removing the DataPtr stuff
Jani Honkonen -
r822:924499b21823
parent child
Show More
@@ -223,7 +223,7 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
223 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
223 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
224
224
225 QPieSlice *s = series->slices().at(i);
225 QPieSlice *s = series->slices().at(i);
226 PieSliceData data = *s->data_ptr();
226 PieSliceData data = PieSliceData::data(s);
227
227
228 if (data.m_slicePen.isThemed() || force) {
228 if (data.m_slicePen.isThemed() || force) {
229 data.m_slicePen = penColor;
229 data.m_slicePen = penColor;
@@ -245,9 +245,9 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
245 data.m_labelFont.setThemed(true);
245 data.m_labelFont.setThemed(true);
246 }
246 }
247
247
248 if (*s->data_ptr() != data) {
248 if (PieSliceData::data(s) != data) {
249 *s->data_ptr() = data;
249 PieSliceData::data(s) = data;
250 emit s->data_ptr()->emitChangedSignal(s);
250 emit PieSliceData::data(s).emitChangedSignal(s);
251 }
251 }
252 }
252 }
253 }
253 }
@@ -147,7 +147,7 void PieChartItem::calculatePieLayout()
147 PieSliceData PieChartItem::sliceData(QPieSlice *slice)
147 PieSliceData PieChartItem::sliceData(QPieSlice *slice)
148 {
148 {
149 // TODO: This function is kid of useless now. Refactor.
149 // TODO: This function is kid of useless now. Refactor.
150 PieSliceData sliceData = *slice->data_ptr();
150 PieSliceData sliceData = PieSliceData::data(slice);
151 sliceData.m_center = PieSliceItem::sliceCenter(m_pieCenter, m_pieRadius, slice);
151 sliceData.m_center = PieSliceItem::sliceCenter(m_pieCenter, m_pieRadius, slice);
152 sliceData.m_radius = m_pieRadius;
152 sliceData.m_radius = m_pieRadius;
153 return sliceData;
153 return sliceData;
@@ -110,6 +110,12 public:
110 emit s->changed();
110 emit s->changed();
111 }
111 }
112
112
113 static PieSliceData &data(QPieSlice *slice)
114 {
115 Q_ASSERT(slice);
116 return *slice->d;
117 }
118
113 qreal m_value;
119 qreal m_value;
114
120
115 Themed<QPen> m_slicePen;
121 Themed<QPen> m_slicePen;
@@ -69,21 +69,21 void QPieSeriesPrivate::updateDerivativeData()
69 QVector<QPieSlice*> changed;
69 QVector<QPieSlice*> changed;
70 foreach (QPieSlice* s, m_slices) {
70 foreach (QPieSlice* s, m_slices) {
71
71
72 PieSliceData data = *s->data_ptr();
72 PieSliceData data = PieSliceData::data(s);
73 data.m_percentage = s->value() / m_total;
73 data.m_percentage = s->value() / m_total;
74 data.m_angleSpan = pieSpan * data.m_percentage;
74 data.m_angleSpan = pieSpan * data.m_percentage;
75 data.m_startAngle = sliceAngle;
75 data.m_startAngle = sliceAngle;
76 sliceAngle += data.m_angleSpan;
76 sliceAngle += data.m_angleSpan;
77
77
78 if (*s->data_ptr() != data) {
78 if (PieSliceData::data(s) != data) {
79 *s->data_ptr() = data;
79 PieSliceData::data(s) = data;
80 changed << s;
80 changed << s;
81 }
81 }
82 }
82 }
83
83
84 // emit signals
84 // emit signals
85 foreach (QPieSlice* s, changed)
85 foreach (QPieSlice* s, changed)
86 s->data_ptr()->emitChangedSignal(s);
86 PieSliceData::data(s).emitChangedSignal(s);
87 }
87 }
88
88
89 void QPieSeriesPrivate::sliceChanged()
89 void QPieSeriesPrivate::sliceChanged()
@@ -80,10 +80,6 private:
80 friend class PieSliceData;
80 friend class PieSliceData;
81 PieSliceData * const d;
81 PieSliceData * const d;
82 Q_DISABLE_COPY(QPieSlice)
82 Q_DISABLE_COPY(QPieSlice)
83
84 public:
85 typedef PieSliceData * const DataPtr;
86 inline DataPtr &data_ptr() { return d; }
87 };
83 };
88
84
89 QTCOMMERCIALCHART_END_NAMESPACE
85 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now