##// 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 121 QObject::connect(lineSeries,SIGNAL(pointReplaced(int)),item,SLOT(handlePointReplaced(int)));
122 122 QObject::connect(lineSeries,SIGNAL(pointAdded(int)),item,SLOT(handlePointAdded(int)));
123 123 QObject::connect(lineSeries,SIGNAL(pointRemoved(int)),item,SLOT(handlePointRemoved(int)));
124 QObject::connect(lineSeries,SIGNAL(updated()),item,SLOT(handleUpdated()));
124 125 m_chartItems.insert(series,item);
125 126 if(m_rect.isValid()) item->handleGeometryChanged(m_rect);
127 item->handleUpdated();
126 128 break;
127 129 }
128 130
@@ -193,10 +193,8 void LineChartItem::handleGeometryChanged(const QRectF& rect)
193 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 198 m_items.setVisible(m_series->pointsVisible());
201 199 setPen(m_series->pen());
202 200 update();
@@ -29,7 +29,7 public slots:
29 29 void handlePointAdded(int index);
30 30 void handlePointRemoved(int index);
31 31 void handlePointReplaced(int index);
32 void handleSeriesUpdated();
32 void handleUpdated();
33 33 void handleDomainChanged(const Domain& domain);
34 34 void handleGeometryChanged(const QRectF& size);
35 35
@@ -45,13 +45,13 public:
45 45 private:
46 46 ChartPresenter* m_presenter;
47 47 QPainterPath m_path;
48 QLineSeries* m_series;
48 49 QSizeF m_size;
49 50 QRectF m_rect;
50 51 QRectF m_clipRect;
51 52 Domain m_domain;
52 53 QGraphicsItemGroup m_items;
53 54 QVector<QPointF> m_points;
54 QLineSeries* m_series;
55 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 66 Constructs empty series object which is a child of \a parent.
62 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 179 void QLineSeries::setPen(const QPen& pen)
175 180 {
181 if(pen!=m_pen){
176 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 190 void QLineSeries::setPointsVisible(bool visible)
183 191 {
192 if(m_pointsVisible!=visible){
184 193 m_pointsVisible=visible;
194 emit updated();
195 }
185 196 }
186 197
187 198 QDebug operator<< (QDebug debug, const QLineSeries series)
@@ -43,6 +43,7 signals:
43 43 void pointReplaced(int index);
44 44 void pointRemoved(int index);
45 45 void pointAdded(int index);
46 void updated();
46 47
47 48 private:
48 49 QVector<qreal> m_x;
General Comments 0
You need to be logged in to leave comments. Login now