##// END OF EJS Templates
Adds updated handling for line series
Michal Klocek -
r392:938f3d3eaf7c
parent child
Show More
@@ -121,8 +121,10 void ChartPresenter::handleSeriesAdded(QSeries* series)
121 QObject::connect(lineSeries,SIGNAL(pointReplaced(int)),item,SLOT(handlePointReplaced(int)));
121 QObject::connect(lineSeries,SIGNAL(pointReplaced(int)),item,SLOT(handlePointReplaced(int)));
122 QObject::connect(lineSeries,SIGNAL(pointAdded(int)),item,SLOT(handlePointAdded(int)));
122 QObject::connect(lineSeries,SIGNAL(pointAdded(int)),item,SLOT(handlePointAdded(int)));
123 QObject::connect(lineSeries,SIGNAL(pointRemoved(int)),item,SLOT(handlePointRemoved(int)));
123 QObject::connect(lineSeries,SIGNAL(pointRemoved(int)),item,SLOT(handlePointRemoved(int)));
124 QObject::connect(lineSeries,SIGNAL(updated()),item,SLOT(handleUpdated()));
124 m_chartItems.insert(series,item);
125 m_chartItems.insert(series,item);
125 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
126 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
127 item->handleUpdated();
126 break;
128 break;
127 }
129 }
128
130
@@ -193,10 +193,8 void LineChartItem::handleGeometryChanged(const QRectF& rect)
193 update();
193 update();
194 }
194 }
195
195
196 void LineChartItem::handleSeriesUpdated()
196 void LineChartItem::handleUpdated()
197 {
197 {
198 if(m_points.count()==0) return;
199
200 m_items.setVisible(m_series->pointsVisible());
198 m_items.setVisible(m_series->pointsVisible());
201 setPen(m_series->pen());
199 setPen(m_series->pen());
202 update();
200 update();
@@ -29,7 +29,7 public slots:
29 void handlePointAdded(int index);
29 void handlePointAdded(int index);
30 void handlePointRemoved(int index);
30 void handlePointRemoved(int index);
31 void handlePointReplaced(int index);
31 void handlePointReplaced(int index);
32 void handleSeriesUpdated();
32 void handleUpdated();
33 void handleDomainChanged(const Domain& domain);
33 void handleDomainChanged(const Domain& domain);
34 void handleGeometryChanged(const QRectF& size);
34 void handleGeometryChanged(const QRectF& size);
35
35
@@ -45,13 +45,13 public:
45 private:
45 private:
46 ChartPresenter* m_presenter;
46 ChartPresenter* m_presenter;
47 QPainterPath m_path;
47 QPainterPath m_path;
48 QLineSeries* m_series;
48 QSizeF m_size;
49 QSizeF m_size;
49 QRectF m_rect;
50 QRectF m_rect;
50 QRectF m_clipRect;
51 QRectF m_clipRect;
51 Domain m_domain;
52 Domain m_domain;
52 QGraphicsItemGroup m_items;
53 QGraphicsItemGroup m_items;
53 QVector<QPointF> m_points;
54 QVector<QPointF> m_points;
54 QLineSeries* m_series;
55 QPen m_pen;
55 QPen m_pen;
56
56
57 };
57 };
@@ -58,6 +58,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
58 */
58 */
59
59
60 /*!
60 /*!
61 \fn void QLineSeries::updated(int index)
62 \brief \internal
63 */
64
65 /*!
61 Constructs empty series object which is a child of \a parent.
66 Constructs empty series object which is a child of \a parent.
62 When series object is added to QChartView or QChart instance ownerships is transfered.
67 When series object is added to QChartView or QChart instance ownerships is transfered.
63 */
68 */
@@ -173,7 +178,10 int QLineSeries::count() const
173 */
178 */
174 void QLineSeries::setPen(const QPen& pen)
179 void QLineSeries::setPen(const QPen& pen)
175 {
180 {
181 if(pen!=m_pen){
176 m_pen=pen;
182 m_pen=pen;
183 emit updated();
184 }
177 }
185 }
178
186
179 /*!
187 /*!
@@ -181,7 +189,10 void QLineSeries::setPen(const QPen& pen)
181 */
189 */
182 void QLineSeries::setPointsVisible(bool visible)
190 void QLineSeries::setPointsVisible(bool visible)
183 {
191 {
192 if(m_pointsVisible!=visible){
184 m_pointsVisible=visible;
193 m_pointsVisible=visible;
194 emit updated();
195 }
185 }
196 }
186
197
187 QDebug operator<< (QDebug debug, const QLineSeries series)
198 QDebug operator<< (QDebug debug, const QLineSeries series)
@@ -43,6 +43,7 signals:
43 void pointReplaced(int index);
43 void pointReplaced(int index);
44 void pointRemoved(int index);
44 void pointRemoved(int index);
45 void pointAdded(int index);
45 void pointAdded(int index);
46 void updated();
46
47
47 private:
48 private:
48 QVector<qreal> m_x;
49 QVector<qreal> m_x;
General Comments 0
You need to be logged in to leave comments. Login now