##// END OF EJS Templates
Fix box-and-whiskers animations...
Miikka Heikkinen -
r2560:a2f72685ff33
parent child
Show More
@@ -26,7 +26,8
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
29 : m_item(item)
29 : QObject(item),
30 m_item(item)
30 31 {
31 32 }
32 33
@@ -73,6 +74,12 void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box)
73 74 animation->setStartData(box->m_data);
74 75 }
75 76
77 void BoxPlotAnimation::stopAll()
78 {
79 foreach (BoxWhiskersAnimation *animation, m_animations.values())
80 animation->stopAndDestroyLater();
81 }
82
76 83 //#include "moc_boxplotanimation_p.cpp"
77 84
78 85 QTCOMMERCIALCHART_END_NAMESPACE
@@ -39,8 +39,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 39
40 40 class BoxPlotChartItem;
41 41
42 class BoxPlotAnimation
42 class BoxPlotAnimation : public QObject
43 43 {
44 Q_OBJECT
44 45 public:
45 46 BoxPlotAnimation(BoxPlotChartItem *item);
46 47 ~BoxPlotAnimation();
@@ -50,6 +51,7 public:
50 51 ChartAnimation *boxChangeAnimation(BoxWhiskers *box);
51 52
52 53 void setAnimationStart(BoxWhiskers *box);
54 void stopAll();
53 55
54 56 protected:
55 57 BoxPlotChartItem *m_item;
@@ -58,9 +58,7 public: // from QVariantAnimation
58 58
59 59 protected:
60 60 friend class BoxPlotAnimation;
61 BoxPlotChartItem *m_item;
62 61 BoxWhiskers *m_box;
63 BoxWhiskersData *m_boxData;
64 62 bool m_moveMedianLine;
65 63 };
66 64
@@ -32,8 +32,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 32 BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item) :
33 33 ChartItem(series->d_func(), item),
34 34 m_series(series),
35 m_animation(0),
36 m_animate(0)
35 m_animation(0)
37 36 {
38 37 connect(series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), this, SLOT(handleBoxsetRemove(QList<QBoxSet *>)));
39 38 connect(series->d_func(), SIGNAL(restructuredBoxes()), this, SLOT(handleDataStructureChanged()));
@@ -75,7 +75,6 protected:
75 75 int m_seriesCount;
76 76
77 77 BoxPlotAnimation *m_animation;
78 bool m_animate;
79 78
80 79 QRectF m_boundingRect;
81 80 };
@@ -488,9 +488,11 void QBoxPlotSeriesPrivate::initializeAnimations(QChart::AnimationOptions option
488 488 item->animation()->stopAndDestroyLater();
489 489
490 490 if (options.testFlag(QChart::SeriesAnimations))
491 item->setAnimation(new BoxPlotAnimation(item));
491 m_animation = new BoxPlotAnimation(item);
492 492 else
493 item->setAnimation(0);
493 m_animation = 0;
494 item->setAnimation(m_animation);
495
494 496 QAbstractSeriesPrivate::initializeAnimations(options);
495 497 }
496 498
@@ -506,7 +508,11 void QBoxPlotSeriesPrivate::handleSeriesRemove(QAbstractSeries *series)
506 508 Q_Q(QBoxPlotSeries);
507 509
508 510 QBoxPlotSeries *removedSeries = static_cast<QBoxPlotSeries *>(series);
509 QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0);
511
512 if (q == removedSeries && m_animation) {
513 m_animation->stopAll();
514 QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0);
515 }
510 516
511 517 // Test if series removed is me, then don't do anything
512 518 if (q != removedSeries) {
@@ -37,6 +37,8
37 37
38 38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 39
40 class BoxPlotAnimation;
41
40 42 class QBoxPlotSeriesPrivate : public QAbstractSeriesPrivate
41 43 {
42 44 Q_OBJECT
@@ -85,6 +87,7 protected:
85 87 QPen m_pen;
86 88 QBrush m_brush;
87 89 int m_index;
90 BoxPlotAnimation *m_animation;
88 91
89 92 private:
90 93 Q_DECLARE_PUBLIC(QBoxPlotSeries)
General Comments 0
You need to be logged in to leave comments. Login now