##// END OF EJS Templates
Internal review: fixed minor issues in Area and XySeries
Tero Ahola -
r761:e53014bd1799
parent child
Show More
@@ -10,7 +10,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 //TODO: optimize : remove points which are not visible
11 //TODO: optimize : remove points which are not visible
12
12
13 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries,ChartPresenter *presenter) : ChartItem(presenter),
13 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter)
14 : ChartItem(presenter),
14 m_series(areaSeries),
15 m_series(areaSeries),
15 m_upper(0),
16 m_upper(0),
16 m_lower(0),
17 m_lower(0),
@@ -18,9 +19,8 AreaChartItem::AreaChartItem(QAreaSeries *areaSeries,ChartPresenter *presenter)
18 {
19 {
19 setZValue(ChartPresenter::LineChartZValue);
20 setZValue(ChartPresenter::LineChartZValue);
20 m_upper = new AreaBoundItem(this,m_series->upperSeries());
21 m_upper = new AreaBoundItem(this,m_series->upperSeries());
21 if (m_series->lowerSeries()) {
22 if (m_series->lowerSeries())
22 m_lower = new AreaBoundItem(this,m_series->lowerSeries());
23 m_lower = new AreaBoundItem(this,m_series->lowerSeries());
23 }
24
24
25 connect(areaSeries,SIGNAL(updated()),this,SLOT(handleUpdated()));
25 connect(areaSeries,SIGNAL(updated()),this,SLOT(handleUpdated()));
26 connect(this,SIGNAL(clicked(const QPointF&)),areaSeries,SIGNAL(clicked(const QPointF&)));
26 connect(this,SIGNAL(clicked(const QPointF&)),areaSeries,SIGNAL(clicked(const QPointF&)));
@@ -32,7 +32,7 AreaChartItem::~AreaChartItem()
32 {
32 {
33 delete m_upper;
33 delete m_upper;
34 delete m_lower;
34 delete m_lower;
35 };
35 }
36
36
37 QRectF AreaChartItem::boundingRect() const
37 QRectF AreaChartItem::boundingRect() const
38 {
38 {
@@ -60,8 +60,8 void AreaChartItem::updatePath()
60 }
60 }
61 path.closeSubpath();
61 path.closeSubpath();
62 prepareGeometryChange();
62 prepareGeometryChange();
63 m_path=path;
63 m_path = path;
64 m_rect=path.boundingRect();
64 m_rect = path.boundingRect();
65 update();
65 update();
66 }
66 }
67
67
@@ -71,7 +71,7 void AreaChartItem::handleUpdated()
71 m_linePen = m_series->pen();
71 m_linePen = m_series->pen();
72 m_brush = m_series->brush();
72 m_brush = m_series->brush();
73 m_pointPen = m_series->pen();
73 m_pointPen = m_series->pen();
74 m_pointPen.setWidthF(2*m_pointPen.width());
74 m_pointPen.setWidthF(2 * m_pointPen.width());
75
75
76 update();
76 update();
77 }
77 }
@@ -91,7 +91,6 void AreaChartItem::handleGeometryChanged(const QRectF &rect)
91 if (m_lower)
91 if (m_lower)
92 m_lower->handleGeometryChanged(rect);
92 m_lower->handleGeometryChanged(rect);
93 }
93 }
94 //painter
95
94
96 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
95 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
97 {
96 {
@@ -15,7 +15,7 class AreaChartItem : public ChartItem
15 Q_OBJECT
15 Q_OBJECT
16 public:
16 public:
17 AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter);
17 AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter);
18 ~ AreaChartItem();
18 ~AreaChartItem();
19
19
20 //from QGraphicsItem
20 //from QGraphicsItem
21 QRectF boundingRect() const;
21 QRectF boundingRect() const;
@@ -56,7 +56,7 class AreaBoundItem : public LineChartItem
56 {
56 {
57 public:
57 public:
58 AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries) : LineChartItem(lineSeries, 0), m_item(item) {}
58 AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries) : LineChartItem(lineSeries, 0), m_item(item) {}
59 ~AreaBoundItem(){}
59 ~AreaBoundItem() {}
60
60
61 void setLayout(QVector<QPointF> &points) {
61 void setLayout(QVector<QPointF> &points) {
62 LineChartItem::setLayout(points);
62 LineChartItem::setLayout(points);
@@ -65,7 +65,6 public:
65
65
66 private:
66 private:
67 AreaChartItem* m_item;
67 AreaChartItem* m_item;
68
69 };
68 };
70
69
71 QTCOMMERCIALCHART_END_NAMESPACE
70 QTCOMMERCIALCHART_END_NAMESPACE
@@ -78,12 +78,14 QTCOMMERCIALCHART_BEGIN_NAMESPACE
78 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
78 upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
79 When series object is added to QChartView or QChart instance ownerships is transfered.
79 When series object is added to QChartView or QChart instance ownerships is transfered.
80 */
80 */
81 QAreaSeries::QAreaSeries(QLineSeries* upperSeries,QLineSeries* lowerSeries):QSeries(upperSeries),
81 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
82 m_upperSeries(upperSeries),
82 : QSeries(upperSeries),
83 m_lowerSeries(lowerSeries),
83 m_upperSeries(upperSeries),
84 m_pointsVisible(false)
84 m_lowerSeries(lowerSeries),
85 m_pointsVisible(false)
85 {
86 {
86 }
87 }
88
87 /*!
89 /*!
88 Destroys the object. Series added to QChartView or QChart instances are owned by those,
90 Destroys the object. Series added to QChartView or QChart instances are owned by those,
89 and are deleted when mentioned object are destroyed.
91 and are deleted when mentioned object are destroyed.
@@ -95,7 +97,7 QAreaSeries::~QAreaSeries()
95 /*!
97 /*!
96 Sets \a pen used for drawing area outline.
98 Sets \a pen used for drawing area outline.
97 */
99 */
98 void QAreaSeries::setPen(const QPen& pen)
100 void QAreaSeries::setPen(const QPen &pen)
99 {
101 {
100 if (m_pen != pen) {
102 if (m_pen != pen) {
101 m_pen = pen;
103 m_pen = pen;
@@ -12,7 +12,7 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14 protected:
14 protected:
15 QXYSeries(QObject *parent=0);
15 QXYSeries(QObject *parent = 0);
16 virtual ~QXYSeries();
16 virtual ~QXYSeries();
17
17
18 public:
18 public:
@@ -36,21 +36,21 public:
36
36
37 void setPen(const QPen &pen);
37 void setPen(const QPen &pen);
38 QPen pen() const {return m_pen;}
38 QPen pen() const {return m_pen;}
39 void setBrush(const QBrush &pen);
39 void setBrush(const QBrush &brush);
40 QBrush brush() const {return m_brush;}
40 QBrush brush() const {return m_brush;}
41
41
42 bool setModel(QAbstractItemModel *model);
42 bool setModel(QAbstractItemModel *model);
43 QAbstractItemModel* model() {return m_model;}
43 QAbstractItemModel* model() { return m_model; }
44
44
45 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
45 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
46 virtual void setModelMappingShift(int first, int count = 0);
46 virtual void setModelMappingShift(int first, int count = 0);
47
47
48 private slots:
48 private slots:
49 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
49 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
50 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
50 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
51 void modelDataAdded(QModelIndex parent, int start, int end);
51 void modelDataAdded(QModelIndex parent, int start, int end);
52 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
52 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
53 void modelDataRemoved(QModelIndex parent, int start, int end);
53 void modelDataRemoved(QModelIndex parent, int start, int end);
54
54
55 signals:
55 signals:
56 void clicked(const QPointF &point);
56 void clicked(const QPointF &point);
General Comments 0
You need to be logged in to leave comments. Login now