From d27e6a35ae043796b546deb321499280cf345229 2015-09-23 11:56:35 From: Titta Heikkala Date: 2015-09-23 11:56:35 Subject: [PATCH] Revert previous change to LineChartItem The m_points private member in LineChartItem is needed after all. If the points from XYChart are used, the old line is not properly cleared with animations. The variable is now renamed to reduce confusion. Change-Id: I35fcb708017d1a423a6e42eb1721c0b332a3a995 Task-number: QTRD-3489 Reviewed-by: Miikka Heikkinen --- diff --git a/src/charts/linechart/linechartitem.cpp b/src/charts/linechart/linechartitem.cpp index 2117da0..84d9e1e 100644 --- a/src/charts/linechart/linechartitem.cpp +++ b/src/charts/linechart/linechartitem.cpp @@ -70,7 +70,10 @@ QPainterPath LineChartItem::shape() const void LineChartItem::updateGeometry() { - const QVector &points = geometryPoints(); + // Store the points to a local variable so that the old line gets properly cleared + // when animation starts. + m_linePoints = geometryPoints(); + const QVector &points = m_linePoints; if (points.size() == 0) { prepareGeometryChange(); @@ -377,8 +380,8 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt // to ensure proper continuity of the pattern painter->drawPath(m_linePath); } else { - for (int i(1); i < m_points.size(); i++) - painter->drawLine(m_points.at(i - 1), m_points.at(i)); + for (int i(1); i < m_linePoints.size(); i++) + painter->drawLine(m_linePoints.at(i - 1), m_linePoints.at(i)); } } @@ -389,7 +392,7 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->setClipping(true); else painter->setClipping(false); - m_series->d_func()->drawSeriesPointLabels(painter, m_points, m_linePen.width() / 2); + m_series->d_func()->drawSeriesPointLabels(painter, m_linePoints, m_linePen.width() / 2); } painter->restore(); diff --git a/src/charts/linechart/linechartitem_p.h b/src/charts/linechart/linechartitem_p.h index 321a8f6..ebf8a1b 100644 --- a/src/charts/linechart/linechartitem_p.h +++ b/src/charts/linechart/linechartitem_p.h @@ -74,6 +74,7 @@ private: QPainterPath m_fullPath; QPainterPath m_shapePath; + QVector m_linePoints; QRectF m_rect; QPen m_linePen; bool m_pointsVisible;