@@ -43,10 +43,10 PieChartItem::PieChartItem(QPieSeries *series, ChartPresenter* presenter) | |||||
43 | connect(d, SIGNAL(piePositionChanged()), this, SLOT(updateLayout())); |
|
43 | connect(d, SIGNAL(piePositionChanged()), this, SLOT(updateLayout())); | |
44 | connect(d, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout())); |
|
44 | connect(d, SIGNAL(pieSizeChanged()), this, SLOT(updateLayout())); | |
45 |
|
45 | |||
46 | QTimer::singleShot(0, this, SLOT(initialize())); // TODO: get rid of this |
|
|||
47 |
|
||||
48 | // Note: the following does not affect as long as the item does not have anything to paint |
|
46 | // Note: the following does not affect as long as the item does not have anything to paint | |
49 | setZValue(ChartPresenter::PieSeriesZValue); |
|
47 | setZValue(ChartPresenter::PieSeriesZValue); | |
|
48 | ||||
|
49 | // Note: will not create slice items until we have a proper rectangle to draw on. | |||
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | PieChartItem::~PieChartItem() |
|
52 | PieChartItem::~PieChartItem() | |
@@ -59,6 +59,11 void PieChartItem::handleGeometryChanged(const QRectF& rect) | |||||
59 | prepareGeometryChange(); |
|
59 | prepareGeometryChange(); | |
60 | m_rect = rect; |
|
60 | m_rect = rect; | |
61 | updateLayout(); |
|
61 | updateLayout(); | |
|
62 | ||||
|
63 | // This is for delayed initialization of the slice items during startup. | |||
|
64 | // It ensures that startup animation originates from the correct position. | |||
|
65 | if (m_sliceItems.isEmpty()) | |||
|
66 | handleSlicesAdded(m_series->slices()); | |||
62 | } |
|
67 | } | |
63 |
|
68 | |||
64 | void PieChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
69 | void PieChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) | |
@@ -86,11 +91,6 void PieChartItem::rangeYChanged(qreal min, qreal max, int tickYCount) | |||||
86 | // does not apply to pie |
|
91 | // does not apply to pie | |
87 | } |
|
92 | } | |
88 |
|
93 | |||
89 | void PieChartItem::initialize() |
|
|||
90 | { |
|
|||
91 | handleSlicesAdded(m_series->slices()); |
|
|||
92 | } |
|
|||
93 |
|
||||
94 | void PieChartItem::updateLayout() |
|
94 | void PieChartItem::updateLayout() | |
95 | { |
|
95 | { | |
96 | // find pie center coordinates |
|
96 | // find pie center coordinates | |
@@ -122,6 +122,10 void PieChartItem::updateLayout() | |||||
122 |
|
122 | |||
123 | void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) |
|
123 | void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |
124 | { |
|
124 | { | |
|
125 | // delay creating slice items until there is a proper rectangle | |||
|
126 | if (!m_rect.isValid() && m_sliceItems.isEmpty()) | |||
|
127 | return; | |||
|
128 | ||||
125 | presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); |
|
129 | presenter()->chartTheme()->decorate(m_series, presenter()->dataSet()->seriesIndex(m_series)); | |
126 |
|
130 | |||
127 | bool startupAnimation = m_sliceItems.isEmpty(); |
|
131 | bool startupAnimation = m_sliceItems.isEmpty(); |
@@ -49,7 +49,6 public Q_SLOTS: | |||||
49 | virtual void rangeXChanged(qreal min, qreal max, int tickXCount); |
|
49 | virtual void rangeXChanged(qreal min, qreal max, int tickXCount); | |
50 | virtual void rangeYChanged(qreal min, qreal max, int tickYCount); |
|
50 | virtual void rangeYChanged(qreal min, qreal max, int tickYCount); | |
51 |
|
51 | |||
52 | void initialize(); |
|
|||
53 | void updateLayout(); |
|
52 | void updateLayout(); | |
54 | void handleSlicesAdded(QList<QPieSlice*> slices); |
|
53 | void handleSlicesAdded(QList<QPieSlice*> slices); | |
55 | void handleSlicesRemoved(QList<QPieSlice*> slices); |
|
54 | void handleSlicesRemoved(QList<QPieSlice*> slices); |
General Comments 0
You need to be logged in to leave comments.
Login now