##// END OF EJS Templates
Internal review: fixed minor issues in Area and XySeries
Tero Ahola -
r761:e53014bd1799
parent child
Show More
@@ -1,122 +1,121
1 #include "areachartitem_p.h"
1 #include "areachartitem_p.h"
2 #include "qareaseries.h"
2 #include "qareaseries.h"
3 #include "qlineseries.h"
3 #include "qlineseries.h"
4 #include "chartpresenter_p.h"
4 #include "chartpresenter_p.h"
5 #include <QPainter>
5 #include <QPainter>
6 #include <QGraphicsSceneMouseEvent>
6 #include <QGraphicsSceneMouseEvent>
7
7
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 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),
17 m_pointsVisible(false)
18 m_pointsVisible(false)
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&)));
27
27
28 handleUpdated();
28 handleUpdated();
29 }
29 }
30
30
31 AreaChartItem::~AreaChartItem()
31 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 {
39 return m_rect;
39 return m_rect;
40 }
40 }
41
41
42 QPainterPath AreaChartItem::shape() const
42 QPainterPath AreaChartItem::shape() const
43 {
43 {
44 return m_path;
44 return m_path;
45 }
45 }
46
46
47 void AreaChartItem::updatePath()
47 void AreaChartItem::updatePath()
48 {
48 {
49 QPainterPath path;
49 QPainterPath path;
50
50
51 path = m_upper->shape();
51 path = m_upper->shape();
52
52
53 if (m_lower) {
53 if (m_lower) {
54 path.connectPath(m_lower->shape().toReversed());
54 path.connectPath(m_lower->shape().toReversed());
55 } else {
55 } else {
56 QPointF first = path.pointAtPercent(0);
56 QPointF first = path.pointAtPercent(0);
57 QPointF last = path.pointAtPercent(1);
57 QPointF last = path.pointAtPercent(1);
58 path.lineTo(last.x(),m_clipRect.bottom());
58 path.lineTo(last.x(),m_clipRect.bottom());
59 path.lineTo(first.x(),m_clipRect.bottom());
59 path.lineTo(first.x(),m_clipRect.bottom());
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
68 void AreaChartItem::handleUpdated()
68 void AreaChartItem::handleUpdated()
69 {
69 {
70 m_pointsVisible = m_series->pointsVisible();
70 m_pointsVisible = m_series->pointsVisible();
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 }
78
78
79 void AreaChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
79 void AreaChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
80 {
80 {
81 m_upper->handleDomainChanged(minX,maxX,minY,maxY);
81 m_upper->handleDomainChanged(minX,maxX,minY,maxY);
82 if (m_lower)
82 if (m_lower)
83 m_lower->handleDomainChanged(minX,maxX,minY,maxY);
83 m_lower->handleDomainChanged(minX,maxX,minY,maxY);
84 }
84 }
85
85
86 void AreaChartItem::handleGeometryChanged(const QRectF &rect)
86 void AreaChartItem::handleGeometryChanged(const QRectF &rect)
87 {
87 {
88 m_clipRect=rect.translated(-rect.topLeft());
88 m_clipRect=rect.translated(-rect.topLeft());
89 setPos(rect.topLeft());
89 setPos(rect.topLeft());
90 m_upper->handleGeometryChanged(rect);
90 m_upper->handleGeometryChanged(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 {
98 Q_UNUSED(widget)
97 Q_UNUSED(widget)
99 Q_UNUSED(option)
98 Q_UNUSED(option)
100
99
101 painter->save();
100 painter->save();
102 painter->setPen(m_linePen);
101 painter->setPen(m_linePen);
103 painter->setBrush(m_brush);
102 painter->setBrush(m_brush);
104 painter->setClipRect(m_clipRect);
103 painter->setClipRect(m_clipRect);
105 painter->drawPath(m_path);
104 painter->drawPath(m_path);
106 if (m_pointsVisible) {
105 if (m_pointsVisible) {
107 painter->setPen(m_pointPen);
106 painter->setPen(m_pointPen);
108 painter->drawPoints(m_upper->points());
107 painter->drawPoints(m_upper->points());
109 if (m_lower)
108 if (m_lower)
110 painter->drawPoints(m_lower->points());
109 painter->drawPoints(m_lower->points());
111 }
110 }
112 painter->restore();
111 painter->restore();
113 }
112 }
114
113
115 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
114 void AreaChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
116 {
115 {
117 emit clicked(m_upper->calculateDomainPoint(event->pos()));
116 emit clicked(m_upper->calculateDomainPoint(event->pos()));
118 }
117 }
119
118
120 #include "moc_areachartitem_p.cpp"
119 #include "moc_areachartitem_p.cpp"
121
120
122 QTCOMMERCIALCHART_END_NAMESPACE
121 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,73 +1,72
1 #ifndef AREACHARTITEM_H
1 #ifndef AREACHARTITEM_H
2 #define AREACHARTITEM_H
2 #define AREACHARTITEM_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "linechartitem_p.h"
5 #include "linechartitem_p.h"
6 #include <QPen>
6 #include <QPen>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QAreaSeries;
10 class QAreaSeries;
11 class AreaChartItem;
11 class AreaChartItem;
12
12
13 class AreaChartItem : public ChartItem
13 class AreaChartItem : public ChartItem
14 {
14 {
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;
22 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
22 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
23 QPainterPath shape() const;
23 QPainterPath shape() const;
24
24
25 LineChartItem* upperLineItem() const { return m_upper; }
25 LineChartItem* upperLineItem() const { return m_upper; }
26 LineChartItem* lowerLineItem() const { return m_lower; }
26 LineChartItem* lowerLineItem() const { return m_lower; }
27
27
28 void updatePath();
28 void updatePath();
29
29
30 protected:
30 protected:
31 void mousePressEvent(QGraphicsSceneMouseEvent *event);
31 void mousePressEvent(QGraphicsSceneMouseEvent *event);
32
32
33 signals:
33 signals:
34 void clicked(const QPointF &point);
34 void clicked(const QPointF &point);
35
35
36 public slots:
36 public slots:
37 void handleUpdated();
37 void handleUpdated();
38 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
38 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
39 void handleGeometryChanged(const QRectF &size);
39 void handleGeometryChanged(const QRectF &size);
40
40
41 private:
41 private:
42 QAreaSeries* m_series;
42 QAreaSeries* m_series;
43 LineChartItem* m_upper;
43 LineChartItem* m_upper;
44 LineChartItem* m_lower;
44 LineChartItem* m_lower;
45 QPainterPath m_path;
45 QPainterPath m_path;
46 QRectF m_rect;
46 QRectF m_rect;
47 QRectF m_clipRect;
47 QRectF m_clipRect;
48 QPen m_linePen;
48 QPen m_linePen;
49 QPen m_pointPen;
49 QPen m_pointPen;
50 QBrush m_brush;
50 QBrush m_brush;
51 bool m_pointsVisible;
51 bool m_pointsVisible;
52
52
53 };
53 };
54
54
55 class AreaBoundItem : public LineChartItem
55 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);
63 m_item->updatePath();
63 m_item->updatePath();
64 }
64 }
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
72
71
73 #endif
72 #endif
@@ -1,148 +1,150
1 #include "qareaseries.h"
1 #include "qareaseries.h"
2 #include "qlineseries.h"
2 #include "qlineseries.h"
3
3
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5
5
6 /*!
6 /*!
7 \class QAreaSeries
7 \class QAreaSeries
8 \brief The QAreaSeries class is used for making area charts.
8 \brief The QAreaSeries class is used for making area charts.
9
9
10 \mainclass
10 \mainclass
11
11
12 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
12 An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
13 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
13 is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
14 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
14 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
15 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
15 In that case QAreaSeries should be initiated with two QLineSerie instances. Please note terms "upper" and "lower" boundary can be misleading in cases
16 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
16 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
17
17
18 \image areachart.png
18 \image areachart.png
19
19
20 Creating basic area chart is simple:
20 Creating basic area chart is simple:
21 \code
21 \code
22 QLineSeries* lineSeries = new QLineSeries();
22 QLineSeries* lineSeries = new QLineSeries();
23 series->add(0, 6);
23 series->add(0, 6);
24 series->add(2, 4);
24 series->add(2, 4);
25 QAreaSeries* areaSeries = new QAreaSeries(lineSeries);
25 QAreaSeries* areaSeries = new QAreaSeries(lineSeries);
26 ...
26 ...
27 chartView->addSeries(areaSeries);
27 chartView->addSeries(areaSeries);
28 \endcode
28 \endcode
29 */
29 */
30
30
31 /*!
31 /*!
32 \fn virtual QSeriesType QAreaSeries::type() const
32 \fn virtual QSeriesType QAreaSeries::type() const
33 \brief Returns type of series.
33 \brief Returns type of series.
34 \sa QSeries, QSeriesType
34 \sa QSeries, QSeriesType
35 */
35 */
36
36
37 /*!
37 /*!
38 \fn QLineSeries* QAreaSeries::upperSeries() const
38 \fn QLineSeries* QAreaSeries::upperSeries() const
39 \brief Returns upperSeries used to define one of area boundaries.
39 \brief Returns upperSeries used to define one of area boundaries.
40 */
40 */
41
41
42 /*!
42 /*!
43 \fn QLineSeries* QAreaSeries::lowerSeries() const
43 \fn QLineSeries* QAreaSeries::lowerSeries() const
44 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
44 \brief Returns lowerSeries used to define one of area boundaries. Note if QAreaSeries where counstucted wihtout a\ lowerSeries
45 this function return Null pointer.
45 this function return Null pointer.
46 */
46 */
47
47
48 /*!
48 /*!
49 \fn QPen QAreaSeries::pen() const
49 \fn QPen QAreaSeries::pen() const
50 \brief Returns the pen used to draw line for this series.
50 \brief Returns the pen used to draw line for this series.
51 \sa setPen()
51 \sa setPen()
52 */
52 */
53
53
54 /*!
54 /*!
55 \fn QPen QAreaSeries::brush() const
55 \fn QPen QAreaSeries::brush() const
56 \brief Returns the brush used to draw line for this series.
56 \brief Returns the brush used to draw line for this series.
57 \sa setBrush()
57 \sa setBrush()
58 */
58 */
59
59
60 /*!
60 /*!
61 \fn bool QAreaSeries::pointsVisible() const
61 \fn bool QAreaSeries::pointsVisible() const
62 \brief Returns if the points are drawn for this series.
62 \brief Returns if the points are drawn for this series.
63 \sa setPointsVisible()
63 \sa setPointsVisible()
64 */
64 */
65
65
66 /*!
66 /*!
67 \fn void QAreaSeries::clicked(const QPointF& point)
67 \fn void QAreaSeries::clicked(const QPointF& point)
68 \brief Signal is emitted when user clicks the \a point on area chart.
68 \brief Signal is emitted when user clicks the \a point on area chart.
69 */
69 */
70
70
71 /*!
71 /*!
72 \fn void QAreaSeries::updated()
72 \fn void QAreaSeries::updated()
73 \brief \internal
73 \brief \internal
74 */
74 */
75
75
76 /*!
76 /*!
77 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
77 Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
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.
90 */
92 */
91 QAreaSeries::~QAreaSeries()
93 QAreaSeries::~QAreaSeries()
92 {
94 {
93 }
95 }
94
96
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;
102 emit updated();
104 emit updated();
103 }
105 }
104 }
106 }
105
107
106 /*!
108 /*!
107 Sets \a brush used for filling the area.
109 Sets \a brush used for filling the area.
108 */
110 */
109 void QAreaSeries::setBrush(const QBrush &brush)
111 void QAreaSeries::setBrush(const QBrush &brush)
110 {
112 {
111 if (m_brush != brush) {
113 if (m_brush != brush) {
112 m_brush = brush;
114 m_brush = brush;
113 emit updated();
115 emit updated();
114 }
116 }
115 }
117 }
116 /*!
118 /*!
117 Sets if data points are \a visible and should be drawn on line.
119 Sets if data points are \a visible and should be drawn on line.
118 */
120 */
119 void QAreaSeries::setPointsVisible(bool visible)
121 void QAreaSeries::setPointsVisible(bool visible)
120 {
122 {
121 if (m_pointsVisible != visible) {
123 if (m_pointsVisible != visible) {
122 m_pointsVisible = visible;
124 m_pointsVisible = visible;
123 emit updated();
125 emit updated();
124 }
126 }
125 }
127 }
126
128
127 //bool QAreaSeries::setModel(QAbstractItemModel* model)
129 //bool QAreaSeries::setModel(QAbstractItemModel* model)
128 //{
130 //{
129 // m_upperSeries->setModel(model);
131 // m_upperSeries->setModel(model);
130 // if (m_lowerSeries)
132 // if (m_lowerSeries)
131 // m_lowerSeries->setModel(model);
133 // m_lowerSeries->setModel(model);
132 // return true;
134 // return true;
133 //}
135 //}
134
136
135 //void QAreaSeries::setModelMappingUpper(int modelX, int modelY, Qt::Orientation orientation)
137 //void QAreaSeries::setModelMappingUpper(int modelX, int modelY, Qt::Orientation orientation)
136 //{
138 //{
137 // m_upperSeries->setModelMapping(modelX, modelY, orientation);
139 // m_upperSeries->setModelMapping(modelX, modelY, orientation);
138 //}
140 //}
139
141
140 //void QAreaSeries::setModelMappingLower(int modelX, int modelY, Qt::Orientation orientation)
142 //void QAreaSeries::setModelMappingLower(int modelX, int modelY, Qt::Orientation orientation)
141 //{
143 //{
142 // if (m_lowerSeries)
144 // if (m_lowerSeries)
143 // m_lowerSeries->setModelMapping(modelX, modelY, orientation);
145 // m_lowerSeries->setModelMapping(modelX, modelY, orientation);
144 //}
146 //}
145
147
146 #include "moc_qareaseries.cpp"
148 #include "moc_qareaseries.cpp"
147
149
148 QTCOMMERCIALCHART_END_NAMESPACE
150 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,80 +1,80
1 #ifndef QXYSERIES_H_
1 #ifndef QXYSERIES_H_
2 #define QXYSERIES_H_
2 #define QXYSERIES_H_
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <qseries.h>
5 #include <qseries.h>
6 #include <QPen>
6 #include <QPen>
7 #include <QBrush>
7 #include <QBrush>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
11 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:
19 void add(qreal x, qreal y);
19 void add(qreal x, qreal y);
20 void add(const QPointF &point);
20 void add(const QPointF &point);
21 void add(const QList<QPointF> points);
21 void add(const QList<QPointF> points);
22 void replace(qreal x,qreal y);
22 void replace(qreal x,qreal y);
23 void replace(const QPointF &point);
23 void replace(const QPointF &point);
24 void remove(qreal x);
24 void remove(qreal x);
25 void remove(qreal x, qreal y);
25 void remove(qreal x, qreal y);
26 void remove(const QPointF &point);
26 void remove(const QPointF &point);
27 void removeAll();
27 void removeAll();
28
28
29 int count() const;
29 int count() const;
30 qreal x(int pos) const;
30 qreal x(int pos) const;
31 qreal y(int pos) const;
31 qreal y(int pos) const;
32 QList<QPointF> data();
32 QList<QPointF> data();
33
33
34 QXYSeries& operator << (const QPointF &point);
34 QXYSeries& operator << (const QPointF &point);
35 QXYSeries& operator << (const QList<QPointF> points);
35 QXYSeries& operator << (const QList<QPointF> points);
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);
57 void updated();
57 void updated();
58 void pointReplaced(int index);
58 void pointReplaced(int index);
59 void pointRemoved(int index);
59 void pointRemoved(int index);
60 void pointAdded(int index);
60 void pointAdded(int index);
61
61
62 protected:
62 protected:
63 QVector<qreal> m_x;
63 QVector<qreal> m_x;
64 QVector<qreal> m_y;
64 QVector<qreal> m_y;
65
65
66 QPen m_pen;
66 QPen m_pen;
67 QBrush m_brush;
67 QBrush m_brush;
68
68
69 int m_mapX;
69 int m_mapX;
70 int m_mapY;
70 int m_mapY;
71 int m_mapFirst;
71 int m_mapFirst;
72 int m_mapCount;
72 int m_mapCount;
73 bool m_mapLimited;
73 bool m_mapLimited;
74 Qt::Orientation m_mapOrientation;
74 Qt::Orientation m_mapOrientation;
75 int tempItemsRemoved;
75 int tempItemsRemoved;
76 };
76 };
77
77
78 QTCOMMERCIALCHART_END_NAMESPACE
78 QTCOMMERCIALCHART_END_NAMESPACE
79
79
80 #endif
80 #endif
General Comments 0
You need to be logged in to leave comments. Login now