From d86f47a4910b19350ceb2021bed5d551606dc177 2013-04-25 07:18:55 From: Miikka Heikkinen Date: 2013-04-25 07:18:55 Subject: [PATCH] Refactor the new QXYSeries::pointAt() -> QXYSeries::at() QML API already had XYSeries::at() for the same functionality. Also, at() is a common method for returning an item at index in Qt containers, so use that instead of pointAt(). This function was introduced in polar chart refactoring and has not yet been released, so no problem changing the name at this point. Change-Id: I4286178cd971a4f3e6fbff9290ae0bbb5c9097cd Reviewed-by: Tomi Korpipää --- diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index ef2a350..6bc20a1 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -88,7 +88,7 @@ void LineChartItem::updateGeometry() qreal minX = domain()->minX(); qreal maxX = domain()->maxX(); qreal minY = domain()->minY(); - QPointF currentSeriesPoint = m_series->pointAt(0); + QPointF currentSeriesPoint = m_series->at(0); QPointF currentGeometryPoint = points.at(0); QPointF previousGeometryPoint = points.at(0); int size = m_linePen.width(); @@ -129,7 +129,7 @@ void LineChartItem::updateGeometry() // degrees and both of the points are within the margin, one in the top half and one in the // bottom half of the chart, the bottom one gets clipped incorrectly. // However, this should be rare occurrence in any sensible chart. - currentSeriesPoint = m_series->pointAt(qMin(seriesLastIndex, i)); + currentSeriesPoint = m_series->at(qMin(seriesLastIndex, i)); currentGeometryPoint = points.at(i); pointOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); @@ -149,7 +149,7 @@ void LineChartItem::updateGeometry() bool dummyOk; // We know points are ok, but this is needed qreal currentAngle = static_cast(domain())->toAngularCoordinate(currentSeriesPoint.x(), dummyOk); - qreal previousAngle = static_cast(domain())->toAngularCoordinate(m_series->pointAt(i - 1).x(), dummyOk); + qreal previousAngle = static_cast(domain())->toAngularCoordinate(m_series->at(i - 1).x(), dummyOk); if ((qAbs(currentAngle - previousAngle) > 180.0)) { // If the angle between two points is over 180 degrees (half X range), diff --git a/src/scatterchart/scatterchartitem.cpp b/src/scatterchart/scatterchartitem.cpp index 6889fdc..fe6c9de 100644 --- a/src/scatterchart/scatterchartitem.cpp +++ b/src/scatterchart/scatterchartitem.cpp @@ -140,7 +140,7 @@ void ScatterChartItem::updateGeometry() // Note that marker map values can be technically incorrect during the animation, // if it was caused by an insert, but this shouldn't be a problem as the points are // fake anyway. - m_markerMap[item] = m_series->pointAt(qMin(seriesLastIndex, i)); + m_markerMap[item] = m_series->at(qMin(seriesLastIndex, i)); item->setPos(point.x() - rect.width() / 2, point.y() - rect.height() / 2); if (!m_visible || offGridStatus.at(i)) diff --git a/src/splinechart/splinechartitem.cpp b/src/splinechart/splinechartitem.cpp index 4f1162c..ebac68d 100644 --- a/src/splinechart/splinechartitem.cpp +++ b/src/splinechart/splinechartitem.cpp @@ -119,7 +119,7 @@ void SplineChartItem::updateGeometry() qreal minX = domain()->minX(); qreal maxX = domain()->maxX(); qreal minY = domain()->minY(); - QPointF currentSeriesPoint = m_series->pointAt(0); + QPointF currentSeriesPoint = m_series->at(0); QPointF currentGeometryPoint = points.at(0); QPointF previousGeometryPoint = points.at(0); bool pointOffGrid = false; @@ -157,7 +157,7 @@ void SplineChartItem::updateGeometry() // degrees and both of the points are within the margin, one in the top half and one in the // bottom half of the chart, the bottom one gets clipped incorrectly. // However, this should be rare occurrence in any sensible chart. - currentSeriesPoint = m_series->pointAt(qMin(seriesLastIndex, i)); + currentSeriesPoint = m_series->at(qMin(seriesLastIndex, i)); currentGeometryPoint = points.at(i); pointOffGrid = (currentSeriesPoint.x() < minX || currentSeriesPoint.x() > maxX); @@ -165,7 +165,7 @@ void SplineChartItem::updateGeometry() if (!pointOffGrid || !previousPointWasOffGrid) { bool dummyOk; // We know points are ok, but this is needed qreal currentAngle = static_cast(domain())->toAngularCoordinate(currentSeriesPoint.x(), dummyOk); - qreal previousAngle = static_cast(domain())->toAngularCoordinate(m_series->pointAt(i - 1).x(), dummyOk); + qreal previousAngle = static_cast(domain())->toAngularCoordinate(m_series->at(i - 1).x(), dummyOk); if ((qAbs(currentAngle - previousAngle) > 180.0)) { // If the angle between two points is over 180 degrees (half X range), diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index 285c078..37c7355 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -368,7 +368,7 @@ QList QXYSeries::points() const /*! Returns point at \a index in internal points vector. */ -const QPointF &QXYSeries::pointAt(int index) const +const QPointF &QXYSeries::at(int index) const { Q_D(const QXYSeries); return d->m_points.at(index); diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h index 8eff380..65ab002 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -56,7 +56,7 @@ public: int count() const; QList points() const; - const QPointF &pointAt(int index) const; + const QPointF &at(int index) const; QXYSeries &operator << (const QPointF &point); QXYSeries &operator << (const QList &points); diff --git a/src/xychart/xychart.cpp b/src/xychart/xychart.cpp index a018119..5f57cc5 100644 --- a/src/xychart/xychart.cpp +++ b/src/xychart/xychart.cpp @@ -79,7 +79,7 @@ QVector XYChart::offGridStatusVector() const int seriesLastIndex = m_series->count() - 1; for (int i = 0; i < m_points.size(); i++) { - const QPointF &seriesPoint = m_series->pointAt(qMin(seriesLastIndex, i)); + const QPointF &seriesPoint = m_series->at(qMin(seriesLastIndex, i)); if (seriesPoint.x() < minX || seriesPoint.x() > maxX || seriesPoint.y() < minY