@@ -1,660 +1,693 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qpieseries.h" |
|
21 | #include "qpieseries.h" | |
22 | #include "qpiesliceprivate_p.h" |
|
22 | #include "qpiesliceprivate_p.h" | |
23 | #include "qpieseriesprivate_p.h" |
|
23 | #include "qpieseriesprivate_p.h" | |
24 | #include <QDebug> |
|
24 | #include <QDebug> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) |
|
28 | QPieSeriesPrivate::QPieSeriesPrivate(QPieSeries *parent) | |
29 | :QObject(parent), |
|
29 | :QObject(parent), | |
30 | q_ptr(parent), |
|
30 | q_ptr(parent), | |
31 | m_pieRelativeHorPos(0.5), |
|
31 | m_pieRelativeHorPos(0.5), | |
32 | m_pieRelativeVerPos(0.5), |
|
32 | m_pieRelativeVerPos(0.5), | |
33 | m_pieRelativeSize(0.7), |
|
33 | m_pieRelativeSize(0.7), | |
34 | m_pieStartAngle(0), |
|
34 | m_pieStartAngle(0), | |
35 | m_pieEndAngle(360), |
|
35 | m_pieEndAngle(360), | |
36 | m_total(0), |
|
36 | m_total(0), | |
37 | m_mapValues(0), |
|
37 | m_mapValues(0), | |
38 | m_mapLabels(0), |
|
38 | m_mapLabels(0), | |
39 | m_mapOrientation(Qt::Horizontal) |
|
39 | m_mapOrientation(Qt::Horizontal) | |
40 | { |
|
40 | { | |
41 |
|
41 | |||
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | QPieSeriesPrivate::~QPieSeriesPrivate() |
|
44 | QPieSeriesPrivate::~QPieSeriesPrivate() | |
45 | { |
|
45 | { | |
46 |
|
46 | |||
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | void QPieSeriesPrivate::updateDerivativeData() |
|
49 | void QPieSeriesPrivate::updateDerivativeData() | |
50 | { |
|
50 | { | |
51 | m_total = 0; |
|
51 | m_total = 0; | |
52 |
|
52 | |||
53 | // nothing to do? |
|
53 | // nothing to do? | |
54 | if (m_slices.count() == 0) |
|
54 | if (m_slices.count() == 0) | |
55 | return; |
|
55 | return; | |
56 |
|
56 | |||
57 | // calculate total |
|
57 | // calculate total | |
58 | foreach (QPieSlice* s, m_slices) |
|
58 | foreach (QPieSlice* s, m_slices) | |
59 | m_total += s->value(); |
|
59 | m_total += s->value(); | |
60 |
|
60 | |||
61 | // nothing to show.. |
|
61 | // nothing to show.. | |
62 | if (qFuzzyIsNull(m_total)) |
|
62 | if (qFuzzyIsNull(m_total)) | |
63 | return; |
|
63 | return; | |
64 |
|
64 | |||
65 | // update slice attributes |
|
65 | // update slice attributes | |
66 | qreal sliceAngle = m_pieStartAngle; |
|
66 | qreal sliceAngle = m_pieStartAngle; | |
67 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; |
|
67 | qreal pieSpan = m_pieEndAngle - m_pieStartAngle; | |
68 | QVector<QPieSlice*> changed; |
|
68 | QVector<QPieSlice*> changed; | |
69 | foreach (QPieSlice* s, m_slices) { |
|
69 | foreach (QPieSlice* s, m_slices) { | |
70 |
|
70 | |||
71 | PieSliceData data = s->data_ptr()->m_data; |
|
71 | PieSliceData data = s->data_ptr()->m_data; | |
72 | data.m_percentage = s->value() / m_total; |
|
72 | data.m_percentage = s->value() / m_total; | |
73 | data.m_angleSpan = pieSpan * data.m_percentage; |
|
73 | data.m_angleSpan = pieSpan * data.m_percentage; | |
74 | data.m_startAngle = sliceAngle; |
|
74 | data.m_startAngle = sliceAngle; | |
75 | sliceAngle += data.m_angleSpan; |
|
75 | sliceAngle += data.m_angleSpan; | |
76 |
|
76 | |||
77 | if (s->data_ptr()->m_data != data) { |
|
77 | if (s->data_ptr()->m_data != data) { | |
78 | s->data_ptr()->m_data = data; |
|
78 | s->data_ptr()->m_data = data; | |
79 | changed << s; |
|
79 | changed << s; | |
80 | } |
|
80 | } | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | // emit signals |
|
83 | // emit signals | |
84 | foreach (QPieSlice* s, changed) |
|
84 | foreach (QPieSlice* s, changed) | |
85 | emit s->data_ptr()->changed(); |
|
85 | emit s->data_ptr()->changed(); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void QPieSeriesPrivate::sliceChanged() |
|
88 | void QPieSeriesPrivate::sliceChanged() | |
89 | { |
|
89 | { | |
90 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); |
|
90 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
91 | updateDerivativeData(); |
|
91 | updateDerivativeData(); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | void QPieSeriesPrivate::sliceClicked(Qt::MouseButtons buttons) |
|
94 | void QPieSeriesPrivate::sliceClicked(Qt::MouseButtons buttons) | |
95 | { |
|
95 | { | |
96 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
96 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
97 | Q_ASSERT(m_slices.contains(slice)); |
|
97 | Q_ASSERT(m_slices.contains(slice)); | |
98 | Q_Q(QPieSeries); |
|
98 | Q_Q(QPieSeries); | |
99 | emit q->clicked(slice, buttons); |
|
99 | emit q->clicked(slice, buttons); | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | void QPieSeriesPrivate::sliceHoverEnter() |
|
102 | void QPieSeriesPrivate::sliceHoverEnter() | |
103 | { |
|
103 | { | |
104 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
104 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
105 | Q_ASSERT(m_slices.contains(slice)); |
|
105 | Q_ASSERT(m_slices.contains(slice)); | |
106 | Q_Q(QPieSeries); |
|
106 | Q_Q(QPieSeries); | |
107 | emit q->hoverEnter(slice); |
|
107 | emit q->hoverEnter(slice); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | void QPieSeriesPrivate::sliceHoverLeave() |
|
110 | void QPieSeriesPrivate::sliceHoverLeave() | |
111 | { |
|
111 | { | |
112 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
112 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); | |
113 | Q_ASSERT(m_slices.contains(slice)); |
|
113 | Q_ASSERT(m_slices.contains(slice)); | |
114 | Q_Q(QPieSeries); |
|
114 | Q_Q(QPieSeries); | |
115 | emit q->hoverLeave(slice); |
|
115 | emit q->hoverLeave(slice); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
|
118 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) | |
119 | { |
|
119 | { | |
120 | Q_UNUSED(bottomRight) |
|
120 | Q_UNUSED(bottomRight) | |
121 | Q_Q(QPieSeries); |
|
121 | Q_Q(QPieSeries); | |
122 |
|
122 | |||
123 | if (m_mapOrientation == Qt::Vertical) |
|
123 | if (m_mapOrientation == Qt::Vertical) | |
124 | { |
|
124 | { | |
125 | // slices().at(topLeft.row())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); |
|
125 | // slices().at(topLeft.row())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); | |
126 | if (topLeft.column() == m_mapValues) |
|
126 | if (topLeft.column() == m_mapValues) | |
127 | if (m_mapValues == m_mapLabels) |
|
127 | if (m_mapValues == m_mapLabels) | |
128 | { |
|
128 | { | |
129 | m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
129 | m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
130 | m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
130 | m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); | |
131 | } |
|
131 | } | |
132 | else |
|
132 | else | |
133 | { |
|
133 | { | |
134 | m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
134 | m_slices.at(topLeft.row())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
135 | } |
|
135 | } | |
136 | else if (topLeft.column() == m_mapLabels) |
|
136 | else if (topLeft.column() == m_mapLabels) | |
137 | m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
137 | m_slices.at(topLeft.row())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); | |
138 | } |
|
138 | } | |
139 | else |
|
139 | else | |
140 | { |
|
140 | { | |
141 | // slices().at(topLeft.column())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); |
|
141 | // slices().at(topLeft.column())->setValue(m_model->data(m_model->index(topLeft.row(), topLeft.column()), Qt::DisplayRole).toDouble()); | |
142 | if (topLeft.row() == m_mapValues) |
|
142 | if (topLeft.row() == m_mapValues) | |
143 | if (m_mapValues == m_mapLabels) |
|
143 | if (m_mapValues == m_mapLabels) | |
144 | { |
|
144 | { | |
145 | m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
145 | m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
146 | m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
146 | m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); | |
147 | } |
|
147 | } | |
148 | else |
|
148 | else | |
149 | { |
|
149 | { | |
150 | m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); |
|
150 | m_slices.at(topLeft.column())->setValue(q->m_model->data(topLeft, Qt::DisplayRole).toDouble()); | |
151 | } |
|
151 | } | |
152 | else if (topLeft.row() == m_mapLabels) |
|
152 | else if (topLeft.row() == m_mapLabels) | |
153 | m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); |
|
153 | m_slices.at(topLeft.column())->setLabel(q->m_model->data(topLeft, Qt::DisplayRole).toString()); | |
154 | } |
|
154 | } | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
157 | void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end) |
|
157 | void QPieSeriesPrivate::modelDataAdded(QModelIndex parent, int start, int end) | |
158 | { |
|
158 | { | |
159 | Q_UNUSED(parent) |
|
159 | Q_UNUSED(parent) | |
160 | Q_UNUSED(end) |
|
160 | Q_UNUSED(end) | |
161 | Q_Q(QPieSeries); |
|
161 | Q_Q(QPieSeries); | |
162 |
|
162 | |||
163 | QPieSlice* newSlice = new QPieSlice; |
|
163 | QPieSlice* newSlice = new QPieSlice; | |
164 | newSlice->setLabelVisible(true); |
|
164 | newSlice->setLabelVisible(true); | |
165 | if (m_mapOrientation == Qt::Vertical) |
|
165 | if (m_mapOrientation == Qt::Vertical) | |
166 | { |
|
166 | { | |
167 | newSlice->setValue(q->m_model->data(q->m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble()); |
|
167 | newSlice->setValue(q->m_model->data(q->m_model->index(start, m_mapValues), Qt::DisplayRole).toDouble()); | |
168 | newSlice->setLabel(q->m_model->data(q->m_model->index(start, m_mapLabels), Qt::DisplayRole).toString()); |
|
168 | newSlice->setLabel(q->m_model->data(q->m_model->index(start, m_mapLabels), Qt::DisplayRole).toString()); | |
169 | } |
|
169 | } | |
170 | else |
|
170 | else | |
171 | { |
|
171 | { | |
172 | newSlice->setValue(q->m_model->data(q->m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble()); |
|
172 | newSlice->setValue(q->m_model->data(q->m_model->index(m_mapValues, start), Qt::DisplayRole).toDouble()); | |
173 | newSlice->setLabel(q->m_model->data(q->m_model->index(m_mapLabels, start), Qt::DisplayRole).toString()); |
|
173 | newSlice->setLabel(q->m_model->data(q->m_model->index(m_mapLabels, start), Qt::DisplayRole).toString()); | |
174 | } |
|
174 | } | |
175 |
|
175 | |||
176 | q->insert(start, newSlice); |
|
176 | q->insert(start, newSlice); | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) |
|
179 | void QPieSeriesPrivate::modelDataRemoved(QModelIndex parent, int start, int end) | |
180 | { |
|
180 | { | |
181 | Q_UNUSED(parent) |
|
181 | Q_UNUSED(parent) | |
182 | Q_UNUSED(end) |
|
182 | Q_UNUSED(end) | |
183 | Q_Q(QPieSeries); |
|
183 | Q_Q(QPieSeries); | |
184 | q->remove(m_slices.at(start)); |
|
184 | q->remove(m_slices.at(start)); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 |
|
187 | |||
188 |
|
188 | |||
189 | /*! |
|
189 | /*! | |
190 | \class QPieSeries |
|
190 | \class QPieSeries | |
191 | \brief Pie series API for QtCommercial Charts |
|
191 | \brief Pie series API for QtCommercial Charts | |
192 |
|
192 | |||
193 | The pie series defines a pie chart which consists of pie slices which are QPieSlice objects. |
|
193 | The pie series defines a pie chart which consists of pie slices which are QPieSlice objects. | |
194 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. |
|
194 | The slices can have any values as the QPieSeries will calculate its relative value to the sum of all slices. | |
195 | The actual slice size is determined by that relative value. |
|
195 | The actual slice size is determined by that relative value. | |
196 |
|
196 | |||
197 | By default the pie is defined as a full pie but it can be a partial pie. |
|
197 | By default the pie is defined as a full pie but it can be a partial pie. | |
198 | This can be done by setting a starting angle and angle span to the series. |
|
198 | This can be done by setting a starting angle and angle span to the series. | |
199 | */ |
|
199 | */ | |
200 |
|
200 | |||
201 | /*! |
|
201 | /*! | |
202 | Constructs a series object which is a child of \a parent. |
|
202 | Constructs a series object which is a child of \a parent. | |
203 | */ |
|
203 | */ | |
204 | QPieSeries::QPieSeries(QObject *parent) : |
|
204 | QPieSeries::QPieSeries(QObject *parent) : | |
205 | QSeries(parent), |
|
205 | QSeries(parent), | |
206 | d_ptr(new QPieSeriesPrivate(this)) |
|
206 | d_ptr(new QPieSeriesPrivate(this)) | |
207 | { |
|
207 | { | |
208 |
|
208 | |||
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
212 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |
213 | */ |
|
213 | */ | |
214 | QPieSeries::~QPieSeries() |
|
214 | QPieSeries::~QPieSeries() | |
215 | { |
|
215 | { | |
216 | // NOTE: d_prt destroyed by QObject |
|
216 | // NOTE: d_prt destroyed by QObject | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | Returns QChartSeries::SeriesTypePie. |
|
220 | Returns QChartSeries::SeriesTypePie. | |
221 | */ |
|
221 | */ | |
222 | QSeries::QSeriesType QPieSeries::type() const |
|
222 | QSeries::QSeriesType QPieSeries::type() const | |
223 | { |
|
223 | { | |
224 | return QSeries::SeriesTypePie; |
|
224 | return QSeries::SeriesTypePie; | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | /*! |
|
227 | /*! | |
228 | Sets an array of \a slices to the series replacing the existing slices. |
|
228 | Sets an array of \a slices to the series replacing the existing slices. | |
229 | Slice ownership is passed to the series. |
|
229 | Slice ownership is passed to the series. | |
230 | */ |
|
230 | */ | |
231 | void QPieSeries::replace(QList<QPieSlice*> slices) |
|
231 | void QPieSeries::replace(QList<QPieSlice*> slices) | |
232 | { |
|
232 | { | |
233 | clear(); |
|
233 | clear(); | |
234 | append(slices); |
|
234 | append(slices); | |
235 | } |
|
235 | } | |
236 |
|
236 | |||
237 | /*! |
|
237 | /*! | |
238 | Adds an array of \a slices to the series. |
|
238 | Adds an array of \a slices to the series. | |
239 | Slice ownership is passed to the series. |
|
239 | Slice ownership is passed to the series. | |
240 | */ |
|
240 | */ | |
241 | void QPieSeries::append(QList<QPieSlice*> slices) |
|
241 | void QPieSeries::append(QList<QPieSlice*> slices) | |
242 | { |
|
242 | { | |
243 | Q_D(QPieSeries); |
|
243 | Q_D(QPieSeries); | |
244 |
|
244 | |||
245 | foreach (QPieSlice* s, slices) { |
|
245 | foreach (QPieSlice* s, slices) { | |
246 | s->setParent(this); |
|
246 | s->setParent(this); | |
247 | d->m_slices << s; |
|
247 | d->m_slices << s; | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | d->updateDerivativeData(); |
|
250 | d->updateDerivativeData(); | |
251 |
|
251 | |||
252 | foreach (QPieSlice* s, slices) { |
|
252 | foreach (QPieSlice* s, slices) { | |
253 | connect(s, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
253 | connect(s, SIGNAL(changed()), d, SLOT(sliceChanged())); | |
254 | connect(s, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); |
|
254 | connect(s, SIGNAL(clicked(Qt::MouseButtons)), d, SLOT(sliceClicked(Qt::MouseButtons))); | |
255 | connect(s, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); |
|
255 | connect(s, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); | |
256 | connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); |
|
256 | connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
257 | } |
|
257 | } | |
258 |
|
258 | |||
259 | emit added(slices); |
|
259 | emit added(slices); | |
260 | } |
|
260 | } | |
261 |
|
261 | |||
262 | /*! |
|
262 | /*! | |
263 | Adds a single \a slice to the series. |
|
263 | Adds a single \a slice to the series. | |
264 | Slice ownership is passed to the series. |
|
264 | Slice ownership is passed to the series. | |
265 | */ |
|
265 | */ | |
266 | void QPieSeries::append(QPieSlice* slice) |
|
266 | void QPieSeries::append(QPieSlice* slice) | |
267 | { |
|
267 | { | |
268 | append(QList<QPieSlice*>() << slice); |
|
268 | append(QList<QPieSlice*>() << slice); | |
269 | } |
|
269 | } | |
270 |
|
270 | |||
271 | /*! |
|
271 | /*! | |
272 | Adds a single \a slice to the series and returns a reference to the series. |
|
272 | Adds a single \a slice to the series and returns a reference to the series. | |
273 | Slice ownership is passed to the series. |
|
273 | Slice ownership is passed to the series. | |
274 | */ |
|
274 | */ | |
275 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) |
|
275 | QPieSeries& QPieSeries::operator << (QPieSlice* slice) | |
276 | { |
|
276 | { | |
277 | append(slice); |
|
277 | append(slice); | |
278 | return *this; |
|
278 | return *this; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 |
|
281 | |||
282 | /*! |
|
282 | /*! | |
283 |
A |
|
283 | Appends a single slice to the series with give \a value and \a name. | |
284 | Slice ownership is passed to the series. |
|
284 | Slice ownership is passed to the series. | |
285 | */ |
|
285 | */ | |
286 | QPieSlice* QPieSeries::append(qreal value, QString name) |
|
286 | QPieSlice* QPieSeries::append(qreal value, QString name) | |
287 | { |
|
287 | { | |
288 | QPieSlice* slice = new QPieSlice(value, name); |
|
288 | QPieSlice* slice = new QPieSlice(value, name); | |
289 | append(slice); |
|
289 | append(slice); | |
290 | return slice; |
|
290 | return slice; | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | void QPieSeries::insert(int i, QPieSlice* slice) |
|
293 | /*! | |
|
294 | Inserts a single \a slice to the series before the slice at \a index position. | |||
|
295 | Slice ownership is passed to the series. | |||
|
296 | */ | |||
|
297 | void QPieSeries::insert(int index, QPieSlice* slice) | |||
294 | { |
|
298 | { | |
295 | Q_D(QPieSeries); |
|
299 | Q_D(QPieSeries); | |
296 | Q_ASSERT(i <= d->m_slices.count()); |
|
300 | Q_ASSERT(index <= d->m_slices.count()); | |
297 | slice->setParent(this); |
|
301 | slice->setParent(this); | |
298 | d->m_slices.insert(i, slice); |
|
302 | d->m_slices.insert(index, slice); | |
299 |
|
303 | |||
300 | d->updateDerivativeData(); |
|
304 | d->updateDerivativeData(); | |
301 |
|
305 | |||
302 | connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
306 | connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged())); | |
303 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); |
|
307 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
304 | connect(slice, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); |
|
308 | connect(slice, SIGNAL(hoverEnter()), d, SLOT(sliceHoverEnter())); | |
305 | connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); |
|
309 | connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
306 |
|
310 | |||
307 | emit added(QList<QPieSlice*>() << slice); |
|
311 | emit added(QList<QPieSlice*>() << slice); | |
308 | } |
|
312 | } | |
309 |
|
313 | |||
310 | /*! |
|
314 | /*! | |
311 | Removes a single \a slice from the series and deletes the slice. |
|
315 | Removes a single \a slice from the series and deletes the slice. | |
312 |
|
316 | |||
313 | Do not reference this pointer after this call. |
|
317 | Do not reference this pointer after this call. | |
314 | */ |
|
318 | */ | |
315 | void QPieSeries::remove(QPieSlice* slice) |
|
319 | void QPieSeries::remove(QPieSlice* slice) | |
316 | { |
|
320 | { | |
317 | Q_D(QPieSeries); |
|
321 | Q_D(QPieSeries); | |
318 | if (!d->m_slices.removeOne(slice)) { |
|
322 | if (!d->m_slices.removeOne(slice)) { | |
319 | Q_ASSERT(0); // TODO: how should this be reported? |
|
323 | Q_ASSERT(0); // TODO: how should this be reported? | |
320 | return; |
|
324 | return; | |
321 | } |
|
325 | } | |
322 |
|
326 | |||
323 | d->updateDerivativeData(); |
|
327 | d->updateDerivativeData(); | |
324 |
|
328 | |||
325 | emit removed(QList<QPieSlice*>() << slice); |
|
329 | emit removed(QList<QPieSlice*>() << slice); | |
326 |
|
330 | |||
327 | delete slice; |
|
331 | delete slice; | |
328 | slice = NULL; |
|
332 | slice = NULL; | |
329 | } |
|
333 | } | |
330 |
|
334 | |||
331 | /*! |
|
335 | /*! | |
332 | Clears all slices from the series. |
|
336 | Clears all slices from the series. | |
333 | */ |
|
337 | */ | |
334 | void QPieSeries::clear() |
|
338 | void QPieSeries::clear() | |
335 | { |
|
339 | { | |
336 | Q_D(QPieSeries); |
|
340 | Q_D(QPieSeries); | |
337 | if (d->m_slices.count() == 0) |
|
341 | if (d->m_slices.count() == 0) | |
338 | return; |
|
342 | return; | |
339 |
|
343 | |||
340 | QList<QPieSlice*> slices = d->m_slices; |
|
344 | QList<QPieSlice*> slices = d->m_slices; | |
341 | foreach (QPieSlice* s, d->m_slices) { |
|
345 | foreach (QPieSlice* s, d->m_slices) { | |
342 | d->m_slices.removeOne(s); |
|
346 | d->m_slices.removeOne(s); | |
343 | delete s; |
|
347 | delete s; | |
344 | } |
|
348 | } | |
345 |
|
349 | |||
346 | d->updateDerivativeData(); |
|
350 | d->updateDerivativeData(); | |
347 |
|
351 | |||
348 | emit removed(slices); |
|
352 | emit removed(slices); | |
349 | } |
|
353 | } | |
350 |
|
354 | |||
351 | /*! |
|
355 | /*! | |
352 | Counts the number of the slices in this series. |
|
356 | Counts the number of the slices in this series. | |
353 | */ |
|
357 | */ | |
354 | int QPieSeries::count() const |
|
358 | int QPieSeries::count() const | |
355 | { |
|
359 | { | |
356 | Q_D(const QPieSeries); |
|
360 | Q_D(const QPieSeries); | |
357 | return d->m_slices.count(); |
|
361 | return d->m_slices.count(); | |
358 | } |
|
362 | } | |
359 |
|
363 | |||
360 | /*! |
|
364 | /*! | |
361 | Returns true is the series is empty. |
|
365 | Returns true is the series is empty. | |
362 | */ |
|
366 | */ | |
363 | bool QPieSeries::isEmpty() const |
|
367 | bool QPieSeries::isEmpty() const | |
364 | { |
|
368 | { | |
365 | Q_D(const QPieSeries); |
|
369 | Q_D(const QPieSeries); | |
366 | return d->m_slices.isEmpty(); |
|
370 | return d->m_slices.isEmpty(); | |
367 | } |
|
371 | } | |
368 |
|
372 | |||
369 | /*! |
|
373 | /*! | |
370 | Returns a list of slices that belong to this series. |
|
374 | Returns a list of slices that belong to this series. | |
371 | */ |
|
375 | */ | |
372 | QList<QPieSlice*> QPieSeries::slices() const |
|
376 | QList<QPieSlice*> QPieSeries::slices() const | |
373 | { |
|
377 | { | |
374 | Q_D(const QPieSeries); |
|
378 | Q_D(const QPieSeries); | |
375 | return d->m_slices; |
|
379 | return d->m_slices; | |
376 | } |
|
380 | } | |
377 |
|
381 | |||
378 | /*! |
|
382 | /*! | |
379 | Sets the center position of the pie by \a relativeHorizontalPosition and \a relativeVerticalPosition. |
|
383 | Sets the center position of the pie by \a relativeHorizontalPosition and \a relativeVerticalPosition. | |
380 |
|
384 | |||
381 | The factors are relative to the chart rectangle where: |
|
385 | The factors are relative to the chart rectangle where: | |
382 |
|
386 | |||
383 | \a relativeHorizontalPosition 0.0 means the absolute left. |
|
387 | \a relativeHorizontalPosition 0.0 means the absolute left. | |
384 | \a relativeHorizontalPosition 1.0 means the absolute right. |
|
388 | \a relativeHorizontalPosition 1.0 means the absolute right. | |
385 | \a relativeVerticalPosition 0.0 means the absolute top. |
|
389 | \a relativeVerticalPosition 0.0 means the absolute top. | |
386 | \a relativeVerticalPosition 1.0 means the absolute bottom. |
|
390 | \a relativeVerticalPosition 1.0 means the absolute bottom. | |
387 |
|
391 | |||
388 | By default both values are 0.5 which puts the pie in the middle of the chart rectangle. |
|
392 | By default both values are 0.5 which puts the pie in the middle of the chart rectangle. | |
389 |
|
393 | |||
390 | \sa pieHorizontalPosition(), pieVerticalPosition(), setPieSize() |
|
394 | \sa pieHorizontalPosition(), pieVerticalPosition(), setPieSize() | |
391 | */ |
|
395 | */ | |
392 | void QPieSeries::setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition) |
|
396 | void QPieSeries::setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition) | |
393 | { |
|
397 | { | |
394 | Q_D(QPieSeries); |
|
398 | Q_D(QPieSeries); | |
395 | if (relativeHorizontalPosition < 0.0 || relativeHorizontalPosition > 1.0 || |
|
399 | if (relativeHorizontalPosition < 0.0 || relativeHorizontalPosition > 1.0 || | |
396 | relativeVerticalPosition < 0.0 || relativeVerticalPosition > 1.0) |
|
400 | relativeVerticalPosition < 0.0 || relativeVerticalPosition > 1.0) | |
397 | return; |
|
401 | return; | |
398 |
|
402 | |||
399 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativeHorizontalPosition) || |
|
403 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativeHorizontalPosition) || | |
400 | !qFuzzyIsNull(d->m_pieRelativeVerPos - relativeVerticalPosition)) { |
|
404 | !qFuzzyIsNull(d->m_pieRelativeVerPos - relativeVerticalPosition)) { | |
401 | d->m_pieRelativeHorPos = relativeHorizontalPosition; |
|
405 | d->m_pieRelativeHorPos = relativeHorizontalPosition; | |
402 | d->m_pieRelativeVerPos = relativeVerticalPosition; |
|
406 | d->m_pieRelativeVerPos = relativeVerticalPosition; | |
403 | emit piePositionChanged(); |
|
407 | emit piePositionChanged(); | |
404 | } |
|
408 | } | |
405 | } |
|
409 | } | |
406 |
|
410 | |||
407 | /*! |
|
411 | /*! | |
408 | Gets the horizontal position of the pie. |
|
412 | Gets the horizontal position of the pie. | |
409 |
|
413 | |||
410 | The returned value is relative to the chart rectangle where: |
|
414 | The returned value is relative to the chart rectangle where: | |
411 |
|
415 | |||
412 | 0.0 means the absolute left. |
|
416 | 0.0 means the absolute left. | |
413 | 1.0 means the absolute right. |
|
417 | 1.0 means the absolute right. | |
414 |
|
418 | |||
415 | By default it is 0.5 which puts the pie in the horizontal middle of the chart rectangle. |
|
419 | By default it is 0.5 which puts the pie in the horizontal middle of the chart rectangle. | |
416 |
|
420 | |||
417 | \sa setPiePosition(), pieVerticalPosition(), setPieSize() |
|
421 | \sa setPiePosition(), pieVerticalPosition(), setPieSize() | |
418 | */ |
|
422 | */ | |
419 | qreal QPieSeries::pieHorizontalPosition() const |
|
423 | qreal QPieSeries::pieHorizontalPosition() const | |
420 | { |
|
424 | { | |
421 | Q_D(const QPieSeries); |
|
425 | Q_D(const QPieSeries); | |
422 | return d->m_pieRelativeHorPos; |
|
426 | return d->m_pieRelativeHorPos; | |
423 | } |
|
427 | } | |
424 |
|
428 | |||
425 | /*! |
|
429 | /*! | |
426 | Gets the vertical position position of the pie. |
|
430 | Gets the vertical position position of the pie. | |
427 |
|
431 | |||
428 | The returned value is relative to the chart rectangle where: |
|
432 | The returned value is relative to the chart rectangle where: | |
429 |
|
433 | |||
430 | 0.0 means the absolute top. |
|
434 | 0.0 means the absolute top. | |
431 | 1.0 means the absolute bottom. |
|
435 | 1.0 means the absolute bottom. | |
432 |
|
436 | |||
433 | By default it is 0.5 which puts the pie in the vertical middle of the chart rectangle. |
|
437 | By default it is 0.5 which puts the pie in the vertical middle of the chart rectangle. | |
434 |
|
438 | |||
435 | \sa setPiePosition(), pieHorizontalPosition(), setPieSize() |
|
439 | \sa setPiePosition(), pieHorizontalPosition(), setPieSize() | |
436 | */ |
|
440 | */ | |
437 | qreal QPieSeries::pieVerticalPosition() const |
|
441 | qreal QPieSeries::pieVerticalPosition() const | |
438 | { |
|
442 | { | |
439 | Q_D(const QPieSeries); |
|
443 | Q_D(const QPieSeries); | |
440 | return d->m_pieRelativeVerPos; |
|
444 | return d->m_pieRelativeVerPos; | |
441 | } |
|
445 | } | |
442 |
|
446 | |||
443 | /*! |
|
447 | /*! | |
444 | Sets the relative size of the pie. |
|
448 | Sets the relative size of the pie. | |
445 |
|
449 | |||
446 | The \a relativeSize is defined so that the 1.0 is the maximum that can fit the given chart rectangle. |
|
450 | The \a relativeSize is defined so that the 1.0 is the maximum that can fit the given chart rectangle. | |
447 |
|
451 | |||
448 | Default value is 0.7. |
|
452 | Default value is 0.7. | |
449 |
|
453 | |||
450 | \sa pieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition() |
|
454 | \sa pieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition() | |
451 | */ |
|
455 | */ | |
452 | void QPieSeries::setPieSize(qreal relativeSize) |
|
456 | void QPieSeries::setPieSize(qreal relativeSize) | |
453 | { |
|
457 | { | |
454 | Q_D(QPieSeries); |
|
458 | Q_D(QPieSeries); | |
455 | if (relativeSize < 0.0 || relativeSize > 1.0) |
|
459 | if (relativeSize < 0.0 || relativeSize > 1.0) | |
456 | return; |
|
460 | return; | |
457 |
|
461 | |||
458 | if (!qFuzzyIsNull(d->m_pieRelativeSize- relativeSize)) { |
|
462 | if (!qFuzzyIsNull(d->m_pieRelativeSize- relativeSize)) { | |
459 | d->m_pieRelativeSize = relativeSize; |
|
463 | d->m_pieRelativeSize = relativeSize; | |
460 | emit pieSizeChanged(); |
|
464 | emit pieSizeChanged(); | |
461 | } |
|
465 | } | |
462 | } |
|
466 | } | |
463 |
|
467 | |||
464 | /*! |
|
468 | /*! | |
465 | Gets the relative size of the pie. |
|
469 | Gets the relative size of the pie. | |
466 |
|
470 | |||
467 | The size is defined so that the 1.0 is the maximum that can fit the given chart rectangle. |
|
471 | The size is defined so that the 1.0 is the maximum that can fit the given chart rectangle. | |
468 |
|
472 | |||
469 | Default value is 0.7. |
|
473 | Default value is 0.7. | |
470 |
|
474 | |||
471 | \sa setPieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition() |
|
475 | \sa setPieSize(), setPiePosition(), pieVerticalPosition(), pieHorizontalPosition() | |
472 | */ |
|
476 | */ | |
473 | qreal QPieSeries::pieSize() const |
|
477 | qreal QPieSeries::pieSize() const | |
474 | { |
|
478 | { | |
475 | Q_D(const QPieSeries); |
|
479 | Q_D(const QPieSeries); | |
476 | return d->m_pieRelativeSize; |
|
480 | return d->m_pieRelativeSize; | |
477 | } |
|
481 | } | |
478 |
|
482 | |||
479 |
|
483 | |||
480 | /*! |
|
484 | /*! | |
481 | Sets the end angle of the pie. |
|
485 | Sets the end angle of the pie. | |
482 |
|
486 | |||
483 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
487 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
484 |
|
488 | |||
485 | \a angle must be less than pie end angle. Default value is 0. |
|
489 | \a angle must be less than pie end angle. Default value is 0. | |
486 |
|
490 | |||
487 | \sa pieStartAngle(), pieEndAngle(), setPieEndAngle() |
|
491 | \sa pieStartAngle(), pieEndAngle(), setPieEndAngle() | |
488 | */ |
|
492 | */ | |
489 | void QPieSeries::setPieStartAngle(qreal angle) |
|
493 | void QPieSeries::setPieStartAngle(qreal angle) | |
490 | { |
|
494 | { | |
491 | Q_D(QPieSeries); |
|
495 | Q_D(QPieSeries); | |
492 |
|
496 | |||
493 | if (angle < 0 || angle > 360 || angle > d->m_pieEndAngle) |
|
497 | if (angle < 0 || angle > 360 || angle > d->m_pieEndAngle) | |
494 | return; |
|
498 | return; | |
495 |
|
499 | |||
496 | if (!qFuzzyIsNull(angle - d->m_pieStartAngle)) { |
|
500 | if (!qFuzzyIsNull(angle - d->m_pieStartAngle)) { | |
497 | d->m_pieStartAngle = angle; |
|
501 | d->m_pieStartAngle = angle; | |
498 | d->updateDerivativeData(); |
|
502 | d->updateDerivativeData(); | |
499 | } |
|
503 | } | |
500 | } |
|
504 | } | |
501 |
|
505 | |||
502 | /*! |
|
506 | /*! | |
503 | Gets the start angle of the pie. |
|
507 | Gets the start angle of the pie. | |
504 |
|
508 | |||
505 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. Default value is 360. |
|
509 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. Default value is 360. | |
506 |
|
510 | |||
507 | \sa setPieStartAngle(), pieEndAngle(), setPieEndAngle() |
|
511 | \sa setPieStartAngle(), pieEndAngle(), setPieEndAngle() | |
508 | */ |
|
512 | */ | |
509 | qreal QPieSeries::pieStartAngle() const |
|
513 | qreal QPieSeries::pieStartAngle() const | |
510 | { |
|
514 | { | |
511 | Q_D(const QPieSeries); |
|
515 | Q_D(const QPieSeries); | |
512 | return d->m_pieStartAngle; |
|
516 | return d->m_pieStartAngle; | |
513 | } |
|
517 | } | |
514 |
|
518 | |||
515 | /*! |
|
519 | /*! | |
516 | Sets the end angle of the pie. |
|
520 | Sets the end angle of the pie. | |
517 |
|
521 | |||
518 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
522 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
519 |
|
523 | |||
520 | \a angle must be greater than start angle. |
|
524 | \a angle must be greater than start angle. | |
521 |
|
525 | |||
522 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
526 | \sa pieEndAngle(), pieStartAngle(), setPieStartAngle() | |
523 | */ |
|
527 | */ | |
524 | void QPieSeries::setPieEndAngle(qreal angle) |
|
528 | void QPieSeries::setPieEndAngle(qreal angle) | |
525 | { |
|
529 | { | |
526 | Q_D(QPieSeries); |
|
530 | Q_D(QPieSeries); | |
527 |
|
531 | |||
528 | if (angle < 0 || angle > 360 || angle < d->m_pieStartAngle) |
|
532 | if (angle < 0 || angle > 360 || angle < d->m_pieStartAngle) | |
529 | return; |
|
533 | return; | |
530 |
|
534 | |||
531 | if (!qFuzzyIsNull(angle - d->m_pieEndAngle)) { |
|
535 | if (!qFuzzyIsNull(angle - d->m_pieEndAngle)) { | |
532 | d->m_pieEndAngle = angle; |
|
536 | d->m_pieEndAngle = angle; | |
533 | d->updateDerivativeData(); |
|
537 | d->updateDerivativeData(); | |
534 | } |
|
538 | } | |
535 | } |
|
539 | } | |
536 |
|
540 | |||
537 | /*! |
|
541 | /*! | |
538 | Returns the end angle of the pie. |
|
542 | Returns the end angle of the pie. | |
539 |
|
543 | |||
540 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
544 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
541 |
|
545 | |||
542 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() |
|
546 | \sa setPieEndAngle(), pieStartAngle(), setPieStartAngle() | |
543 | */ |
|
547 | */ | |
544 | qreal QPieSeries::pieEndAngle() const |
|
548 | qreal QPieSeries::pieEndAngle() const | |
545 | { |
|
549 | { | |
546 | Q_D(const QPieSeries); |
|
550 | Q_D(const QPieSeries); | |
547 | return d->m_pieEndAngle; |
|
551 | return d->m_pieEndAngle; | |
548 | } |
|
552 | } | |
549 |
|
553 | |||
550 | /*! |
|
554 | /*! | |
551 | Sets the all the slice labels \a visible or invisible. |
|
555 | Sets the all the slice labels \a visible or invisible. | |
552 |
|
556 | |||
553 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() |
|
557 | \sa QPieSlice::isLabelVisible(), QPieSlice::setLabelVisible() | |
554 | */ |
|
558 | */ | |
555 | void QPieSeries::setLabelsVisible(bool visible) |
|
559 | void QPieSeries::setLabelsVisible(bool visible) | |
556 | { |
|
560 | { | |
557 | Q_D(QPieSeries); |
|
561 | Q_D(QPieSeries); | |
558 | foreach (QPieSlice* s, d->m_slices) |
|
562 | foreach (QPieSlice* s, d->m_slices) | |
559 | s->setLabelVisible(visible); |
|
563 | s->setLabelVisible(visible); | |
560 | } |
|
564 | } | |
561 |
|
565 | |||
562 | /*! |
|
566 | /*! | |
563 | Returns the sum of all slice values in this series. |
|
567 | Returns the sum of all slice values in this series. | |
564 |
|
568 | |||
565 | \sa QPieSlice::value(), QPieSlice::setValue() |
|
569 | \sa QPieSlice::value(), QPieSlice::setValue() | |
566 | */ |
|
570 | */ | |
567 | qreal QPieSeries::total() const |
|
571 | qreal QPieSeries::total() const | |
568 | { |
|
572 | { | |
569 | Q_D(const QPieSeries); |
|
573 | Q_D(const QPieSeries); | |
570 | return d->m_total; |
|
574 | return d->m_total; | |
571 | } |
|
575 | } | |
572 |
|
576 | |||
573 | /*! |
|
577 | /*! | |
574 | \fn void QPieSeries::clicked(QPieSlice* slice) |
|
578 | \fn void QPieSeries::clicked(QPieSlice* slice, Qt::MouseButtons buttons) | |
575 |
|
579 | |||
576 | This signal is emitted when a \a slice has been clicked. |
|
580 | This signal is emitted when a \a slice has been clicked with mouse \a buttons. | |
577 |
|
581 | |||
578 | \sa QPieSlice::clicked() |
|
582 | \sa QPieSlice::clicked() | |
579 | */ |
|
583 | */ | |
580 |
|
584 | |||
581 | /*! |
|
585 | /*! | |
582 | \fn void QPieSeries::hoverEnter(QPieSlice* slice) |
|
586 | \fn void QPieSeries::hoverEnter(QPieSlice* slice) | |
583 |
|
587 | |||
584 | This signal is emitted when user has hovered over a \a slice. |
|
588 | This signal is emitted when user has hovered over a \a slice. | |
585 |
|
589 | |||
586 | \sa QPieSlice::hoverEnter() |
|
590 | \sa QPieSlice::hoverEnter() | |
587 | */ |
|
591 | */ | |
588 |
|
592 | |||
589 | /*! |
|
593 | /*! | |
590 | \fn void QPieSeries::hoverLeave(QPieSlice* slice) |
|
594 | \fn void QPieSeries::hoverLeave(QPieSlice* slice) | |
591 |
|
595 | |||
592 | This signal is emitted when user has hovered away from a \a slice. |
|
596 | This signal is emitted when user has hovered away from a \a slice. | |
593 |
|
597 | |||
594 | \sa QPieSlice::hoverLeave() |
|
598 | \sa QPieSlice::hoverLeave() | |
595 | */ |
|
599 | */ | |
596 |
|
600 | |||
|
601 | /*! | |||
|
602 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |||
|
603 | ||||
|
604 | This signal is emitted when \a slices has been added to the series. | |||
|
605 | ||||
|
606 | \sa append(), insert() | |||
|
607 | */ | |||
|
608 | ||||
|
609 | /*! | |||
|
610 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |||
|
611 | ||||
|
612 | This signal is emitted when \a slices has been removed from the series. | |||
|
613 | ||||
|
614 | \sa remove(), clear() | |||
|
615 | */ | |||
|
616 | ||||
|
617 | /*! | |||
|
618 | \fn void QPieSeries::piePositionChanged() | |||
|
619 | ||||
|
620 | This signal is emitted when pie position has changed. | |||
|
621 | ||||
|
622 | \sa setPiePosition(), pieVerticalPosition(), pieHorizontalPosition() | |||
|
623 | */ | |||
|
624 | ||||
|
625 | /*! | |||
|
626 | \fn void QPieSeries::pieSizeChanged() | |||
597 |
|
|
627 | ||
|
628 | This signal is emitted when pie size has changed. | |||
598 |
|
|
629 | ||
|
630 | \sa pieSize(), setPieSize() | |||
|
631 | */ | |||
599 |
|
632 | |||
600 | bool QPieSeries::setModel(QAbstractItemModel* model) |
|
633 | bool QPieSeries::setModel(QAbstractItemModel* model) | |
601 | { |
|
634 | { | |
602 | Q_D(QPieSeries); |
|
635 | Q_D(QPieSeries); | |
603 | // disconnect signals from old model |
|
636 | // disconnect signals from old model | |
604 | if(m_model) |
|
637 | if(m_model) | |
605 | { |
|
638 | { | |
606 | disconnect(m_model, 0, this, 0); |
|
639 | disconnect(m_model, 0, this, 0); | |
607 | d->m_mapValues = -1; |
|
640 | d->m_mapValues = -1; | |
608 | d->m_mapLabels = -1; |
|
641 | d->m_mapLabels = -1; | |
609 | d->m_mapOrientation = Qt::Vertical; |
|
642 | d->m_mapOrientation = Qt::Vertical; | |
610 | } |
|
643 | } | |
611 |
|
644 | |||
612 | // set new model |
|
645 | // set new model | |
613 | if(model) |
|
646 | if(model) | |
614 | { |
|
647 | { | |
615 | m_model = model; |
|
648 | m_model = model; | |
616 | return true; |
|
649 | return true; | |
617 | } |
|
650 | } | |
618 | else |
|
651 | else | |
619 | { |
|
652 | { | |
620 | m_model = NULL; |
|
653 | m_model = NULL; | |
621 | return false; |
|
654 | return false; | |
622 | } |
|
655 | } | |
623 | } |
|
656 | } | |
624 |
|
657 | |||
625 | void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) |
|
658 | void QPieSeries::setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation) | |
626 | { |
|
659 | { | |
627 | Q_D(QPieSeries); |
|
660 | Q_D(QPieSeries); | |
628 |
|
661 | |||
629 | if (m_model == NULL) |
|
662 | if (m_model == NULL) | |
630 | return; |
|
663 | return; | |
631 |
|
664 | |||
632 | d->m_mapValues = modelValuesLine; |
|
665 | d->m_mapValues = modelValuesLine; | |
633 | d->m_mapLabels = modelLabelsLine; |
|
666 | d->m_mapLabels = modelLabelsLine; | |
634 | d->m_mapOrientation = orientation; |
|
667 | d->m_mapOrientation = orientation; | |
635 |
|
668 | |||
636 | // connect the signals |
|
669 | // connect the signals | |
637 | if (d->m_mapOrientation == Qt::Vertical) { |
|
670 | if (d->m_mapOrientation == Qt::Vertical) { | |
638 | connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
671 | connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
639 | connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
672 | connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); | |
640 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
673 | connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
641 | } else { |
|
674 | } else { | |
642 | connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex))); |
|
675 | connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex, QModelIndex))); | |
643 | connect(m_model, SIGNAL(columnsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); |
|
676 | connect(m_model, SIGNAL(columnsInserted(QModelIndex, int, int)), d, SLOT(modelDataAdded(QModelIndex,int,int))); | |
644 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); |
|
677 | connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), d, SLOT(modelDataRemoved(QModelIndex,int,int))); | |
645 | } |
|
678 | } | |
646 |
|
679 | |||
647 | // create the initial slices set |
|
680 | // create the initial slices set | |
648 | if (d->m_mapOrientation == Qt::Vertical) { |
|
681 | if (d->m_mapOrientation == Qt::Vertical) { | |
649 | for (int i = 0; i < m_model->rowCount(); i++) |
|
682 | for (int i = 0; i < m_model->rowCount(); i++) | |
650 | append(m_model->data(m_model->index(i, d->m_mapValues), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(i, d->m_mapLabels), Qt::DisplayRole).toString()); |
|
683 | append(m_model->data(m_model->index(i, d->m_mapValues), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(i, d->m_mapLabels), Qt::DisplayRole).toString()); | |
651 | } else { |
|
684 | } else { | |
652 | for (int i = 0; i < m_model->columnCount(); i++) |
|
685 | for (int i = 0; i < m_model->columnCount(); i++) | |
653 | append(m_model->data(m_model->index(d->m_mapValues, i), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(d->m_mapLabels, i), Qt::DisplayRole).toString()); |
|
686 | append(m_model->data(m_model->index(d->m_mapValues, i), Qt::DisplayRole).toDouble(), m_model->data(m_model->index(d->m_mapLabels, i), Qt::DisplayRole).toString()); | |
654 | } |
|
687 | } | |
655 | } |
|
688 | } | |
656 |
|
689 | |||
657 | #include "moc_qpieseries.cpp" |
|
690 | #include "moc_qpieseries.cpp" | |
658 | #include "moc_qpieseriesprivate_p.cpp" |
|
691 | #include "moc_qpieseriesprivate_p.cpp" | |
659 |
|
692 | |||
660 | QTCOMMERCIALCHART_END_NAMESPACE |
|
693 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,100 +1,100 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #ifndef PIESERIES_H |
|
21 | #ifndef PIESERIES_H | |
22 | #define PIESERIES_H |
|
22 | #define PIESERIES_H | |
23 |
|
23 | |||
24 | #include <qseries.h> |
|
24 | #include <qseries.h> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 | class QPieSeriesPrivate; |
|
27 | class QPieSeriesPrivate; | |
28 | class QPieSlice; |
|
28 | class QPieSlice; | |
29 |
|
29 | |||
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries |
|
30 | class QTCOMMERCIALCHART_EXPORT QPieSeries : public QSeries | |
31 | { |
|
31 | { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 |
|
33 | |||
34 | public: |
|
34 | public: | |
35 | QPieSeries(QObject *parent = 0); |
|
35 | QPieSeries(QObject *parent = 0); | |
36 | virtual ~QPieSeries(); |
|
36 | virtual ~QPieSeries(); | |
37 |
|
37 | |||
38 | public: // from QChartSeries |
|
38 | public: // from QChartSeries | |
39 | QSeriesType type() const; |
|
39 | QSeriesType type() const; | |
40 |
|
40 | |||
41 | public: |
|
41 | public: | |
42 |
|
42 | |||
43 | // slice setters |
|
43 | // slice setters | |
44 | void append(QPieSlice* slice); |
|
44 | void append(QPieSlice* slice); | |
45 | void append(QList<QPieSlice*> slices); |
|
45 | void append(QList<QPieSlice*> slices); | |
46 | void insert(int i, QPieSlice* slice); |
|
46 | void insert(int index, QPieSlice* slice); | |
47 | void replace(QList<QPieSlice*> slices); |
|
47 | void replace(QList<QPieSlice*> slices); | |
48 | void remove(QPieSlice* slice); |
|
48 | void remove(QPieSlice* slice); | |
49 | void clear(); |
|
49 | void clear(); | |
50 |
|
50 | |||
51 | // slice getters |
|
51 | // slice getters | |
52 | QList<QPieSlice*> slices() const; |
|
52 | QList<QPieSlice*> slices() const; | |
53 |
|
53 | |||
54 | // calculated data |
|
54 | // calculated data | |
55 | int count() const; |
|
55 | int count() const; | |
56 | bool isEmpty() const; |
|
56 | bool isEmpty() const; | |
57 | qreal total() const; |
|
57 | qreal total() const; | |
58 |
|
58 | |||
59 | // pie customization |
|
59 | // pie customization | |
60 | void setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition); |
|
60 | void setPiePosition(qreal relativeHorizontalPosition, qreal relativeVerticalPosition); | |
61 | qreal pieHorizontalPosition() const; |
|
61 | qreal pieHorizontalPosition() const; | |
62 | qreal pieVerticalPosition() const; |
|
62 | qreal pieVerticalPosition() const; | |
63 | void setPieSize(qreal relativeSize); |
|
63 | void setPieSize(qreal relativeSize); | |
64 | qreal pieSize() const; |
|
64 | qreal pieSize() const; | |
65 | void setPieStartAngle(qreal startAngle); |
|
65 | void setPieStartAngle(qreal startAngle); | |
66 | qreal pieStartAngle() const; |
|
66 | qreal pieStartAngle() const; | |
67 | void setPieEndAngle(qreal endAngle); |
|
67 | void setPieEndAngle(qreal endAngle); | |
68 | qreal pieEndAngle() const; |
|
68 | qreal pieEndAngle() const; | |
69 |
|
69 | |||
70 | // convenience function |
|
70 | // convenience function | |
71 | QPieSeries& operator << (QPieSlice* slice); |
|
71 | QPieSeries& operator << (QPieSlice* slice); | |
72 | QPieSlice* append(qreal value, QString name); |
|
72 | QPieSlice* append(qreal value, QString name); | |
73 | void setLabelsVisible(bool visible = true); |
|
73 | void setLabelsVisible(bool visible = true); | |
74 |
|
74 | |||
75 | // data from model |
|
75 | // data from model | |
76 | bool setModel(QAbstractItemModel* model); |
|
76 | bool setModel(QAbstractItemModel* model); | |
77 | void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); |
|
77 | void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); | |
78 |
|
78 | |||
79 | Q_SIGNALS: |
|
79 | Q_SIGNALS: | |
80 | void clicked(QPieSlice* slice, Qt::MouseButtons buttons); |
|
80 | void clicked(QPieSlice* slice, Qt::MouseButtons buttons); | |
81 | void hoverEnter(QPieSlice* slice); |
|
81 | void hoverEnter(QPieSlice* slice); | |
82 | void hoverLeave(QPieSlice* slice); |
|
82 | void hoverLeave(QPieSlice* slice); | |
83 | void added(QList<QPieSlice*> slices); |
|
83 | void added(QList<QPieSlice*> slices); | |
84 | void removed(QList<QPieSlice*> slices); |
|
84 | void removed(QList<QPieSlice*> slices); | |
85 | void piePositionChanged(); |
|
85 | void piePositionChanged(); | |
86 | void pieSizeChanged(); |
|
86 | void pieSizeChanged(); | |
87 |
|
87 | |||
88 | private: |
|
88 | private: | |
89 | QPieSeriesPrivate * const d_ptr; |
|
89 | QPieSeriesPrivate * const d_ptr; | |
90 | Q_DECLARE_PRIVATE(QPieSeries) |
|
90 | Q_DECLARE_PRIVATE(QPieSeries) | |
91 | Q_DISABLE_COPY(QPieSeries) |
|
91 | Q_DISABLE_COPY(QPieSeries) | |
92 |
|
92 | |||
93 | public: |
|
93 | public: | |
94 | typedef QPieSeriesPrivate * const DataPtr; |
|
94 | typedef QPieSeriesPrivate * const DataPtr; | |
95 | inline DataPtr &data_ptr() { return d_ptr; } |
|
95 | inline DataPtr &data_ptr() { return d_ptr; } | |
96 | }; |
|
96 | }; | |
97 |
|
97 | |||
98 | QTCOMMERCIALCHART_END_NAMESPACE |
|
98 | QTCOMMERCIALCHART_END_NAMESPACE | |
99 |
|
99 | |||
100 | #endif // PIESERIES_H |
|
100 | #endif // PIESERIES_H |
@@ -1,433 +1,433 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qpieslice.h" |
|
21 | #include "qpieslice.h" | |
22 | #include "qpiesliceprivate_p.h" |
|
22 | #include "qpiesliceprivate_p.h" | |
23 | #include "qpieseries.h" |
|
23 | #include "qpieseries.h" | |
24 | #include "qpieseriesprivate_p.h" |
|
24 | #include "qpieseriesprivate_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QPieSlice |
|
29 | \class QPieSlice | |
30 | \brief Defines a slice in pie series. |
|
30 | \brief Defines a slice in pie series. | |
31 |
|
31 | |||
32 | Holds all the data of a single slice in a QPieSeries and provides the means |
|
32 | Holds all the data of a single slice in a QPieSeries and provides the means | |
33 | to modify slice data and customize the visual appearance of the slice. |
|
33 | to modify slice data and customize the visual appearance of the slice. | |
34 |
|
34 | |||
35 | It also provides the means to customize user interaction with the slice by |
|
35 | It also provides the means to customize user interaction with the slice by | |
36 | providing signals for clicking and hover events. |
|
36 | providing signals for clicking and hover events. | |
37 | */ |
|
37 | */ | |
38 |
|
38 | |||
39 | /*! |
|
39 | /*! | |
40 | \property QPieSlice::label |
|
40 | \property QPieSlice::label | |
41 |
|
41 | |||
42 | Label of the slice. |
|
42 | Label of the slice. | |
43 | */ |
|
43 | */ | |
44 |
|
44 | |||
45 | /*! |
|
45 | /*! | |
46 | \property QPieSlice::value |
|
46 | \property QPieSlice::value | |
47 |
|
47 | |||
48 | Value of the slice. |
|
48 | Value of the slice. | |
49 | */ |
|
49 | */ | |
50 |
|
50 | |||
51 | /*! |
|
51 | /*! | |
52 | Constructs an empty slice with a \a parent. |
|
52 | Constructs an empty slice with a \a parent. | |
53 |
|
53 | |||
54 | Note that QPieSeries takes ownership of the slice when it is set/added. |
|
54 | Note that QPieSeries takes ownership of the slice when it is set/added. | |
55 |
|
55 | |||
56 | \sa QPieSeries::replace(), QPieSeries::append() |
|
56 | \sa QPieSeries::replace(), QPieSeries::append() | |
57 | */ |
|
57 | */ | |
58 | QPieSlice::QPieSlice(QObject *parent) |
|
58 | QPieSlice::QPieSlice(QObject *parent) | |
59 | :QObject(parent), |
|
59 | :QObject(parent), | |
60 | d_ptr(new QPieSlicePrivate(this)) |
|
60 | d_ptr(new QPieSlicePrivate(this)) | |
61 | { |
|
61 | { | |
62 |
|
62 | |||
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | Constructs an empty slice with given \a value, \a label and a \a parent. |
|
66 | Constructs an empty slice with given \a value, \a label and a \a parent. | |
67 | Note that QPieSeries takes ownership of the slice when it is set/added. |
|
67 | Note that QPieSeries takes ownership of the slice when it is set/added. | |
68 | \sa QPieSeries::replace(), QPieSeries::append() |
|
68 | \sa QPieSeries::replace(), QPieSeries::append() | |
69 | */ |
|
69 | */ | |
70 | QPieSlice::QPieSlice(qreal value, QString label, QObject *parent) |
|
70 | QPieSlice::QPieSlice(qreal value, QString label, QObject *parent) | |
71 | :QObject(parent), |
|
71 | :QObject(parent), | |
72 | d_ptr(new QPieSlicePrivate(this)) |
|
72 | d_ptr(new QPieSlicePrivate(this)) | |
73 | { |
|
73 | { | |
74 | Q_D(QPieSlice); |
|
74 | Q_D(QPieSlice); | |
75 | d->m_data.m_value = value; |
|
75 | d->m_data.m_value = value; | |
76 | d->m_data.m_labelText = label; |
|
76 | d->m_data.m_labelText = label; | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | Destroys the slice. |
|
80 | Destroys the slice. | |
81 | User should not delete the slice if it has been added to the series. |
|
81 | User should not delete the slice if it has been added to the series. | |
82 | */ |
|
82 | */ | |
83 | QPieSlice::~QPieSlice() |
|
83 | QPieSlice::~QPieSlice() | |
84 | { |
|
84 | { | |
85 | delete d_ptr; |
|
85 | delete d_ptr; | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | /*! |
|
88 | /*! | |
89 | Gets the value of the slice. |
|
89 | Gets the value of the slice. | |
90 | Note that all values in the series |
|
90 | Note that all values in the series | |
91 | \sa setValue() |
|
91 | \sa setValue() | |
92 | */ |
|
92 | */ | |
93 | qreal QPieSlice::value() const |
|
93 | qreal QPieSlice::value() const | |
94 | { |
|
94 | { | |
95 | Q_D(const QPieSlice); |
|
95 | Q_D(const QPieSlice); | |
96 | return d->m_data.m_value; |
|
96 | return d->m_data.m_value; | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | Gets the label of the slice. |
|
100 | Gets the label of the slice. | |
101 | \sa setLabel() |
|
101 | \sa setLabel() | |
102 | */ |
|
102 | */ | |
103 | QString QPieSlice::label() const |
|
103 | QString QPieSlice::label() const | |
104 | { |
|
104 | { | |
105 | Q_D(const QPieSlice); |
|
105 | Q_D(const QPieSlice); | |
106 | return d->m_data.m_labelText; |
|
106 | return d->m_data.m_labelText; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | /*! |
|
109 | /*! | |
110 | Returns true if label is set as visible. |
|
110 | Returns true if label is set as visible. | |
111 | \sa setLabelVisible() |
|
111 | \sa setLabelVisible() | |
112 | */ |
|
112 | */ | |
113 | bool QPieSlice::isLabelVisible() const |
|
113 | bool QPieSlice::isLabelVisible() const | |
114 | { |
|
114 | { | |
115 | Q_D(const QPieSlice); |
|
115 | Q_D(const QPieSlice); | |
116 | return d->m_data.m_isLabelVisible; |
|
116 | return d->m_data.m_isLabelVisible; | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | /*! |
|
119 | /*! | |
120 | Returns true if slice is exloded from the pie. |
|
120 | Returns true if slice is exloded from the pie. | |
121 | \sa setExploded(), setExplodeDistanceFactor() |
|
121 | \sa setExploded(), setExplodeDistanceFactor() | |
122 | */ |
|
122 | */ | |
123 | bool QPieSlice::isExploded() const |
|
123 | bool QPieSlice::isExploded() const | |
124 | { |
|
124 | { | |
125 | Q_D(const QPieSlice); |
|
125 | Q_D(const QPieSlice); | |
126 | return d->m_data.m_isExploded; |
|
126 | return d->m_data.m_isExploded; | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | /*! |
|
129 | /*! | |
130 | Returns the explode distance factor. |
|
130 | Returns the explode distance factor. | |
131 |
|
131 | |||
132 | The factor is relative to pie radius. For example: |
|
132 | The factor is relative to pie radius. For example: | |
133 | 1.0 means the distance is the same as the radius. |
|
133 | 1.0 means the distance is the same as the radius. | |
134 | 0.5 means the distance is half of the radius. |
|
134 | 0.5 means the distance is half of the radius. | |
135 |
|
135 | |||
136 | Default value is 0.15. |
|
136 | Default value is 0.15. | |
137 |
|
137 | |||
138 | \sa setExplodeDistanceFactor() |
|
138 | \sa setExplodeDistanceFactor() | |
139 | */ |
|
139 | */ | |
140 | qreal QPieSlice::explodeDistanceFactor() const |
|
140 | qreal QPieSlice::explodeDistanceFactor() const | |
141 | { |
|
141 | { | |
142 | Q_D(const QPieSlice); |
|
142 | Q_D(const QPieSlice); | |
143 | return d->m_data.m_explodeDistanceFactor; |
|
143 | return d->m_data.m_explodeDistanceFactor; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | Returns the percentage of this slice compared to all slices in the same series. |
|
147 | Returns the percentage of this slice compared to all slices in the same series. | |
148 | The returned value ranges from 0 to 1.0. |
|
148 | The returned value ranges from 0 to 1.0. | |
149 |
|
149 | |||
150 | Updated internally after the slice is added to the series. |
|
150 | Updated internally after the slice is added to the series. | |
151 | */ |
|
151 | */ | |
152 | qreal QPieSlice::percentage() const |
|
152 | qreal QPieSlice::percentage() const | |
153 | { |
|
153 | { | |
154 | Q_D(const QPieSlice); |
|
154 | Q_D(const QPieSlice); | |
155 | return d->m_data.m_percentage; |
|
155 | return d->m_data.m_percentage; | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | /*! |
|
158 | /*! | |
159 | Returns the starting angle of this slice in the series it belongs to. |
|
159 | Returns the starting angle of this slice in the series it belongs to. | |
160 |
|
160 | |||
161 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
161 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
162 |
|
162 | |||
163 | Updated internally after the slice is added to the series. |
|
163 | Updated internally after the slice is added to the series. | |
164 | */ |
|
164 | */ | |
165 | qreal QPieSlice::startAngle() const |
|
165 | qreal QPieSlice::startAngle() const | |
166 | { |
|
166 | { | |
167 | Q_D(const QPieSlice); |
|
167 | Q_D(const QPieSlice); | |
168 | return d->m_data.m_startAngle; |
|
168 | return d->m_data.m_startAngle; | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Returns the end angle of this slice in the series it belongs to. |
|
172 | Returns the end angle of this slice in the series it belongs to. | |
173 |
|
173 | |||
174 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. |
|
174 | Full pie is 360 degrees where 0 degrees is at 12 a'clock. | |
175 |
|
175 | |||
176 | Updated internally after the slice is added to the series. |
|
176 | Updated internally after the slice is added to the series. | |
177 | */ |
|
177 | */ | |
178 | qreal QPieSlice::endAngle() const |
|
178 | qreal QPieSlice::endAngle() const | |
179 | { |
|
179 | { | |
180 | Q_D(const QPieSlice); |
|
180 | Q_D(const QPieSlice); | |
181 | return d->m_data.m_startAngle + d->m_data.m_angleSpan; |
|
181 | return d->m_data.m_startAngle + d->m_data.m_angleSpan; | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | /*! |
|
184 | /*! | |
185 | Returns the pen used to draw this slice. |
|
185 | Returns the pen used to draw this slice. | |
186 |
\sa set |
|
186 | \sa setPen() | |
187 | */ |
|
187 | */ | |
188 | QPen QPieSlice::pen() const |
|
188 | QPen QPieSlice::pen() const | |
189 | { |
|
189 | { | |
190 | Q_D(const QPieSlice); |
|
190 | Q_D(const QPieSlice); | |
191 | return d->m_data.m_slicePen; |
|
191 | return d->m_data.m_slicePen; | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | /*! |
|
194 | /*! | |
195 | Returns the brush used to draw this slice. |
|
195 | Returns the brush used to draw this slice. | |
196 |
\sa set |
|
196 | \sa setBrush() | |
197 | */ |
|
197 | */ | |
198 | QBrush QPieSlice::brush() const |
|
198 | QBrush QPieSlice::brush() const | |
199 | { |
|
199 | { | |
200 | Q_D(const QPieSlice); |
|
200 | Q_D(const QPieSlice); | |
201 | return d->m_data.m_sliceBrush; |
|
201 | return d->m_data.m_sliceBrush; | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | /*! |
|
204 | /*! | |
205 | Returns the pen used to draw the label in this slice. |
|
205 | Returns the pen used to draw the label in this slice. | |
206 |
\sa setLabel |
|
206 | \sa setLabelPen() | |
207 | */ |
|
207 | */ | |
208 | QPen QPieSlice::labelPen() const |
|
208 | QPen QPieSlice::labelPen() const | |
209 | { |
|
209 | { | |
210 | Q_D(const QPieSlice); |
|
210 | Q_D(const QPieSlice); | |
211 | return d->m_data.m_labelPen; |
|
211 | return d->m_data.m_labelPen; | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | /*! |
|
214 | /*! | |
215 | Returns the font used to draw label in this slice. |
|
215 | Returns the font used to draw label in this slice. | |
216 | \sa setLabelFont() |
|
216 | \sa setLabelFont() | |
217 | */ |
|
217 | */ | |
218 | QFont QPieSlice::labelFont() const |
|
218 | QFont QPieSlice::labelFont() const | |
219 | { |
|
219 | { | |
220 | Q_D(const QPieSlice); |
|
220 | Q_D(const QPieSlice); | |
221 | return d->m_data.m_labelFont; |
|
221 | return d->m_data.m_labelFont; | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | /*! |
|
224 | /*! | |
225 | Gets the label arm length factor. |
|
225 | Gets the label arm length factor. | |
226 |
|
226 | |||
227 | The factor is relative to pie radius. For example: |
|
227 | The factor is relative to pie radius. For example: | |
228 | 1.0 means the length is the same as the radius. |
|
228 | 1.0 means the length is the same as the radius. | |
229 | 0.5 means the length is half of the radius. |
|
229 | 0.5 means the length is half of the radius. | |
230 |
|
230 | |||
231 | Default value is 0.15 |
|
231 | Default value is 0.15 | |
232 |
|
232 | |||
233 | \sa setLabelArmLengthFactor() |
|
233 | \sa setLabelArmLengthFactor() | |
234 | */ |
|
234 | */ | |
235 | qreal QPieSlice::labelArmLengthFactor() const |
|
235 | qreal QPieSlice::labelArmLengthFactor() const | |
236 | { |
|
236 | { | |
237 | Q_D(const QPieSlice); |
|
237 | Q_D(const QPieSlice); | |
238 | return d->m_data.m_labelArmLengthFactor; |
|
238 | return d->m_data.m_labelArmLengthFactor; | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | /*! |
|
241 | /*! | |
242 | \fn void QPieSlice::clicked() |
|
242 | \fn void QPieSlice::clicked(Qt::MouseButtons buttons) | |
243 |
|
243 | |||
244 | This signal is emitted when user has clicked the slice. |
|
244 | This signal is emitted when user has clicked the slice. | |
245 |
|
245 | |||
246 | \sa QPieSeries::clicked() |
|
246 | \sa QPieSeries::clicked() | |
247 | */ |
|
247 | */ | |
248 |
|
248 | |||
249 | /*! |
|
249 | /*! | |
250 | \fn void QPieSlice::hoverEnter() |
|
250 | \fn void QPieSlice::hoverEnter() | |
251 |
|
251 | |||
252 | This signal is emitted when user has hovered over the slice. |
|
252 | This signal is emitted when user has hovered over the slice. | |
253 |
|
253 | |||
254 | \sa QPieSeries::hoverEnter() |
|
254 | \sa QPieSeries::hoverEnter() | |
255 | */ |
|
255 | */ | |
256 |
|
256 | |||
257 | /*! |
|
257 | /*! | |
258 | \fn void QPieSlice::hoverLeave() |
|
258 | \fn void QPieSlice::hoverLeave() | |
259 |
|
259 | |||
260 | This signal is emitted when user has hovered away from the slice. |
|
260 | This signal is emitted when user has hovered away from the slice. | |
261 |
|
261 | |||
262 | \sa QPieSeries::hoverLeave() |
|
262 | \sa QPieSeries::hoverLeave() | |
263 | */ |
|
263 | */ | |
264 |
|
264 | |||
265 | /*! |
|
265 | /*! | |
266 | \fn void QPieSlice::changed() |
|
266 | \fn void QPieSlice::changed() | |
267 |
|
267 | |||
268 | This signal emitted when something has changed in the slice. |
|
268 | This signal emitted when something has changed in the slice. | |
269 |
|
269 | |||
270 | \sa QPieSeries::changed() |
|
270 | \sa QPieSeries::changed() | |
271 | */ |
|
271 | */ | |
272 |
|
272 | |||
273 | /*! |
|
273 | /*! | |
274 | Sets the \a value of this slice. |
|
274 | Sets the \a value of this slice. | |
275 | \sa value() |
|
275 | \sa value() | |
276 | */ |
|
276 | */ | |
277 | void QPieSlice::setValue(qreal value) |
|
277 | void QPieSlice::setValue(qreal value) | |
278 | { |
|
278 | { | |
279 | Q_D(QPieSlice); |
|
279 | Q_D(QPieSlice); | |
280 | if (!qFuzzyIsNull(d->m_data.m_value - value)) { |
|
280 | if (!qFuzzyIsNull(d->m_data.m_value - value)) { | |
281 | d->m_data.m_value = value; |
|
281 | d->m_data.m_value = value; | |
282 |
|
282 | |||
283 | QPieSeries *series = qobject_cast<QPieSeries*>(parent()); |
|
283 | QPieSeries *series = qobject_cast<QPieSeries*>(parent()); | |
284 | if (series) |
|
284 | if (series) | |
285 | series->data_ptr()->updateDerivativeData(); // will emit changed() |
|
285 | series->data_ptr()->updateDerivativeData(); // will emit changed() | |
286 | else |
|
286 | else | |
287 | emit changed(); |
|
287 | emit changed(); | |
288 | } |
|
288 | } | |
289 | } |
|
289 | } | |
290 |
|
290 | |||
291 | /*! |
|
291 | /*! | |
292 | Sets the \a label of the slice. |
|
292 | Sets the \a label of the slice. | |
293 | \sa label() |
|
293 | \sa label() | |
294 | */ |
|
294 | */ | |
295 | void QPieSlice::setLabel(QString label) |
|
295 | void QPieSlice::setLabel(QString label) | |
296 | { |
|
296 | { | |
297 | Q_D(QPieSlice); |
|
297 | Q_D(QPieSlice); | |
298 | if (d->m_data.m_labelText != label) { |
|
298 | if (d->m_data.m_labelText != label) { | |
299 | d->m_data.m_labelText = label; |
|
299 | d->m_data.m_labelText = label; | |
300 | emit changed(); |
|
300 | emit changed(); | |
301 | } |
|
301 | } | |
302 | } |
|
302 | } | |
303 |
|
303 | |||
304 | /*! |
|
304 | /*! | |
305 | Sets the label \a visible in this slice. |
|
305 | Sets the label \a visible in this slice. | |
306 | \sa isLabelVisible(), QPieSeries::setLabelsVisible() |
|
306 | \sa isLabelVisible(), QPieSeries::setLabelsVisible() | |
307 | */ |
|
307 | */ | |
308 | void QPieSlice::setLabelVisible(bool visible) |
|
308 | void QPieSlice::setLabelVisible(bool visible) | |
309 | { |
|
309 | { | |
310 | Q_D(QPieSlice); |
|
310 | Q_D(QPieSlice); | |
311 | if (d->m_data.m_isLabelVisible != visible) { |
|
311 | if (d->m_data.m_isLabelVisible != visible) { | |
312 | d->m_data.m_isLabelVisible = visible; |
|
312 | d->m_data.m_isLabelVisible = visible; | |
313 | emit changed(); |
|
313 | emit changed(); | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | /*! |
|
317 | /*! | |
318 | Sets this slice \a exploded. |
|
318 | Sets this slice \a exploded. | |
319 | \sa isExploded(), explodeDistanceFactor() |
|
319 | \sa isExploded(), explodeDistanceFactor() | |
320 | */ |
|
320 | */ | |
321 | void QPieSlice::setExploded(bool exploded) |
|
321 | void QPieSlice::setExploded(bool exploded) | |
322 | { |
|
322 | { | |
323 | Q_D(QPieSlice); |
|
323 | Q_D(QPieSlice); | |
324 | if (d->m_data.m_isExploded != exploded) { |
|
324 | if (d->m_data.m_isExploded != exploded) { | |
325 | d->m_data.m_isExploded = exploded; |
|
325 | d->m_data.m_isExploded = exploded; | |
326 | emit changed(); |
|
326 | emit changed(); | |
327 | } |
|
327 | } | |
328 | } |
|
328 | } | |
329 |
|
329 | |||
330 | /*! |
|
330 | /*! | |
331 | Sets the explode distance \a factor. |
|
331 | Sets the explode distance \a factor. | |
332 |
|
332 | |||
333 | The factor is relative to pie radius. For example: |
|
333 | The factor is relative to pie radius. For example: | |
334 | 1.0 means the distance is the same as the radius. |
|
334 | 1.0 means the distance is the same as the radius. | |
335 | 0.5 means the distance is half of the radius. |
|
335 | 0.5 means the distance is half of the radius. | |
336 |
|
336 | |||
337 | Default value is 0.15 |
|
337 | Default value is 0.15 | |
338 |
|
338 | |||
339 | \sa explodeDistanceFactor() |
|
339 | \sa explodeDistanceFactor() | |
340 | */ |
|
340 | */ | |
341 | void QPieSlice::setExplodeDistanceFactor(qreal factor) |
|
341 | void QPieSlice::setExplodeDistanceFactor(qreal factor) | |
342 | { |
|
342 | { | |
343 | Q_D(QPieSlice); |
|
343 | Q_D(QPieSlice); | |
344 | if (!qFuzzyIsNull(d->m_data.m_explodeDistanceFactor - factor)) { |
|
344 | if (!qFuzzyIsNull(d->m_data.m_explodeDistanceFactor - factor)) { | |
345 | d->m_data.m_explodeDistanceFactor = factor; |
|
345 | d->m_data.m_explodeDistanceFactor = factor; | |
346 | emit changed(); |
|
346 | emit changed(); | |
347 | } |
|
347 | } | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | /*! |
|
350 | /*! | |
351 | Sets the \a pen used to draw this slice. |
|
351 | Sets the \a pen used to draw this slice. | |
352 | Note that applying a theme will override this. |
|
352 | Note that applying a theme will override this. | |
353 |
\sa |
|
353 | \sa pen() | |
354 | */ |
|
354 | */ | |
355 | void QPieSlice::setPen(const QPen &pen) |
|
355 | void QPieSlice::setPen(const QPen &pen) | |
356 | { |
|
356 | { | |
357 | Q_D(QPieSlice); |
|
357 | Q_D(QPieSlice); | |
358 | if (d->m_data.m_slicePen != pen) { |
|
358 | if (d->m_data.m_slicePen != pen) { | |
359 | d->m_data.m_slicePen = pen; |
|
359 | d->m_data.m_slicePen = pen; | |
360 | d->m_data.m_slicePen.setThemed(false); |
|
360 | d->m_data.m_slicePen.setThemed(false); | |
361 | emit changed(); |
|
361 | emit changed(); | |
362 | } |
|
362 | } | |
363 | } |
|
363 | } | |
364 |
|
364 | |||
365 | /*! |
|
365 | /*! | |
366 | Sets the \a brush used to draw this slice. |
|
366 | Sets the \a brush used to draw this slice. | |
367 | Note that applying a theme will override this. |
|
367 | Note that applying a theme will override this. | |
368 |
\sa |
|
368 | \sa brush() | |
369 | */ |
|
369 | */ | |
370 | void QPieSlice::setBrush(const QBrush &brush) |
|
370 | void QPieSlice::setBrush(const QBrush &brush) | |
371 | { |
|
371 | { | |
372 | Q_D(QPieSlice); |
|
372 | Q_D(QPieSlice); | |
373 | if (d->m_data.m_sliceBrush != brush) { |
|
373 | if (d->m_data.m_sliceBrush != brush) { | |
374 | d->m_data.m_sliceBrush = brush; |
|
374 | d->m_data.m_sliceBrush = brush; | |
375 | d->m_data.m_sliceBrush.setThemed(false); |
|
375 | d->m_data.m_sliceBrush.setThemed(false); | |
376 | emit changed(); |
|
376 | emit changed(); | |
377 | } |
|
377 | } | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | /*! |
|
380 | /*! | |
381 | Sets the \a pen used to draw the label in this slice. |
|
381 | Sets the \a pen used to draw the label in this slice. | |
382 | Note that applying a theme will override this. |
|
382 | Note that applying a theme will override this. | |
383 |
\sa label |
|
383 | \sa labelPen() | |
384 | */ |
|
384 | */ | |
385 | void QPieSlice::setLabelPen(const QPen &pen) |
|
385 | void QPieSlice::setLabelPen(const QPen &pen) | |
386 | { |
|
386 | { | |
387 | Q_D(QPieSlice); |
|
387 | Q_D(QPieSlice); | |
388 | if (d->m_data.m_labelPen != pen) { |
|
388 | if (d->m_data.m_labelPen != pen) { | |
389 | d->m_data.m_labelPen = pen; |
|
389 | d->m_data.m_labelPen = pen; | |
390 | d->m_data.m_labelPen.setThemed(false); |
|
390 | d->m_data.m_labelPen.setThemed(false); | |
391 | emit changed(); |
|
391 | emit changed(); | |
392 | } |
|
392 | } | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | /*! |
|
395 | /*! | |
396 | Sets the \a font used to draw the label in this slice. |
|
396 | Sets the \a font used to draw the label in this slice. | |
397 | Note that applying a theme will override this. |
|
397 | Note that applying a theme will override this. | |
398 | \sa labelFont() |
|
398 | \sa labelFont() | |
399 | */ |
|
399 | */ | |
400 | void QPieSlice::setLabelFont(const QFont &font) |
|
400 | void QPieSlice::setLabelFont(const QFont &font) | |
401 | { |
|
401 | { | |
402 | Q_D(QPieSlice); |
|
402 | Q_D(QPieSlice); | |
403 | if (d->m_data.m_labelFont != font) { |
|
403 | if (d->m_data.m_labelFont != font) { | |
404 | d->m_data.m_labelFont = font; |
|
404 | d->m_data.m_labelFont = font; | |
405 | d->m_data.m_labelFont.setThemed(false); |
|
405 | d->m_data.m_labelFont.setThemed(false); | |
406 | emit changed(); |
|
406 | emit changed(); | |
407 | } |
|
407 | } | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | /*! |
|
410 | /*! | |
411 | Sets the label arm length \a factor. |
|
411 | Sets the label arm length \a factor. | |
412 |
|
412 | |||
413 | The factor is relative to pie radius. For example: |
|
413 | The factor is relative to pie radius. For example: | |
414 | 1.0 means the length is the same as the radius. |
|
414 | 1.0 means the length is the same as the radius. | |
415 | 0.5 means the length is half of the radius. |
|
415 | 0.5 means the length is half of the radius. | |
416 |
|
416 | |||
417 | Default value is 0.15 |
|
417 | Default value is 0.15 | |
418 |
|
418 | |||
419 | \sa labelArmLengthFactor() |
|
419 | \sa labelArmLengthFactor() | |
420 | */ |
|
420 | */ | |
421 | void QPieSlice::setLabelArmLengthFactor(qreal factor) |
|
421 | void QPieSlice::setLabelArmLengthFactor(qreal factor) | |
422 | { |
|
422 | { | |
423 | Q_D(QPieSlice); |
|
423 | Q_D(QPieSlice); | |
424 | if (!qFuzzyIsNull(d->m_data.m_labelArmLengthFactor - factor)) { |
|
424 | if (!qFuzzyIsNull(d->m_data.m_labelArmLengthFactor - factor)) { | |
425 | d->m_data.m_labelArmLengthFactor = factor; |
|
425 | d->m_data.m_labelArmLengthFactor = factor; | |
426 | emit changed(); |
|
426 | emit changed(); | |
427 | } |
|
427 | } | |
428 | } |
|
428 | } | |
429 |
|
429 | |||
430 | #include "moc_qpieslice.cpp" |
|
430 | #include "moc_qpieslice.cpp" | |
431 | #include "moc_qpiesliceprivate_p.cpp" |
|
431 | #include "moc_qpiesliceprivate_p.cpp" | |
432 |
|
432 | |||
433 | QTCOMMERCIALCHART_END_NAMESPACE |
|
433 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,87 +1,87 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qseries.h" |
|
21 | #include "qseries.h" | |
22 |
|
22 | |||
23 | /*! |
|
23 | /*! | |
24 | \class QSeries |
|
24 | \class QSeries | |
25 | \brief Base class for all QtCommercial Chart series. |
|
25 | \brief Base class for all QtCommercial Chart series. | |
26 | \mainclass |
|
26 | \mainclass | |
27 |
|
27 | |||
28 | Usually you use the series type specific inherited classes instead of the base class. |
|
28 | Usually you use the series type specific inherited classes instead of the base class. | |
29 | \sa QScatterSeries |
|
29 | \sa QScatterSeries | |
30 | */ |
|
30 | */ | |
31 |
|
31 | |||
32 | /*! |
|
32 | /*! | |
33 | \enum QSeries::QSeriesType |
|
33 | \enum QSeries::QSeriesType | |
34 |
|
34 | |||
35 | The type of the series object. |
|
35 | The type of the series object. | |
36 |
|
36 | |||
37 | \value SeriesTypeLine |
|
37 | \value SeriesTypeLine | |
38 | \value SeriesTypeArea |
|
38 | \value SeriesTypeArea | |
39 | \value SeriesTypeBar |
|
39 | \value SeriesTypeBar | |
40 | \value SeriesTypeStackedBar |
|
40 | \value SeriesTypeStackedBar | |
41 | \value SeriesTypePercentBar |
|
41 | \value SeriesTypePercentBar | |
42 | \value SeriesTypePie |
|
42 | \value SeriesTypePie | |
43 | \value SeriesTypeScatter |
|
43 | \value SeriesTypeScatter | |
44 | \value SeriesTypeSpline |
|
44 | \value SeriesTypeSpline | |
45 | */ |
|
45 | */ | |
46 |
|
46 | |||
47 | /*! |
|
47 | /*! | |
48 | \fn QSeries::QSeries(QObject *parent) |
|
48 | \fn QSeries::QSeries(QObject *parent) | |
49 | \brief Constructs ChartSeries object with \a parent. |
|
49 | \brief Constructs ChartSeries object with \a parent. | |
50 | */ |
|
50 | */ | |
51 |
|
51 | |||
52 | /*! |
|
52 | /*! | |
53 | \fn QSeries::~QSeries() |
|
53 | \fn QSeries::~QSeries() | |
54 | \brief Virtual destructor for the chart series. |
|
54 | \brief Virtual destructor for the chart series. | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \fn QSeriesType QSeries::type() const |
|
58 | \fn QSeriesType QSeries::type() const | |
59 | \brief The type of the series. |
|
59 | \brief The type of the series. | |
60 | */ |
|
60 | */ | |
61 |
|
61 | |||
62 | /*! |
|
62 | /*! | |
63 | \fn bool QSeries::setModel(QAbstractItemModel *model) |
|
63 | \fn bool QSeries::setModel(QAbstractItemModel *model) | |
64 | \brief Use the \a model to provide data for the series. The model overrides possible user data |
|
64 | \brief Use the \a model to provide data for the series. The model overrides possible user data | |
65 | set with QChartSeries type specific data setters. For example if you call both |
|
65 | set with QChartSeries type specific data setters. For example if you call both | |
66 | QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is |
|
66 | QScatterSeries::addData() and QScatterSeries::setModel, only the data provided by the model is | |
67 | used by the series. Returns true if the model is valid for the series. |
|
67 | used by the series. Returns true if the model is valid for the series. | |
68 | */ |
|
68 | */ | |
69 |
|
69 | |||
70 | /*! |
|
70 | /*! | |
71 | \fn void QSeries::setName(QString name) |
|
71 | \fn void QSeries::setName(QString name) | |
72 | \brief Sets a \a name for the series. |
|
72 | \brief Sets a \a name for the series. | |
73 |
|
73 | |||
74 | The name of a series is shown in the legend for QXYSeries. |
|
74 | The name of a series is shown in the legend for QXYSeries. | |
75 | \sa QChart::setTitle() |
|
75 | \sa QChart::setTitle() | |
76 |
\sa QPieSlice::set |
|
76 | \sa QPieSlice::setLabel() | |
77 | \sa QBarSet::setName() |
|
77 | \sa QBarSet::setName() | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \fn QString QSeries::name() |
|
81 | \fn QString QSeries::name() | |
82 | \brief Returns the name of the series. |
|
82 | \brief Returns the name of the series. | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
85 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
86 | #include "moc_qseries.cpp" |
|
86 | #include "moc_qseries.cpp" | |
87 | QTCOMMERCIALCHART_END_NAMESPACE |
|
87 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now