##// END OF EJS Templates
Remove click exploding and hover highlighting from pie series API. User should always implement their own.
Jani Honkonen -
r436:b334955b5e36
parent child
Show More
@@ -25,11 +25,6 int main(int argc, char *argv[])
25 25 chartView->addSeries(series);
26 26 //! [1]
27 27
28 //! [2]
29 series->setHoverHighlighting();
30 series->setClickExplodes();
31 //! [2]
32
33 28 window.setCentralWidget(chartView);
34 29 window.resize(600, 600);
35 30 window.show();
@@ -79,7 +79,6 int main(int argc, char *argv[])
79 79
80 80 QPieSeries* yearSeries = new QPieSeries(drilldownChart);
81 81 yearSeries->setTitle("Sales by year - All");
82 yearSeries->setHoverHighlighting();
83 82
84 83 QList<QString> months;
85 84 months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
@@ -89,7 +88,6 int main(int argc, char *argv[])
89 88 foreach (QString name, names) {
90 89 QPieSeries* series = new QPieSeries(drilldownChart);
91 90 series->setTitle("Sales by month - " + name);
92 series->setHoverHighlighting();
93 91
94 92 foreach (QString month, months)
95 93 *series << new DrilldownSlice(qrand() % 1000, month, yearSeries);
@@ -110,9 +110,6 bool QPieSeries::ChangeSet::isEmpty() const
110 110
111 111 By default the pie is defined as a full pie but it can be a partial pie.
112 112 This can be done by setting a starting angle and angle span to the series.
113
114 To help with the most common user interaction scenarions there some convenience functions.
115 Like exploding a slice when clicked and higlighting when user hovers over a slice.
116 113 */
117 114
118 115 /*!
@@ -341,36 +338,6 void QPieSeries::setLabelsVisible(bool visible)
341 338 }
342 339
343 340 /*!
344 Convenience method for exploding a slice when user clicks the pie. Set \a enable to true to
345 explode slices by clicking.
346
347 \sa QPieSlice::isExploded(), QPieSlice::setExploded(), QPieSlice::setExplodeDistance()
348 */
349 void QPieSeries::setClickExplodes(bool enable)
350 {
351 if (enable)
352 connect(this, SIGNAL(clicked(QPieSlice*)), this, SLOT(toggleExploded(QPieSlice*)));
353 else
354 disconnect(this, SLOT(toggleExploded(QPieSlice*)));
355 }
356
357 /*!
358 Convenience method for highlighting a slice when user hovers over the slice.
359 It changes the slice color to be lighter and shows the label of the slice.
360 Set \a enable to true to highlight a slice when user hovers on top of it.
361 */
362 void QPieSeries::setHoverHighlighting(bool enable)
363 {
364 if (enable) {
365 connect(this, SIGNAL(hoverEnter(QPieSlice*)), this, SLOT(highlightOn(QPieSlice*)));
366 connect(this, SIGNAL(hoverLeave(QPieSlice*)), this, SLOT(highlightOff(QPieSlice*)));
367 } else {
368 disconnect(this, SLOT(hoverEnter(QPieSlice*)));
369 disconnect(this, SLOT(hoverLeave(QPieSlice*)));
370 }
371 }
372
373 /*!
374 341 Returns the sum of all slice values in this series.
375 342
376 343 \sa QPieSlice::value(), QPieSlice::setValue()
@@ -462,26 +429,6 void QPieSeries::sliceHoverLeave()
462 429 emit hoverLeave(slice);
463 430 }
464 431
465 void QPieSeries::toggleExploded(QPieSlice* slice)
466 {
467 Q_ASSERT(slice);
468 slice->setExploded(!slice->isExploded());
469 }
470
471 void QPieSeries::highlightOn(QPieSlice* slice)
472 {
473 Q_ASSERT(slice);
474 QColor c = slice->brush().color().lighter();
475 slice->setBrush(c);
476 }
477
478 void QPieSeries::highlightOff(QPieSlice* slice)
479 {
480 Q_ASSERT(slice);
481 QColor c = slice->brush().color().darker(150);
482 slice->setBrush(c);
483 }
484
485 432 void QPieSeries::updateDerivativeData()
486 433 {
487 434 m_total = 0;
@@ -76,8 +76,6 public:
76 76 void setSpan(qreal startAngle, qreal angleSpan);
77 77
78 78 void setLabelsVisible(bool visible = true);
79 void setClickExplodes(bool enable = true);
80 void setHoverHighlighting(bool enable = true);
81 79
82 80 qreal total() const;
83 81
@@ -105,9 +103,6 private Q_SLOTS: // TODO: should be private and not visible in the interface at
105 103 void sliceClicked();
106 104 void sliceHoverEnter();
107 105 void sliceHoverLeave();
108 void toggleExploded(QPieSlice* slice);
109 void highlightOn(QPieSlice* slice);
110 void highlightOff(QPieSlice* slice);
111 106
112 107 private:
113 108 void updateDerivativeData();
@@ -284,7 +284,7 void QPieSlice::setLabelVisible(bool visible)
284 284
285 285 /*!
286 286 Sets this slice \a exploded.
287 \sa isExploded(), setExplodeDistance(), QPieSeries::setClickExplodes()
287 \sa isExploded(), setExplodeDistance()
288 288 */
289 289 void QPieSlice::setExploded(bool exploded)
290 290 {
@@ -297,7 +297,7 void QPieSlice::setExploded(bool exploded)
297 297 /*!
298 298 Sets the explosion \a distance of this slice.
299 299 It is the distance the slice is moved away from the pie center.
300 \sa explodeDistance(), isExploded(), QPieSeries::setClickExplodes()
300 \sa explodeDistance(), isExploded()
301 301 */
302 302 void QPieSlice::setExplodeDistance(qreal distance)
303 303 {
General Comments 0
You need to be logged in to leave comments. Login now