From 938f3d3eaf7c0ceb39a73e15a083f19e96637a9a 2012-02-29 08:59:41 From: Michal Klocek Date: 2012-02-29 08:59:41 Subject: [PATCH] Adds updated handling for line series --- diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index c1b6923..c97c9ab 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -121,8 +121,10 @@ void ChartPresenter::handleSeriesAdded(QSeries* series) QObject::connect(lineSeries,SIGNAL(pointReplaced(int)),item,SLOT(handlePointReplaced(int))); QObject::connect(lineSeries,SIGNAL(pointAdded(int)),item,SLOT(handlePointAdded(int))); QObject::connect(lineSeries,SIGNAL(pointRemoved(int)),item,SLOT(handlePointRemoved(int))); + QObject::connect(lineSeries,SIGNAL(updated()),item,SLOT(handleUpdated())); m_chartItems.insert(series,item); if(m_rect.isValid()) item->handleGeometryChanged(m_rect); + item->handleUpdated(); break; } diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index 8abbf00..484fb20 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -193,10 +193,8 @@ void LineChartItem::handleGeometryChanged(const QRectF& rect) update(); } -void LineChartItem::handleSeriesUpdated() +void LineChartItem::handleUpdated() { - if(m_points.count()==0) return; - m_items.setVisible(m_series->pointsVisible()); setPen(m_series->pen()); update(); diff --git a/src/linechart/linechartitem_p.h b/src/linechart/linechartitem_p.h index affb6a0..21d23ff 100644 --- a/src/linechart/linechartitem_p.h +++ b/src/linechart/linechartitem_p.h @@ -29,7 +29,7 @@ public slots: void handlePointAdded(int index); void handlePointRemoved(int index); void handlePointReplaced(int index); - void handleSeriesUpdated(); + void handleUpdated(); void handleDomainChanged(const Domain& domain); void handleGeometryChanged(const QRectF& size); @@ -45,13 +45,13 @@ public: private: ChartPresenter* m_presenter; QPainterPath m_path; + QLineSeries* m_series; QSizeF m_size; QRectF m_rect; QRectF m_clipRect; Domain m_domain; QGraphicsItemGroup m_items; QVector m_points; - QLineSeries* m_series; QPen m_pen; }; diff --git a/src/linechart/qlineseries.cpp b/src/linechart/qlineseries.cpp index eba6f0f..e38d046 100644 --- a/src/linechart/qlineseries.cpp +++ b/src/linechart/qlineseries.cpp @@ -58,6 +58,11 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE */ /*! + \fn void QLineSeries::updated(int index) + \brief \internal +*/ + +/*! Constructs empty series object which is a child of \a parent. When series object is added to QChartView or QChart instance ownerships is transfered. */ @@ -173,7 +178,10 @@ int QLineSeries::count() const */ void QLineSeries::setPen(const QPen& pen) { + if(pen!=m_pen){ m_pen=pen; + emit updated(); + } } /*! @@ -181,7 +189,10 @@ void QLineSeries::setPen(const QPen& pen) */ void QLineSeries::setPointsVisible(bool visible) { + if(m_pointsVisible!=visible){ m_pointsVisible=visible; + emit updated(); + } } QDebug operator<< (QDebug debug, const QLineSeries series) diff --git a/src/linechart/qlineseries.h b/src/linechart/qlineseries.h index 2c9601d..2018bc6 100644 --- a/src/linechart/qlineseries.h +++ b/src/linechart/qlineseries.h @@ -43,6 +43,7 @@ signals: void pointReplaced(int index); void pointRemoved(int index); void pointAdded(int index); + void updated(); private: QVector m_x;