@@ -25,8 +25,7 QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
25 | 25 | CustomSlice::CustomSlice(qreal value, QString label) |
|
26 | 26 | :QPieSlice(value, label) |
|
27 | 27 | { |
|
28 |
connect(this, SIGNAL(hover |
|
|
29 | connect(this, SIGNAL(hoverLeave()), this, SLOT(handleHoverLeave())); | |
|
28 | connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); | |
|
30 | 29 | } |
|
31 | 30 | |
|
32 | 31 | QBrush CustomSlice::originalBrush() |
@@ -34,17 +33,16 QBrush CustomSlice::originalBrush() | |||
|
34 | 33 | return m_originalBrush; |
|
35 | 34 | } |
|
36 | 35 | |
|
37 | void CustomSlice::handleHoverEnter() | |
|
36 | void CustomSlice::showHighlight(bool show) | |
|
38 | 37 | { |
|
39 | QBrush brush = this->brush(); | |
|
40 | m_originalBrush = brush; | |
|
41 | brush.setColor(brush.color().lighter()); | |
|
42 | setBrush(brush); | |
|
43 | } | |
|
44 | ||
|
45 | void CustomSlice::handleHoverLeave() | |
|
46 | { | |
|
47 | setBrush(m_originalBrush); | |
|
38 | if (show) { | |
|
39 | QBrush brush = this->brush(); | |
|
40 | m_originalBrush = brush; | |
|
41 | brush.setColor(brush.color().lighter()); | |
|
42 | setBrush(brush); | |
|
43 | } else { | |
|
44 | setBrush(m_originalBrush); | |
|
45 | } | |
|
48 | 46 | } |
|
49 | 47 | |
|
50 | 48 | #include "moc_customslice.cpp" |
@@ -35,8 +35,7 public: | |||
|
35 | 35 | QBrush originalBrush(); |
|
36 | 36 | |
|
37 | 37 | public Q_SLOTS: |
|
38 | void handleHoverEnter(); | |
|
39 | void handleHoverLeave(); | |
|
38 | void showHighlight(bool show); | |
|
40 | 39 | |
|
41 | 40 | private: |
|
42 | 41 | QBrush m_originalBrush; |
@@ -53,7 +53,7 MainWidget::MainWidget(QWidget* parent) | |||
|
53 | 53 | m_series->setLabelsVisible(); |
|
54 | 54 | chart->addSeries(m_series); |
|
55 | 55 | |
|
56 |
connect(m_series, SIGNAL(clicked(QPieSlice* |
|
|
56 | connect(m_series, SIGNAL(clicked(QPieSlice*)), this, SLOT(handleSliceClicked(QPieSlice*))); | |
|
57 | 57 | |
|
58 | 58 | // chart settings |
|
59 | 59 | m_themeComboBox = new QComboBox(); |
@@ -69,16 +69,20 MainWidget::MainWidget(QWidget* parent) | |||
|
69 | 69 | m_animationsCheckBox = new QCheckBox(); |
|
70 | 70 | m_animationsCheckBox->setCheckState(Qt::Checked); |
|
71 | 71 | |
|
72 | m_legendCheckBox = new QCheckBox(); | |
|
73 | ||
|
72 | 74 | QFormLayout* chartSettingsLayout = new QFormLayout(); |
|
73 | 75 | chartSettingsLayout->addRow("Theme", m_themeComboBox); |
|
74 | 76 | chartSettingsLayout->addRow("Antialiasing", m_aaCheckBox); |
|
75 | 77 | chartSettingsLayout->addRow("Animations", m_animationsCheckBox); |
|
78 | chartSettingsLayout->addRow("Legend", m_legendCheckBox); | |
|
76 | 79 | QGroupBox* chartSettings = new QGroupBox("Chart"); |
|
77 | 80 | chartSettings->setLayout(chartSettingsLayout); |
|
78 | 81 | |
|
79 | 82 | connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this ,SLOT(updateChartSettings())); |
|
80 | 83 | connect(m_aaCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); |
|
81 | 84 | connect(m_animationsCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); |
|
85 | connect(m_legendCheckBox, SIGNAL(toggled(bool)), this ,SLOT(updateChartSettings())); | |
|
82 | 86 | |
|
83 | 87 | // series settings |
|
84 | 88 | m_hPosition = new QDoubleSpinBox(); |
@@ -211,6 +215,11 void MainWidget::updateChartSettings() | |||
|
211 | 215 | m_chartView->chart()->setAnimationOptions(QChart::AllAnimations); |
|
212 | 216 | else |
|
213 | 217 | m_chartView->chart()->setAnimationOptions(QChart::NoAnimation); |
|
218 | ||
|
219 | if (m_legendCheckBox->checkState() == Qt::Checked) | |
|
220 | m_chartView->chart()->legend()->show(); | |
|
221 | else | |
|
222 | m_chartView->chart()->legend()->hide(); | |
|
214 | 223 | } |
|
215 | 224 | |
|
216 | 225 | void MainWidget::updateSerieSettings() |
@@ -240,10 +249,8 void MainWidget::updateSliceSettings() | |||
|
240 | 249 | m_slice->setExplodeDistanceFactor(m_sliceExplodedFactor->value()); |
|
241 | 250 | } |
|
242 | 251 | |
|
243 |
void MainWidget::handleSliceClicked(QPieSlice* slice |
|
|
252 | void MainWidget::handleSliceClicked(QPieSlice* slice) | |
|
244 | 253 | { |
|
245 | Q_UNUSED(buttons); | |
|
246 | ||
|
247 | 254 | m_slice = static_cast<CustomSlice*>(slice); |
|
248 | 255 | |
|
249 | 256 | // name |
@@ -51,7 +51,7 public Q_SLOTS: | |||
|
51 | 51 | void updateChartSettings(); |
|
52 | 52 | void updateSerieSettings(); |
|
53 | 53 | void updateSliceSettings(); |
|
54 |
void handleSliceClicked(QPieSlice* slice |
|
|
54 | void handleSliceClicked(QPieSlice* slice); | |
|
55 | 55 | void showFontDialog(); |
|
56 | 56 | void appendSlice(); |
|
57 | 57 | void insertSlice(); |
@@ -61,6 +61,7 private: | |||
|
61 | 61 | QComboBox *m_themeComboBox; |
|
62 | 62 | QCheckBox *m_aaCheckBox; |
|
63 | 63 | QCheckBox *m_animationsCheckBox; |
|
64 | QCheckBox *m_legendCheckBox; | |
|
64 | 65 | |
|
65 | 66 | QChartView* m_chartView; |
|
66 | 67 | QPieSeries* m_series; |
@@ -30,8 +30,7 DrilldownSlice::DrilldownSlice(qreal value, QString prefix, QAbstractSeries* dri | |||
|
30 | 30 | updateLabel(); |
|
31 | 31 | setLabelFont(QFont("Arial", 8)); |
|
32 | 32 | connect(this, SIGNAL(changed()), this, SLOT(updateLabel())); |
|
33 |
connect(this, SIGNAL(hover |
|
|
34 | connect(this, SIGNAL(hoverLeave()), this, SLOT(hideHighlight())); | |
|
33 | connect(this, SIGNAL(hovered(bool)), this, SLOT(showHighlight(bool))); | |
|
35 | 34 | } |
|
36 | 35 | |
|
37 | 36 | DrilldownSlice::~DrilldownSlice() |
@@ -55,16 +54,10 void DrilldownSlice::updateLabel() | |||
|
55 | 54 | setLabel(label); |
|
56 | 55 | } |
|
57 | 56 | |
|
58 | void DrilldownSlice::showHighlight() | |
|
57 | void DrilldownSlice::showHighlight(bool show) | |
|
59 | 58 | { |
|
60 | setExploded(); | |
|
61 | setLabelVisible(); | |
|
62 | } | |
|
63 | ||
|
64 | void DrilldownSlice::hideHighlight() | |
|
65 | { | |
|
66 | setExploded(false); | |
|
67 | setLabelVisible(false); | |
|
59 | setExploded(show); | |
|
60 | setLabelVisible(show); | |
|
68 | 61 | } |
|
69 | 62 | |
|
70 | 63 | #include "moc_drilldownslice.cpp" |
@@ -39,8 +39,7 public: | |||
|
39 | 39 | |
|
40 | 40 | public Q_SLOTS: |
|
41 | 41 | void updateLabel(); |
|
42 | void showHighlight(); | |
|
43 | void hideHighlight(); | |
|
42 | void showHighlight(bool show); | |
|
44 | 43 | |
|
45 | 44 | private: |
|
46 | 45 | QAbstractSeries* m_drilldownSeries; |
@@ -58,12 +58,12 int main(int argc, char *argv[]) | |||
|
58 | 58 | foreach (QString month, months) |
|
59 | 59 | *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); |
|
60 | 60 | |
|
61 |
QObject::connect(series, SIGNAL(clicked(QPieSlice* |
|
|
61 | QObject::connect(series, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); | |
|
62 | 62 | |
|
63 | 63 | *yearSeries << new DrilldownSlice(series->sum(), name, series); |
|
64 | 64 | } |
|
65 | 65 | |
|
66 |
QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice* |
|
|
66 | QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), chart, SLOT(handleSliceClicked(QPieSlice*))); | |
|
67 | 67 | |
|
68 | 68 | chart->changeSeries(yearSeries); |
|
69 | 69 |
@@ -154,7 +154,7 void BarLegendMarker::updated() | |||
|
154 | 154 | PieLegendMarker::PieLegendMarker(QPieSeries* series,QPieSlice *pieslice, QLegend *legend) : LegendMarker(series,legend), |
|
155 | 155 | m_pieslice(pieslice) |
|
156 | 156 | { |
|
157 |
QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL( |
|
|
157 | QObject::connect(this, SIGNAL(selected()),pieslice, SIGNAL(clicked())); | |
|
158 | 158 | QObject::connect(pieslice, SIGNAL(changed()), this, SLOT(updated())); |
|
159 | 159 | updated(); |
|
160 | 160 | } |
@@ -35,6 +35,7 | |||
|
35 | 35 | #include "qpercentbarseries.h" |
|
36 | 36 | #include "qbarset.h" |
|
37 | 37 | #include "qpieseries.h" |
|
38 | #include "qpieseries_p.h" | |
|
38 | 39 | #include "qpieslice.h" |
|
39 | 40 | #include "chartpresenter_p.h" |
|
40 | 41 | #include <QPainter> |
@@ -416,8 +417,9 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |||
|
416 | 417 | if(series->type() == QAbstractSeries::SeriesTypePie) |
|
417 | 418 | { |
|
418 | 419 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
419 | QObject::connect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
|
420 |
QObject::connect( |
|
|
420 | QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries); | |
|
421 | QObject::connect(d, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
|
422 | QObject::connect(d, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
|
421 | 423 | } |
|
422 | 424 | |
|
423 | 425 | updateLayout(); |
@@ -438,20 +440,21 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |||
|
438 | 440 | if(series->type() == QAbstractSeries::SeriesTypePie) |
|
439 | 441 | { |
|
440 | 442 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
441 | QObject::disconnect(pieSeries,SIGNAL(added(QList<QPieSlice*>)),this,SLOT(handleUpdateSeries())); | |
|
442 |
QObject::disconnect( |
|
|
443 | QPieSeriesPrivate *d = QPieSeriesPrivate::seriesData(*pieSeries); | |
|
444 | QObject::disconnect(d, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
|
445 | QObject::disconnect(d, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
|
443 | 446 | } |
|
444 | 447 | |
|
445 | 448 | updateLayout(); |
|
446 | 449 | } |
|
447 | 450 | |
|
448 | void QLegendPrivate::handleUpdateSeries() | |
|
451 | void QLegendPrivate::handleUpdatePieSeries() | |
|
449 | 452 | { |
|
450 | 453 | //TODO: reimplement to be optimal |
|
451 |
Q |
|
|
452 |
Q_ASSERT( |
|
|
453 |
handleSeriesRemoved( |
|
|
454 |
handleSeriesAdded( |
|
|
454 | QPieSeriesPrivate* d = qobject_cast<QPieSeriesPrivate *> (sender()); | |
|
455 | Q_ASSERT(d->q_func()); | |
|
456 | handleSeriesRemoved(d->q_func()); | |
|
457 | handleSeriesAdded(d->q_func(), 0); | |
|
455 | 458 | } |
|
456 | 459 | |
|
457 | 460 | #include "moc_qlegend.cpp" |
@@ -50,7 +50,7 public: | |||
|
50 | 50 | public Q_SLOTS: |
|
51 | 51 | void handleSeriesAdded(QAbstractSeries *series, Domain *domain); |
|
52 | 52 | void handleSeriesRemoved(QAbstractSeries *series); |
|
53 | void handleUpdateSeries(); //TODO remove this function | |
|
53 | void handleUpdatePieSeries(); //TODO remove this function | |
|
54 | 54 | |
|
55 | 55 | private: |
|
56 | 56 | QLegend *q_ptr; |
@@ -22,6 +22,7 | |||
|
22 | 22 | #include "piesliceitem_p.h" |
|
23 | 23 | #include "qpieslice.h" |
|
24 | 24 | #include "qpieseries.h" |
|
25 | #include "qpieseries_p.h" | |
|
25 | 26 | #include "chartpresenter_p.h" |
|
26 | 27 | #include "chartdataset_p.h" |
|
27 | 28 | #include "chartanimator_p.h" |
@@ -35,10 +36,12 PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter) | |||
|
35 | 36 | m_series(series) |
|
36 | 37 | { |
|
37 | 38 | Q_ASSERT(series); |
|
38 | connect(series, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleSlicesAdded(QList<QPieSlice*>))); | |
|
39 | connect(series, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleSlicesRemoved(QList<QPieSlice*>))); | |
|
40 | connect(series, SIGNAL(piePositionChanged()), this, SLOT(handlePieLayoutChanged())); | |
|
41 | connect(series, SIGNAL(pieSizeChanged()), this, SLOT(handlePieLayoutChanged())); | |
|
39 | ||
|
40 | 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(handlePieLayoutChanged())); | |
|
44 | connect(d, SIGNAL(pieSizeChanged()), this, SLOT(handlePieLayoutChanged())); | |
|
42 | 45 | |
|
43 | 46 | QTimer::singleShot(0, this, SLOT(initialize())); // TODO: get rid of this |
|
44 | 47 | |
@@ -75,9 +78,8 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |||
|
75 | 78 | PieSliceItem* item = new PieSliceItem(this); |
|
76 | 79 | m_slices.insert(s, item); |
|
77 | 80 | connect(s, SIGNAL(changed()), this, SLOT(handleSliceChanged())); |
|
78 |
connect(item, SIGNAL(clicked(Qt::MouseButtons)), s, SIGNAL(clicked( |
|
|
79 |
connect(item, SIGNAL(hover |
|
|
80 | connect(item, SIGNAL(hoverLeave()), s, SIGNAL(hoverLeave())); | |
|
81 | connect(item, SIGNAL(clicked(Qt::MouseButtons)), s, SIGNAL(clicked())); | |
|
82 | connect(item, SIGNAL(hovered(bool)), s, SIGNAL(hovered(bool))); | |
|
81 | 83 | |
|
82 | 84 | PieSliceData data = sliceData(s); |
|
83 | 85 |
@@ -85,12 +85,12 void PieSliceItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*op | |||
|
85 | 85 | |
|
86 | 86 | void PieSliceItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/) |
|
87 | 87 | { |
|
88 | emit hoverEnter(); // TODO: refactor emit hover(somebooleanvalue) | |
|
88 | emit hovered(true); | |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | void PieSliceItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) |
|
92 | 92 | { |
|
93 | emit hoverLeave(); // TODO: refactor emit hover(somebooleanvalue) | |
|
93 | emit hovered(false); | |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | void PieSliceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) |
@@ -55,8 +55,7 public: // from QGraphicsItem | |||
|
55 | 55 | |
|
56 | 56 | Q_SIGNALS: |
|
57 | 57 | void clicked(Qt::MouseButtons buttons); |
|
58 |
void hover |
|
|
59 | void hoverLeave(); | |
|
58 | void hovered(bool state); | |
|
60 | 59 | |
|
61 | 60 | public: |
|
62 | 61 | void setSliceData(PieSliceData sliceData); |
@@ -162,12 +162,11 void QPieSeries::append(QList<QPieSlice*> slices) | |||
|
162 | 162 | |
|
163 | 163 | foreach (QPieSlice* s, slices) { |
|
164 | 164 | connect(s, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
165 |
connect(s, SIGNAL(clicked( |
|
|
166 |
connect(s, SIGNAL(hover |
|
|
167 | connect(s, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
|
165 | connect(s, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
|
166 | connect(s, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
|
168 | 167 | } |
|
169 | 168 | |
|
170 | emit added(slices); | |
|
169 | emit d->added(slices); | |
|
171 | 170 | } |
|
172 | 171 | |
|
173 | 172 | /*! |
@@ -215,11 +214,10 void QPieSeries::insert(int index, QPieSlice* slice) | |||
|
215 | 214 | d->updateDerivativeData(); |
|
216 | 215 | |
|
217 | 216 | connect(slice, SIGNAL(changed()), d, SLOT(sliceChanged())); |
|
218 |
connect(slice, SIGNAL(clicked( |
|
|
219 |
connect(slice, SIGNAL(hover |
|
|
220 | connect(slice, SIGNAL(hoverLeave()), d, SLOT(sliceHoverLeave())); | |
|
217 | connect(slice, SIGNAL(clicked()), d, SLOT(sliceClicked())); | |
|
218 | connect(slice, SIGNAL(hovered(bool)), d, SLOT(sliceHovered(bool))); | |
|
221 | 219 | |
|
222 | emit added(QList<QPieSlice*>() << slice); | |
|
220 | emit d->added(QList<QPieSlice*>() << slice); | |
|
223 | 221 | } |
|
224 | 222 | |
|
225 | 223 | /*! |
@@ -237,7 +235,7 void QPieSeries::remove(QPieSlice* slice) | |||
|
237 | 235 | |
|
238 | 236 | d->updateDerivativeData(); |
|
239 | 237 | |
|
240 | emit removed(QList<QPieSlice*>() << slice); | |
|
238 | emit d->removed(QList<QPieSlice*>() << slice); | |
|
241 | 239 | |
|
242 | 240 | delete slice; |
|
243 | 241 | slice = 0; |
@@ -260,7 +258,7 void QPieSeries::clear() | |||
|
260 | 258 | |
|
261 | 259 | d->updateDerivativeData(); |
|
262 | 260 | |
|
263 | emit removed(slices); | |
|
261 | emit d->removed(slices); | |
|
264 | 262 | } |
|
265 | 263 | |
|
266 | 264 | /*! |
@@ -294,14 +292,14 void QPieSeries::setHorizontalPosition(qreal relativePosition) | |||
|
294 | 292 | { |
|
295 | 293 | Q_D(QPieSeries); |
|
296 | 294 | if (d->setRealValue(d->m_pieRelativeHorPos, relativePosition, 1.0)) |
|
297 | emit piePositionChanged(); | |
|
295 | emit d->piePositionChanged(); | |
|
298 | 296 | } |
|
299 | 297 | |
|
300 | 298 | void QPieSeries::setVerticalPosition(qreal relativePosition) |
|
301 | 299 | { |
|
302 | 300 | Q_D(QPieSeries); |
|
303 | 301 | if (d->setRealValue(d->m_pieRelativeVerPos, relativePosition, 1.0)) |
|
304 | emit piePositionChanged(); | |
|
302 | emit d->piePositionChanged(); | |
|
305 | 303 | } |
|
306 | 304 | |
|
307 | 305 | qreal QPieSeries::horizontalPosition() const |
@@ -320,7 +318,7 void QPieSeries::setPieSize(qreal relativeSize) | |||
|
320 | 318 | { |
|
321 | 319 | Q_D(QPieSeries); |
|
322 | 320 | if (d->setRealValue(d->m_pieRelativeSize, relativeSize, 1.0)) |
|
323 | emit pieSizeChanged(); | |
|
321 | emit d->pieSizeChanged(); | |
|
324 | 322 | } |
|
325 | 323 | |
|
326 | 324 | qreal QPieSeries::pieSize() const |
@@ -397,59 +395,21 qreal QPieSeries::sum() const | |||
|
397 | 395 | } |
|
398 | 396 | |
|
399 | 397 | /*! |
|
400 |
\fn void QPieSeries::clicked(QPieSlice* slice |
|
|
398 | \fn void QPieSeries::clicked(QPieSlice* slice) | |
|
401 | 399 | |
|
402 |
This signal is emitted when a \a slice has been clicked |
|
|
400 | This signal is emitted when a \a slice has been clicked. | |
|
403 | 401 | |
|
404 | 402 | \sa QPieSlice::clicked() |
|
405 | 403 | */ |
|
406 | 404 | |
|
407 | 405 | /*! |
|
408 |
\fn void QPieSeries::hover |
|
|
406 | \fn void QPieSeries::hovered(QPieSlice* slice, bool state) | |
|
409 | 407 | |
|
410 | This signal is emitted when user has hovered over a \a slice. | |
|
408 | This signal is emitted when user has hovered over or away from the \a slice. | |
|
411 | 409 | |
|
412 | \sa QPieSlice::hoverEnter() | |
|
413 | */ | |
|
414 | ||
|
415 | /*! | |
|
416 | \fn void QPieSeries::hoverLeave(QPieSlice* slice) | |
|
417 | ||
|
418 | This signal is emitted when user has hovered away from a \a slice. | |
|
419 | ||
|
420 | \sa QPieSlice::hoverLeave() | |
|
421 | */ | |
|
422 | ||
|
423 | /*! | |
|
424 | \fn void QPieSeries::added(QList<QPieSlice*> slices) | |
|
425 | ||
|
426 | This signal is emitted when \a slices has been added to the series. | |
|
410 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
|
427 | 411 | |
|
428 | \sa append(), insert() | |
|
429 | */ | |
|
430 | ||
|
431 | /*! | |
|
432 | \fn void QPieSeries::removed(QList<QPieSlice*> slices) | |
|
433 | ||
|
434 | This signal is emitted when \a slices has been removed from the series. | |
|
435 | ||
|
436 | \sa remove(), clear() | |
|
437 | */ | |
|
438 | ||
|
439 | /*! | |
|
440 | \fn void QPieSeries::piePositionChanged() | |
|
441 | ||
|
442 | This signal is emitted when pie position has changed. | |
|
443 | ||
|
444 | \sa verticalPosition(), setVerticalPosition(), horizontalPosition(), setHorizontalPosition() | |
|
445 | */ | |
|
446 | ||
|
447 | /*! | |
|
448 | \fn void QPieSeries::pieSizeChanged() | |
|
449 | ||
|
450 | This signal is emitted when pie size has changed. | |
|
451 | ||
|
452 | \sa pieSize(), setPieSize() | |
|
412 | \sa QPieSlice::hovered() | |
|
453 | 413 | */ |
|
454 | 414 | |
|
455 | 415 | /*! |
@@ -582,34 +542,31 void QPieSeriesPrivate::updateDerivativeData() | |||
|
582 | 542 | PieSliceData::data(s).emitChangedSignal(s); |
|
583 | 543 | } |
|
584 | 544 | |
|
585 | void QPieSeriesPrivate::sliceChanged() | |
|
545 | QPieSeriesPrivate* QPieSeriesPrivate::seriesData(QPieSeries &series) | |
|
586 | 546 | { |
|
587 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
|
588 | updateDerivativeData(); | |
|
547 | return series.d_func(); | |
|
589 | 548 | } |
|
590 | 549 | |
|
591 |
void QPieSeriesPrivate::sliceC |
|
|
550 | void QPieSeriesPrivate::sliceChanged() | |
|
592 | 551 | { |
|
593 |
Q |
|
|
594 | Q_ASSERT(m_slices.contains(slice)); | |
|
595 | Q_Q(QPieSeries); | |
|
596 | emit q->clicked(slice, buttons); | |
|
552 | Q_ASSERT(m_slices.contains(qobject_cast<QPieSlice *>(sender()))); | |
|
553 | updateDerivativeData(); | |
|
597 | 554 | } |
|
598 | 555 | |
|
599 |
void QPieSeriesPrivate::slice |
|
|
556 | void QPieSeriesPrivate::sliceClicked() | |
|
600 | 557 | { |
|
601 | 558 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
602 | 559 | Q_ASSERT(m_slices.contains(slice)); |
|
603 | 560 | Q_Q(QPieSeries); |
|
604 |
emit q-> |
|
|
561 | emit q->clicked(slice); | |
|
605 | 562 | } |
|
606 | 563 | |
|
607 |
void QPieSeriesPrivate::sliceHover |
|
|
564 | void QPieSeriesPrivate::sliceHovered(bool state) | |
|
608 | 565 | { |
|
609 | 566 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
610 | 567 | Q_ASSERT(m_slices.contains(slice)); |
|
611 | 568 | Q_Q(QPieSeries); |
|
612 |
emit q->hover |
|
|
569 | emit q->hovered(slice, state); | |
|
613 | 570 | } |
|
614 | 571 | |
|
615 | 572 | void QPieSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) |
@@ -40,56 +40,44 public: | |||
|
40 | 40 | explicit QPieSeries(QObject *parent = 0); |
|
41 | 41 | virtual ~QPieSeries(); |
|
42 | 42 | |
|
43 | public: // from QChartSeries | |
|
44 | 43 | QSeriesType type() const; |
|
45 | 44 | |
|
46 | public: | |
|
47 | ||
|
48 | // slice setters | |
|
49 | 45 | void append(QPieSlice* slice); |
|
50 | 46 | void append(QList<QPieSlice*> slices); |
|
47 | QPieSeries& operator << (QPieSlice* slice); | |
|
48 | QPieSlice* append(qreal value, QString name); | |
|
51 | 49 | void insert(int index, QPieSlice* slice); |
|
52 | 50 | void replace(QList<QPieSlice*> slices); |
|
53 | 51 | void remove(QPieSlice* slice); |
|
54 | 52 | void clear(); |
|
55 | 53 | |
|
56 | // slice getters | |
|
57 | 54 | QList<QPieSlice*> slices() const; |
|
58 | ||
|
59 | // calculated data | |
|
60 | 55 | int count() const; |
|
61 | 56 | bool isEmpty() const; |
|
57 | ||
|
62 | 58 | qreal sum() const; |
|
63 | 59 | |
|
64 | // pie customization | |
|
65 | 60 | void setHorizontalPosition(qreal relativePosition); |
|
66 | 61 | qreal horizontalPosition() const; |
|
67 | 62 | void setVerticalPosition(qreal relativePosition); |
|
68 | 63 | qreal verticalPosition() const; |
|
64 | ||
|
69 | 65 | void setPieSize(qreal relativeSize); |
|
70 | 66 | qreal pieSize() const; |
|
67 | ||
|
71 | 68 | void setPieStartAngle(qreal startAngle); |
|
72 | 69 | qreal pieStartAngle() const; |
|
73 | 70 | void setPieEndAngle(qreal endAngle); |
|
74 | 71 | qreal pieEndAngle() const; |
|
75 | 72 | |
|
76 | // convenience function | |
|
77 | QPieSeries& operator << (QPieSlice* slice); | |
|
78 | QPieSlice* append(qreal value, QString name); | |
|
79 | 73 | void setLabelsVisible(bool visible = true); |
|
80 | 74 | |
|
81 | // data from model | |
|
82 | 75 | bool setModel(QAbstractItemModel* model); |
|
83 | 76 | void setModelMapping(int modelValuesLine, int modelLabelsLine, Qt::Orientation orientation = Qt::Vertical); |
|
84 | 77 | |
|
85 | 78 | Q_SIGNALS: |
|
86 |
void clicked(QPieSlice* slice |
|
|
87 |
void hover |
|
|
88 | void hoverLeave(QPieSlice* slice); | |
|
89 | void added(QList<QPieSlice*> slices); | |
|
90 | void removed(QList<QPieSlice*> slices); | |
|
91 | void piePositionChanged(); | |
|
92 | void pieSizeChanged(); | |
|
79 | void clicked(QPieSlice* slice); | |
|
80 | void hovered(QPieSlice* slice, bool state); | |
|
93 | 81 | |
|
94 | 82 | private: |
|
95 | 83 | Q_DECLARE_PRIVATE(QPieSeries) |
@@ -27,6 +27,7 | |||
|
27 | 27 | class QModelIndex; |
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | class QLegendPrivate; | |
|
30 | 31 | |
|
31 | 32 | class QPieSeriesPrivate : public QAbstractSeriesPrivate |
|
32 | 33 | { |
@@ -37,16 +38,23 public: | |||
|
37 | 38 | ~QPieSeriesPrivate(); |
|
38 | 39 | |
|
39 | 40 | void scaleDomain(Domain& domain); |
|
40 |
Chart* createGraphics(ChartPresenter* |
|
|
41 |
QList<LegendMarker*> createLegendMarker(QLegend* |
|
|
41 | Chart* createGraphics(ChartPresenter *presenter); | |
|
42 | QList<LegendMarker*> createLegendMarker(QLegend *legend); | |
|
42 | 43 | |
|
43 | 44 | void updateDerivativeData(); |
|
44 | 45 | |
|
46 | static QPieSeriesPrivate* seriesData(QPieSeries &series); | |
|
47 | ||
|
48 | Q_SIGNALS: | |
|
49 | void added(QList<QPieSlice*> slices); | |
|
50 | void removed(QList<QPieSlice*> slices); | |
|
51 | void piePositionChanged(); | |
|
52 | void pieSizeChanged(); | |
|
53 | ||
|
45 | 54 | public Q_SLOTS: |
|
46 | 55 | void sliceChanged(); |
|
47 |
void sliceClicked( |
|
|
48 |
void sliceHover |
|
|
49 | void sliceHoverLeave(); | |
|
56 | void sliceClicked(); | |
|
57 | void sliceHovered(bool state); | |
|
50 | 58 | void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); |
|
51 | 59 | void modelDataAdded(QModelIndex parent, int start, int end); |
|
52 | 60 | void modelDataRemoved(QModelIndex parent, int start, int end); |
@@ -65,7 +73,9 public: | |||
|
65 | 73 | int m_mapValues; |
|
66 | 74 | int m_mapLabels; |
|
67 | 75 | Qt::Orientation m_mapOrientation; |
|
76 | ||
|
68 | 77 | private: |
|
78 | friend class QLegendPrivate; | |
|
69 | 79 | Q_DECLARE_PUBLIC(QPieSeries) |
|
70 | 80 | }; |
|
71 | 81 |
@@ -228,28 +228,21 qreal QPieSlice::labelArmLengthFactor() const | |||
|
228 | 228 | } |
|
229 | 229 | |
|
230 | 230 | /*! |
|
231 |
\fn void QPieSlice::clicked( |
|
|
231 | \fn void QPieSlice::clicked() | |
|
232 | 232 | |
|
233 | 233 | This signal is emitted when user has clicked the slice. |
|
234 | Parameter \a buttons hold the information about the clicked mouse buttons. | |
|
235 | 234 | |
|
236 | 235 | \sa QPieSeries::clicked() |
|
237 | 236 | */ |
|
238 | 237 | |
|
239 | 238 | /*! |
|
240 |
\fn void QPieSlice::hover |
|
|
239 | \fn void QPieSlice::hovered(bool state) | |
|
241 | 240 | |
|
242 | This signal is emitted when user has hovered over the slice. | |
|
241 | This signal is emitted when user has hovered over or away from the slice. | |
|
243 | 242 | |
|
244 | \sa QPieSeries::hoverEnter() | |
|
245 | */ | |
|
246 | ||
|
247 | /*! | |
|
248 | \fn void QPieSlice::hoverLeave() | |
|
249 | ||
|
250 | This signal is emitted when user has hovered away from the slice. | |
|
243 | \a state is true when user has hovered over the slice and false when hover has moved away from the slice. | |
|
251 | 244 | |
|
252 |
\sa QPieSeries::hover |
|
|
245 | \sa QPieSeries::hovered() | |
|
253 | 246 | */ |
|
254 | 247 | |
|
255 | 248 | /*! |
@@ -259,12 +252,6 qreal QPieSlice::labelArmLengthFactor() const | |||
|
259 | 252 | */ |
|
260 | 253 | |
|
261 | 254 | /*! |
|
262 | \fn void QPieSlice::selected() | |
|
263 | ||
|
264 | This signal emitted when this slice has been clicked in the legend. | |
|
265 | */ | |
|
266 | ||
|
267 | /*! | |
|
268 | 255 | Sets the \a value of this slice. |
|
269 | 256 | \sa value() |
|
270 | 257 | */ |
@@ -41,7 +41,6 public: | |||
|
41 | 41 | QPieSlice(qreal value, QString label, QObject *parent = 0); |
|
42 | 42 | virtual ~QPieSlice(); |
|
43 | 43 | |
|
44 | // data | |
|
45 | 44 | void setValue(qreal value); |
|
46 | 45 | qreal value() const; |
|
47 | 46 | void setLabel(QString label); |
@@ -51,12 +50,6 public: | |||
|
51 | 50 | void setExploded(bool exploded = true); |
|
52 | 51 | bool isExploded() const; |
|
53 | 52 | |
|
54 | // generated data | |
|
55 | qreal percentage() const; | |
|
56 | qreal startAngle() const; | |
|
57 | qreal endAngle() const; | |
|
58 | ||
|
59 | // customization | |
|
60 | 53 | void setPen(const QPen &pen); |
|
61 | 54 | QPen pen() const; |
|
62 | 55 | void setBrush(const QBrush &brush); |
@@ -65,17 +58,20 public: | |||
|
65 | 58 | QPen labelPen() const; |
|
66 | 59 | void setLabelFont(const QFont &font); |
|
67 | 60 | QFont labelFont() const; |
|
61 | ||
|
68 | 62 | void setLabelArmLengthFactor(qreal factor); |
|
69 | 63 | qreal labelArmLengthFactor() const; |
|
70 | 64 | void setExplodeDistanceFactor(qreal factor); |
|
71 | 65 | qreal explodeDistanceFactor() const; |
|
72 | 66 | |
|
67 | qreal percentage() const; | |
|
68 | qreal startAngle() const; | |
|
69 | qreal endAngle() const; | |
|
70 | ||
|
73 | 71 | Q_SIGNALS: |
|
74 |
void clicked( |
|
|
75 |
void hover |
|
|
76 | void hoverLeave(); | |
|
72 | void clicked(); | |
|
73 | void hovered(bool state); | |
|
77 | 74 | void changed(); |
|
78 | void selected(); | |
|
79 | 75 | |
|
80 | 76 | private: |
|
81 | 77 | friend class PieSliceData; |
General Comments 0
You need to be logged in to leave comments.
Login now