##// END OF EJS Templates
Refactor line spline to common xyline...
Michal Klocek -
r465:7f683774d508
parent child
Show More
@@ -1,21 +1,21
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += linechart \
2 SUBDIRS += linechart \
3 zoomlinechart \
3 zoomlinechart \
4 colorlinechart \
4 colorlinechart \
5 barchart \
5 barchart \
6 stackedbarchart \
6 stackedbarchart \
7 percentbarchart \
7 percentbarchart \
8 scatter \
8 scatter \
9 piechart \
9 piechart \
10 piechartcustomization \
10 piechartcustomization \
11 piechartdrilldown \
11 piechartdrilldown \
12 dynamiclinechart \
12 dynamiclinechart \
13 axischart \
13 axischart \
14 multichart \
14 multichart \
15 gdpbarchart \
15 gdpbarchart \
16 presenterchart \
16 presenterchart \
17 chartview \
17 chartview \
18 scatterinteractions \
18 scatterinteractions \
19 #splinechart \
19 splinechart \
20 areachart \
20 areachart \
21 stackedbarchartdrilldown
21 stackedbarchartdrilldown
@@ -1,113 +1,112
1 #include "linechartanimationitem_p.h"
1 #include "linechartanimationitem_p.h"
2 #include "linechartitem_p.h"
2 #include "linechartitem_p.h"
3 #include <QPropertyAnimation>
3 #include <QPropertyAnimation>
4 #include <QTimer>
4 #include <QTimer>
5
5
6 Q_DECLARE_METATYPE(QVector<QPointF>)
6 Q_DECLARE_METATYPE(QVector<QPointF>)
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 const static int duration = 500;
10 const static int duration = 500;
11
11
12 LineChartAnimationItem::LineChartAnimationItem(QLineSeries* series,QGraphicsItem *parent):
12 LineChartAnimationItem::LineChartAnimationItem(QLineSeries* series,QGraphicsItem *parent):
13 LineChartItem(series,parent),
13 LineChartItem(series,parent),
14 m_animation(new LineChartAnimatator(this,this)),
14 m_animation(new LineChartAnimatator(this,this)),
15 m_dirty(false)
15 m_dirty(false)
16 {
16 {
17 }
17 }
18
18
19 LineChartAnimationItem::~LineChartAnimationItem()
19 LineChartAnimationItem::~LineChartAnimationItem()
20 {
20 {
21 }
21 }
22
22
23 void LineChartAnimationItem::updateAllPoints()
23 void LineChartAnimationItem::updatePoints(QVector<QPointF>& newPoints)
24 {
24 {
25 QVector<QPointF> oldPoints = points();
25 QVector<QPointF> oldPoints = points();
26 LineChartItem::updateAllPoints();
26 LineChartItem::updatePoints(newPoints);
27 QVector<QPointF> newPoints = points();
28
27
29 if(newPoints.count()==0) return;
28 if(newPoints.count()==0) return;
30 oldPoints.resize(newPoints.size());
29 oldPoints.resize(newPoints.size());
31
30
32 if(m_animation->state()!=QAbstractAnimation::Stopped){
31 if(m_animation->state()!=QAbstractAnimation::Stopped){
33 m_animation->stop();
32 m_animation->stop();
34 }
33 }
35
34
36 m_animation->setDuration(duration);
35 m_animation->setDuration(duration);
37 m_animation->setEasingCurve(QEasingCurve::InOutBack);
36 m_animation->setEasingCurve(QEasingCurve::InOutBack);
38 m_animation->setKeyValueAt(0.0, qVariantFromValue(oldPoints));
37 m_animation->setKeyValueAt(0.0, qVariantFromValue(oldPoints));
39 m_animation->setKeyValueAt(1.0, qVariantFromValue(newPoints));
38 m_animation->setKeyValueAt(1.0, qVariantFromValue(newPoints));
40 QTimer::singleShot(0,m_animation,SLOT(start()));
39 QTimer::singleShot(0,m_animation,SLOT(start()));
41
40
42
41
43 m_points = newPoints;
42 m_points = newPoints;
44 m_dirty=false;
43 m_dirty=false;
45
44
46 }
45 }
47
46
48 void LineChartAnimationItem::updatePoint(int index,QPointF& newPoint)
47 void LineChartAnimationItem::updatePoint(int index,QPointF& newPoint)
49 {
48 {
50
49
51 if(m_animation->state()!=QAbstractAnimation::Stopped){
50 if(m_animation->state()!=QAbstractAnimation::Stopped){
52 m_animation->stop();
51 m_animation->stop();
53 m_dirty=true;
52 m_dirty=true;
54 }
53 }
55
54
56 if(m_dirty){
55 if(m_dirty){
57 m_points=points();
56 m_points=points();
58 m_dirty=false;
57 m_dirty=false;
59 }
58 }
60
59
61 LineChartItem::updatePoint(index,newPoint);
60 LineChartItem::updatePoint(index,newPoint);
62
61
63 m_animation->setDuration(duration);
62 m_animation->setDuration(duration);
64 m_animation->setEasingCurve(QEasingCurve::InOutBack);
63 m_animation->setEasingCurve(QEasingCurve::InOutBack);
65 m_animation->setKeyValueAt(0.0, qVariantFromValue(m_points));
64 m_animation->setKeyValueAt(0.0, qVariantFromValue(m_points));
66 m_animation->setKeyValueAt(1.0, qVariantFromValue( points()));
65 m_animation->setKeyValueAt(1.0, qVariantFromValue( points()));
67
66
68 QTimer::singleShot(0,this,SLOT(startAnimation()));
67 QTimer::singleShot(0,this,SLOT(startAnimation()));
69
68
70
69
71 }
70 }
72
71
73 void LineChartAnimationItem::startAnimation()
72 void LineChartAnimationItem::startAnimation()
74 {
73 {
75 m_dirty=true;
74 m_dirty=true;
76 m_animation->start();
75 m_animation->start();
77 }
76 }
78
77
79 LineChartAnimatator::LineChartAnimatator(LineChartAnimationItem *item , QObject *parent):QVariantAnimation(parent),
78 LineChartAnimatator::LineChartAnimatator(LineChartAnimationItem *item , QObject *parent):QVariantAnimation(parent),
80 m_item(item)
79 m_item(item)
81 {
80 {
82 }
81 }
83
82
84 LineChartAnimatator::~LineChartAnimatator()
83 LineChartAnimatator::~LineChartAnimatator()
85 {
84 {
86 }
85 }
87
86
88 QVariant LineChartAnimatator::interpolated(const QVariant &start, const QVariant & end, qreal progress ) const
87 QVariant LineChartAnimatator::interpolated(const QVariant &start, const QVariant & end, qreal progress ) const
89 {
88 {
90 QVector<QPointF> startVector = qVariantValue<QVector<QPointF> >(start);
89 QVector<QPointF> startVector = qVariantValue<QVector<QPointF> >(start);
91 QVector<QPointF> endVecotr = qVariantValue<QVector<QPointF> >(end);
90 QVector<QPointF> endVecotr = qVariantValue<QVector<QPointF> >(end);
92 QVector<QPointF> result;
91 QVector<QPointF> result;
93 Q_ASSERT(startVector.count() == endVecotr.count());
92 Q_ASSERT(startVector.count() == endVecotr.count());
94
93
95 for(int i =0 ;i< startVector.count();i++){
94 for(int i =0 ;i< startVector.count();i++){
96 qreal x = startVector[i].x() + ((endVecotr[i].x()- startVector[i].x()) * progress);//qBound(0.0, progress, 1.0));
95 qreal x = startVector[i].x() + ((endVecotr[i].x()- startVector[i].x()) * progress);//qBound(0.0, progress, 1.0));
97 qreal y = startVector[i].y() + ((endVecotr[i].y()- startVector[i].y()) * progress);//qBound(0.0, progress, 1.0));
96 qreal y = startVector[i].y() + ((endVecotr[i].y()- startVector[i].y()) * progress);//qBound(0.0, progress, 1.0));
98 result << QPointF(x,y);
97 result << QPointF(x,y);
99 }
98 }
100 return qVariantFromValue(result);
99 return qVariantFromValue(result);
101 }
100 }
102
101
103 void LineChartAnimatator::updateCurrentValue (const QVariant & value )
102 void LineChartAnimatator::updateCurrentValue (const QVariant & value )
104 {
103 {
105 QVector<QPointF> vector = qVariantValue<QVector<QPointF> >(value);
104 QVector<QPointF> vector = qVariantValue<QVector<QPointF> >(value);
106 if(state()!=QAbstractAnimation::Stopped){ //workaround
105 if(state()!=QAbstractAnimation::Stopped){ //workaround
107 m_item->setGeometry(vector);
106 m_item->setGeometry(vector);
108 }
107 }
109 }
108 }
110
109
111 #include "moc_linechartanimationitem_p.cpp"
110 #include "moc_linechartanimationitem_p.cpp"
112
111
113 QTCOMMERCIALCHART_END_NAMESPACE
112 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,50 +1,50
1 #ifndef LINECHARTANIMATIONITEM_P_H_
1 #ifndef LINECHARTANIMATIONITEM_P_H_
2 #define LINECHARTANIMATIONITEM_P_H_
2 #define LINECHARTANIMATIONITEM_P_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "linechartitem_p.h"
5 #include "linechartitem_p.h"
6 #include "domain_p.h"
6 #include "domain_p.h"
7 #include <QVariantAnimation>
7 #include <QVariantAnimation>
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class LineChartAnimatator;
11 class LineChartAnimatator;
12
12
13 class LineChartAnimationItem : public LineChartItem {
13 class LineChartAnimationItem : public LineChartItem {
14
14
15 Q_OBJECT
15 Q_OBJECT
16
16
17 public:
17 public:
18 LineChartAnimationItem(QLineSeries *series, QGraphicsItem *parent = 0);
18 LineChartAnimationItem(QLineSeries *series, QGraphicsItem *parent = 0);
19 virtual ~LineChartAnimationItem();
19 virtual ~LineChartAnimationItem();
20
20
21 protected:
21 protected:
22 virtual void updateAllPoints();
22 virtual void updatePoints(QVector<QPointF>& newPoints);
23 virtual void updatePoint(int index,QPointF& newPoint);
23 virtual void updatePoint(int index,QPointF& newPoint);
24
24
25 private slots:
25 private slots:
26 void startAnimation();
26 void startAnimation();
27
27
28 private:
28 private:
29 LineChartAnimatator *m_animation;
29 LineChartAnimatator *m_animation;
30 QVector<QPointF> m_points;
30 QVector<QPointF> m_points;
31 bool m_dirty;
31 bool m_dirty;
32 };
32 };
33
33
34 class LineChartAnimatator: public QVariantAnimation
34 class LineChartAnimatator: public QVariantAnimation
35 {
35 {
36 public:
36 public:
37 LineChartAnimatator(LineChartAnimationItem *item, QObject *parent = 0 );
37 LineChartAnimatator(LineChartAnimationItem *item, QObject *parent = 0 );
38 ~LineChartAnimatator();
38 ~LineChartAnimatator();
39
39
40 protected:
40 protected:
41 QVariant interpolated(const QVariant &start, const QVariant & end, qreal progress ) const;
41 QVariant interpolated(const QVariant &start, const QVariant & end, qreal progress ) const;
42 void updateCurrentValue (const QVariant & value );
42 void updateCurrentValue (const QVariant & value );
43
43
44 private:
44 private:
45 LineChartAnimationItem* m_item;
45 LineChartAnimationItem* m_item;
46 };
46 };
47
47
48 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
49
49
50 #endif
50 #endif
@@ -1,245 +1,124
1 #include "linechartitem_p.h"
1 #include "linechartitem_p.h"
2 #include "qlineseries.h"
2 #include "qlineseries.h"
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include <QPainter>
4 #include <QPainter>
5
5
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 //TODO: optimize : remove points which are not visible
9 //TODO: optimize : remove points which are not visible
10
10
11 LineChartItem::LineChartItem(QLineSeries* series,QGraphicsItem *parent):ChartItem(parent),
11 LineChartItem::LineChartItem(QLineSeries* series,QGraphicsItem *parent):XYChartItem(series,parent),
12 m_minX(0),
13 m_maxX(0),
14 m_minY(0),
15 m_maxY(0),
16 m_series(series),
12 m_series(series),
17 m_items(this)
13 m_items(this)
18 {
14 {
19 //m_items.setZValue(ChartPresenter::LineChartZValue);
15 //m_items.setZValue(ChartPresenter::LineChartZValue);
20 setZValue(ChartPresenter::LineChartZValue);
16 setZValue(ChartPresenter::LineChartZValue);
21
22 QObject::connect(series,SIGNAL(pointReplaced(int)),this,SLOT(handlePointReplaced(int)));
23 QObject::connect(series,SIGNAL(pointAdded(int)),this,SLOT(handlePointAdded(int)));
24 QObject::connect(series,SIGNAL(pointRemoved(int)),this,SLOT(handlePointRemoved(int)));
25 QObject::connect(series,SIGNAL(updated()),this,SLOT(handleUpdated()));
17 QObject::connect(series,SIGNAL(updated()),this,SLOT(handleUpdated()));
26
18
27 handleUpdated();
19 handleUpdated();
28 }
20 }
29
21
30 QRectF LineChartItem::boundingRect() const
22 QRectF LineChartItem::boundingRect() const
31 {
23 {
32 return m_rect;
24 return m_rect;
33 }
25 }
34
26
35 QPainterPath LineChartItem::shape() const
27 QPainterPath LineChartItem::shape() const
36 {
28 {
37 return m_path;
29 return m_path;
38 }
30 }
39
31
40 void LineChartItem::createPoints(int count)
32 void LineChartItem::createPoints(int count)
41 {
33 {
42 for (int i = 0; i < count; ++i) {
34 for (int i = 0; i < count; ++i) {
43 QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3);
35 QGraphicsRectItem* item = new QGraphicsRectItem(0,0,3,3);
44 m_items.addToGroup(item);
36 m_items.addToGroup(item);
45 }
37 }
46 }
38 }
47
39
48 void LineChartItem::clearPoints(int count)
40 void LineChartItem::deletePoints(int count)
49 {
41 {
50 QList<QGraphicsItem *> items = m_items.childItems();
42 QList<QGraphicsItem *> items = m_items.childItems();
51
43
52 for (int i = 0; i < count; ++i) {
44 for (int i = 0; i < count; ++i) {
53 delete(items.takeLast());
45 delete(items.takeLast());
54 }
46 }
55 }
47 }
56
48
57 QPointF LineChartItem::calculateGeometryPoint(int index) const
49 void LineChartItem::setGeometry(QVector<QPointF>& points)
58 {
59 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
60 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
61 qreal x = (m_series->x(index) - m_minX)* deltaX;
62 qreal y = (m_series->y(index) - m_minY)*-deltaY + m_size.height();
63 return QPointF(x,y);
64 }
65
66 QVector<QPointF> LineChartItem::calculateGeometryPoints() const
67 {
68 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
69 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
70
71 QVector<QPointF> points;
72 points.reserve(m_series->count());
73 for (int i = 0; i < m_series->count(); ++i) {
74 qreal x = (m_series->x(i) - m_minX)* deltaX;
75 qreal y = (m_series->y(i) - m_minY)*-deltaY + m_size.height();
76 points << QPointF(x,y);
77 }
78 return points;
79 }
80
81 void LineChartItem::updateAllPoints()
82 {
50 {
83 QVector<QPointF> points = calculateGeometryPoints();
51 if(points.size()==0) return;
84
52
85 int diff = m_points.size() - points.size();
53 int diff = XYChartItem::points().size() - points.size();
86
54
87 if(diff>0) {
55 if(diff>0) {
88 clearPoints(diff);
56 deletePoints(diff);
89 }
57 }
90 else if(diff<0) {
58 else if(diff<0) {
91 createPoints(-diff);
59 createPoints(-diff);
92 }
60 }
93
61
94 setGeometry(points);
62 QList<QGraphicsItem*> items = m_items.childItems();
95 }
96
97 void LineChartItem::updatePoints(QVector<QPointF>& points)
98 {
99 int diff = m_points.size() - points.size();
100
63
101 if(diff>0) {
64 QPainterPath path;
102 clearPoints(diff);
65 const QPointF& point = points.at(0);
103 }
66 path.moveTo(point);
104 else if(diff<0) {
67 QGraphicsItem* item = items.at(0);
105 createPoints(-diff);
68 item->setPos(point.x()-1,point.y()-1);
106 }
69 if(!clipRect().contains(point)) {
70 item->setVisible(false);
71 }
72 else {
73 item->setVisible(true);
74 }
107
75
108 setGeometry(points);
76 for(int i=1; i< points.size();i++) {
109 }
77 QGraphicsItem* item = items.at(i);
78 const QPointF& point = points.at(i);
79 item->setPos(point.x()-1,point.y()-1);
80 if(!clipRect().contains(point)) {
81 item->setVisible(false);
82 }
83 else {
84 item->setVisible(true);
85 }
86 path.lineTo(point);
87 }
110
88
111 void LineChartItem::updatePoint(int index,QPointF& newPoint)
89 prepareGeometryChange();
112 {
90 m_path = path;
113 m_points.replace(index,newPoint);
91 m_rect = path.boundingRect();
114 setGeometry(m_points);
115 }
116
92
117 void LineChartItem::setGeometry(QVector<QPointF>& points)
93 XYChartItem::setGeometry(points);
118 {
119 if(points.size()==0) return;
120
121 QList<QGraphicsItem*> items = m_items.childItems();
122
123 QPainterPath path;
124 const QPointF& point = points.at(0);
125 path.moveTo(point);
126 QGraphicsItem* item = items.at(0);
127 item->setPos(point.x()-1,point.y()-1);
128 if(!m_clipRect.contains(point)) {
129 item->setVisible(false);
130 }else{
131 item->setVisible(true);
132 }
133
134 for(int i=1 ; i< points.size();i++) {
135 QGraphicsItem* item = items.at(i);
136 const QPointF& point = points.at(i);
137 item->setPos(point.x()-1,point.y()-1);
138 if(!m_clipRect.contains(point)) {
139 item->setVisible(false);
140 }else{
141 item->setVisible(true);
142 }
143 path.lineTo(point);
144 }
145
146 prepareGeometryChange();
147 m_path = path;
148 m_rect = path.boundingRect();
149 m_points = points;
150 }
94 }
151
95
152 void LineChartItem::setPen(const QPen& pen)
96 void LineChartItem::setPen(const QPen& pen)
153 {
97 {
154 m_pen = pen;
98 m_pen = pen;
155 }
99 }
156
100
157 //handlers
158
159 void LineChartItem::handlePointAdded(int index)
160 {
161 Q_ASSERT(index<m_series->count());
162 Q_ASSERT(index>=0);
163
164 QPointF point = calculateGeometryPoint(index);
165 createPoints(1);
166 QVector<QPointF> points = m_points;
167 points.insert(index,point);
168
169 updatePoints(points);
170 update();
171 }
172 void LineChartItem::handlePointRemoved(int index)
173 {
174 Q_ASSERT(index<m_series->count());
175 Q_ASSERT(index>=0);
176
177 QPointF point = calculateGeometryPoint(index);
178 clearPoints(1);
179 QVector<QPointF> points = m_points;
180 points.remove(index);
181 updatePoints(points);
182 update();
183 }
184
185 void LineChartItem::handlePointReplaced(int index)
186 {
187 Q_ASSERT(index<m_series->count());
188 Q_ASSERT(index>=0);
189 QPointF point = calculateGeometryPoint(index);
190 updatePoint(index,point);
191 update();
192 }
193
194 void LineChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY)
195 {
196 m_minX=minX;
197 m_maxX=maxX;
198 m_minY=minY;
199 m_maxY=maxY;
200
201 if(isEmpty()) return;
202 updateAllPoints();
203 update();
204 }
205
206 void LineChartItem::handleGeometryChanged(const QRectF& rect)
207 {
208 Q_ASSERT(rect.isValid());
209 m_size=rect.size();
210 m_clipRect=rect.translated(-rect.topLeft());
211 setPos(rect.topLeft());
212
213 if(isEmpty()) return;
214 updateAllPoints();
215 update();
216 }
217
101
218 void LineChartItem::handleUpdated()
102 void LineChartItem::handleUpdated()
219 {
103 {
220 m_items.setVisible(m_series->pointsVisible());
104 m_items.setVisible(m_series->pointsVisible());
221 setPen(m_series->pen());
105 setPen(m_series->pen());
222 update();
106 update();
223 }
107 }
224
108
225 //painter
109 //painter
226
110
227 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
111 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
228 {
112 {
229 Q_UNUSED(widget);
113 Q_UNUSED(widget);
230 Q_UNUSED(option);
114 Q_UNUSED(option);
231 painter->save();
115 painter->save();
232 painter->setPen(m_pen);
116 painter->setPen(m_pen);
233 painter->setClipRect(m_clipRect);
117 painter->setClipRect(clipRect());
234 painter->drawPath(m_path);
118 painter->drawPath(m_path);
235 painter->restore();
119 painter->restore();
236 }
120 }
237
121
238 bool LineChartItem::isEmpty()
239 {
240 return !m_clipRect.isValid() || m_maxX - m_minX == 0 || m_maxY - m_minY ==0 ;
241 }
242
243 #include "moc_linechartitem_p.cpp"
122 #include "moc_linechartitem_p.cpp"
244
123
245 QTCOMMERCIALCHART_END_NAMESPACE
124 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,69 +1,50
1 #ifndef LINECHARTITEM_H
1 #ifndef LINECHARTITEM_H
2 #define LINECHARTITEM_H
2 #define LINECHARTITEM_H
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "chartitem_p.h"
5 #include "xychartitem_p.h"
6 #include <QPen>
6 #include <QPen>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class ChartPresenter;
10 class ChartPresenter;
11 class QLineSeries;
11 class QLineSeries;
12
12
13 class LineChartItem : public QObject , public ChartItem
13 class LineChartItem : public XYChartItem
14 {
14 {
15 Q_OBJECT
15 Q_OBJECT
16 public:
16 public:
17 LineChartItem(QLineSeries* series,QGraphicsItem *parent = 0);
17 LineChartItem(QLineSeries* series,QGraphicsItem *parent = 0);
18 ~ LineChartItem(){};
18 ~ LineChartItem(){};
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 void setPen(const QPen& pen);
25 void setPen(const QPen& pen);
26 void setPointsVisible(bool visible);
26 void setPointsVisible(bool visible);
27
27
28 void createPoints(int count);
29 void deletePoints(int count);
30
28 public slots:
31 public slots:
29 void handlePointAdded(int index);
30 void handlePointRemoved(int index);
31 void handlePointReplaced(int index);
32 void handleUpdated();
32 void handleUpdated();
33 void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
34 void handleGeometryChanged(const QRectF& size);
35
33
36 protected:
34 protected:
37 virtual void updateAllPoints();
38 virtual void updatePoints(QVector<QPointF>& points);
39 virtual void updatePoint(int index,QPointF& newPoint);
40 virtual void setGeometry(QVector<QPointF>& points);
35 virtual void setGeometry(QVector<QPointF>& points);
41
36
42 QVector<QPointF> points() {return m_points;}
37 private:
43 void createPoints(int count);
44 void clearPoints(int count);
45 QPointF calculateGeometryPoint(int index) const;
46 QVector<QPointF> calculateGeometryPoints() const;
47 inline bool isEmpty();
48
49 protected:
50 qreal m_minX;
51 qreal m_maxX;
52 qreal m_minY;
53 qreal m_maxY;
54 QPainterPath m_path;
55 QRectF m_rect;
56 QLineSeries* m_series;
38 QLineSeries* m_series;
57 QSizeF m_size;
58 QRectF m_clipRect;
59 QGraphicsItemGroup m_items;
39 QGraphicsItemGroup m_items;
60 QVector<QPointF> m_points;
40 QPainterPath m_path;
41 QRectF m_rect;
61 QPen m_pen;
42 QPen m_pen;
62
43
63 friend class LineChartAnimatator;
44 friend class LineChartAnimatator;
64
45
65 };
46 };
66
47
67 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
68
49
69 #endif
50 #endif
@@ -1,224 +1,117
1 #include "qlineseries.h"
1 #include "qlineseries.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 /*!
5 /*!
6 \class QLineSeries
6 \class QLineSeries
7 \brief The QLineSeries class is used for making line charts.
7 \brief The QLineSeries class is used for making line charts.
8
8
9 \mainclass
9 \mainclass
10
10
11 A line chart is used to show information as a series of data points
11 A line chart is used to show information as a series of data points
12 connected by straight lines.
12 connected by straight lines.
13
13
14 \image linechart.png
14 \image linechart.png
15
15
16 Creating basic line chart is simple:
16 Creating basic line chart is simple:
17 \code
17 \code
18 QLineSeries* series = new QLineSeries();
18 QLineSeries* series = new QLineSeries();
19 series->add(0, 6);
19 series->add(0, 6);
20 series->add(2, 4);
20 series->add(2, 4);
21 ...
21 ...
22 chartView->addSeries(series);
22 chartView->addSeries(series);
23 \endcode
23 \endcode
24 */
24 */
25
25
26 /*!
26 /*!
27 \fn virtual QSeriesType QLineSeries::type() const
27 \fn virtual QSeriesType QLineSeries::type() const
28 \brief Returns type of series.
28 \brief Returns type of series.
29 \sa QSeries, QSeriesType
29 \sa QSeries, QSeriesType
30 */
30 */
31
31
32 /*!
32 /*!
33 \fn QPen QLineSeries::pen() const
33 \fn QPen QLineSeries::pen() const
34 \brief Returns the pen used to draw line for this series.
34 \brief Returns the pen used to draw line for this series.
35 \sa setPen()
35 \sa setPen()
36 */
36 */
37
37
38 /*!
38 /*!
39 \fn bool QLineSeries::pointsVisible() const
39 \fn bool QLineSeries::pointsVisible() const
40 \brief Returns if the points are drawn for this series.
40 \brief Returns if the points are drawn for this series.
41 \sa setPointsVisible()
41 \sa setPointsVisible()
42 */
42 */
43
43
44
44
45 /*!
45 /*!
46 \fn void QLineSeries::pointReplaced(int index)
46 \fn void QLineSeries::pointReplaced(int index)
47 \brief \internal \a index
47 \brief \internal \a index
48 */
48 */
49
49
50 /*!
50 /*!
51 \fn void QLineSeries::pointAdded(int index)
51 \fn void QLineSeries::pointAdded(int index)
52 \brief \internal \a index
52 \brief \internal \a index
53 */
53 */
54
54
55 /*!
55 /*!
56 \fn void QLineSeries::pointRemoved(int index)
56 \fn void QLineSeries::pointRemoved(int index)
57 \brief \internal \a index
57 \brief \internal \a index
58 */
58 */
59
59
60 /*!
60 /*!
61 \fn void QLineSeries::updated()
61 \fn void QLineSeries::updated()
62 \brief \internal
62 \brief \internal
63 */
63 */
64
64
65 /*!
65 /*!
66 Constructs empty series object which is a child of \a parent.
66 Constructs empty series object which is a child of \a parent.
67 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.
68 */
68 */
69 QLineSeries::QLineSeries(QObject* parent):QSeries(parent),
69 QLineSeries::QLineSeries(QObject* parent):QXYSeries(parent),
70 m_pointsVisible(false)
70 m_pointsVisible(false)
71 {
71 {
72 }
72 }
73 /*!
73 /*!
74 Destroys the object. Series added to QChartView or QChart instances are owned by those,
74 Destroys the object. Series added to QChartView or QChart instances are owned by those,
75 and are deleted when mentioned object are destroyed.
75 and are deleted when mentioned object are destroyed.
76 */
76 */
77 QLineSeries::~QLineSeries()
77 QLineSeries::~QLineSeries()
78 {
78 {
79 }
79 }
80
80
81 /*!
81 /*!
82 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
83 */
84 void QLineSeries::add(qreal x,qreal y)
85 {
86 Q_ASSERT(m_x.size() == m_y.size());
87 m_x<<x;
88 m_y<<y;
89 emit pointAdded(m_x.size()-1);
90 }
91
92 /*!
93 This is an overloaded function.
94 Adds data \a point to the series. Points are connected with lines on the chart.
95 */
96 void QLineSeries::add(const QPointF& point)
97 {
98 add(point.x(),point.y());
99 }
100
101 /*!
102 Modifies \a y value for given \a x a value.
103 */
104 void QLineSeries::replace(qreal x,qreal y)
105 {
106 int index = m_x.indexOf(x);
107 m_x[index]=x;
108 m_y[index]=y;
109 emit pointReplaced(index);
110 }
111
112 /*!
113 This is an overloaded function.
114 Replaces current y value of for given \a point x value with \a point y value.
115 */
116 void QLineSeries::replace(const QPointF& point)
117 {
118 replace(point.x(),point.y());
119 }
120
121 /*!
122 Removes current \a x and y value.
123 */
124 void QLineSeries::remove(qreal x)
125 {
126 int index = m_x.indexOf(x);
127 emit pointRemoved(index);
128 m_x.remove(index);
129 m_y.remove(index);
130 }
131
132 /*!
133 Removes current \a point x value. Note \a point y value is ignored.
134 */
135 void QLineSeries::remove(const QPointF& point)
136 {
137 remove(point.x());
138 }
139
140 /*!
141 Clears all the data.
142 */
143 void QLineSeries::clear()
144 {
145 m_x.clear();
146 m_y.clear();
147 }
148
149 /*!
150 \internal \a pos
151 */
152 qreal QLineSeries::x(int pos) const
153 {
154 return m_x.at(pos);
155 }
156
157 /*!
158 \internal \a pos
159 */
160 qreal QLineSeries::y(int pos) const
161 {
162 return m_y.at(pos);
163 }
164
165 /*!
166 Returns number of data points within series.
167 */
168 int QLineSeries::count() const
169 {
170 Q_ASSERT(m_x.size() == m_y.size());
171
172 return m_x.size();
173
174 }
175
176 /*!
177 Sets \a pen used for drawing given series..
82 Sets \a pen used for drawing given series..
178 */
83 */
179 void QLineSeries::setPen(const QPen& pen)
84 void QLineSeries::setPen(const QPen& pen)
180 {
85 {
181 if(pen!=m_pen){
86 if(pen!=m_pen){
182 m_pen=pen;
87 m_pen=pen;
183 emit updated();
88 emit updated();
184 }
89 }
185 }
90 }
186
91
187 /*!
92 /*!
188 Sets if data points are \a visible and should be drawn on line.
93 Sets if data points are \a visible and should be drawn on line.
189 */
94 */
190 void QLineSeries::setPointsVisible(bool visible)
95 void QLineSeries::setPointsVisible(bool visible)
191 {
96 {
192 if(m_pointsVisible!=visible){
97 if(m_pointsVisible!=visible){
193 m_pointsVisible=visible;
98 m_pointsVisible=visible;
194 emit updated();
99 emit updated();
195 }
100 }
196 }
101 }
197
102
198 QDebug operator<< (QDebug debug, const QLineSeries series)
103 QDebug operator<< (QDebug debug, const QLineSeries series)
199 {
104 {
200 Q_ASSERT(series.m_x.size() == series.m_y.size());
105 Q_ASSERT(series.m_x.size() == series.m_y.size());
201
106
202 int size = series.m_x.size();
107 int size = series.m_x.size();
203
108
204 for (int i=0;i<size;i++) {
109 for (int i=0;i<size;i++) {
205 debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") ";
110 debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") ";
206 }
111 }
207 return debug.space();
112 return debug.space();
208 }
113 }
209
114
210 /*!
211 Stream operator for adding a data \a point to the series.
212 \sa add()
213 */
214
215 QLineSeries& QLineSeries::operator<< (const QPointF &point)
216 {
217 add(point);
218 return *this;
219 }
220
221
222 #include "moc_qlineseries.cpp"
115 #include "moc_qlineseries.cpp"
223
116
224 QTCOMMERCIALCHART_END_NAMESPACE
117 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,60 +1,35
1 #ifndef QLINESERIES_H_
1 #ifndef QLINESERIES_H_
2 #define QLINESERIES_H_
2 #define QLINESERIES_H_
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qseries.h"
5 #include "qxyseries.h"
6 #include <QDebug>
6 #include <QDebug>
7 #include <QPen>
7 #include <QPen>
8 #include <QBrush>
8 #include <QBrush>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QSeries
12 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16 QLineSeries(QObject* parent=0);
16 QLineSeries(QObject* parent=0);
17 virtual ~QLineSeries();
17 virtual ~QLineSeries();
18
18
19 public: // from QChartSeries
19 public: // from QChartSeries
20 virtual QSeriesType type() const {return QSeries::SeriesTypeLine;}
20 virtual QSeriesType type() const {return QSeries::SeriesTypeLine;}
21 void add(qreal x, qreal y);
22 void add(const QPointF& point);
23 void replace(qreal x,qreal y);
24 void replace(const QPointF& point);
25 void remove(qreal x);
26 void remove(const QPointF& point);
27 void clear();
28
29 void setPen(const QPen& pen);
21 void setPen(const QPen& pen);
30 QPen pen() const {return m_pen;}
22 QPen pen() const {return m_pen;}
31
23
32 void setPointsVisible(bool visible);
24 void setPointsVisible(bool visible);
33 bool pointsVisible() const {return m_pointsVisible;}
25 bool pointsVisible() const {return m_pointsVisible;}
34
26
35 int count() const;
27 friend QDebug operator<< (QDebug d, const QLineSeries series);
36 qreal x(int pos) const;
37 qreal y(int pos) const;
38
39 QLineSeries& operator << (const QPointF &point);
40 friend QDebug operator<< (QDebug d, const QLineSeries series);
41
42 signals:
43 void updated();
44 void pointReplaced(int index);
45 void pointRemoved(int index);
46 void pointAdded(int index);
47
48
49 protected:
50 QVector<qreal> m_x;
51 QVector<qreal> m_y;
52
53 private:
28 private:
54 QPen m_pen;
29 QPen m_pen;
55 bool m_pointsVisible;
30 bool m_pointsVisible;
56 };
31 };
57
32
58 QTCOMMERCIALCHART_END_NAMESPACE
33 QTCOMMERCIALCHART_END_NAMESPACE
59
34
60 #endif
35 #endif
@@ -1,75 +1,84
1 #include "splinechartitem_p.h"
1 #include "splinechartitem_p.h"
2 #include <QPainter>
2 #include <QPainter>
3
3
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5
5
6 SplineChartItem::SplineChartItem(QSplineSeries* series, QGraphicsObject *parent) :
6 SplineChartItem::SplineChartItem(QSplineSeries* series, QGraphicsObject *parent) :
7 LineChartItem(series, parent)//,m_boundingRect()
7 XYChartItem(series, parent),
8 m_series(series)
8 {
9 {
9 //
10 }
10 }
11
11
12 QRectF SplineChartItem::boundingRect() const
13 {
14 return m_rect;
15 }
12
16
17 QPainterPath SplineChartItem::shape() const
18 {
19 return m_path;
20 }
13
21
14 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const
22 QPointF SplineChartItem::calculateGeometryControlPoint(int index) const
15 {
23 {
16 QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(m_series);
24 return XYChartItem::calculateGeometryPoint(m_series->controlPoint(index));
17 const qreal deltaX = m_size.width()/(m_maxX-m_minX);
18 const qreal deltaY = m_size.height()/(m_maxY-m_minY);
19 qreal x = (splineSeries->controlPoint(index).x() - m_minX)* deltaX;
20 qreal y = (splineSeries->controlPoint(index).y() - m_minY)*-deltaY + m_size.height();
21 return QPointF(x,y);
22 }
25 }
23
26
24 void SplineChartItem::setGeometry(QVector<QPointF>& points)
27 void SplineChartItem::setGeometry(QVector<QPointF>& points)
25 {
28 {
26 if(points.size()==0) return;
29 if(points.size()==0) return;
27
30
28 QPainterPath splinePath;
31 QPainterPath splinePath;
29 const QPointF& point = points.at(0);
32 const QPointF& point = points.at(0);
30 splinePath.moveTo(point);
33 splinePath.moveTo(point);
31
34
32 // QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(m_series);
33 for (int i = 0; i < points.size() - 1; i++)
35 for (int i = 0; i < points.size() - 1; i++)
34 {
36 {
35 const QPointF& point = points.at(i + 1);
37 const QPointF& point = points.at(i + 1);
36 splinePath.cubicTo(calculateGeometryControlPoint(2 * i), calculateGeometryControlPoint(2 * i + 1), point);
38 splinePath.cubicTo(calculateGeometryControlPoint(2 * i), calculateGeometryControlPoint(2 * i + 1), point);
37 }
39 }
38
40
39 prepareGeometryChange();
41 prepareGeometryChange();
40 m_path = splinePath;
42 m_path = splinePath;
41 m_rect = splinePath.boundingRect();
43 m_rect = splinePath.boundingRect();
44 XYChartItem::setGeometry(points);
45 }
46
47 void SplineChartItem::setPen(const QPen& pen)
48 {
49 m_pen = pen;
42 }
50 }
43
51
52
44 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
53 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
45 {
54 {
46 Q_UNUSED(widget);
55 Q_UNUSED(widget);
47 Q_UNUSED(option);
56 Q_UNUSED(option);
48 painter->save();
57 painter->save();
49 painter->setPen(m_pen);
58 painter->setClipRect(clipRect());
50 painter->setClipRect(m_clipRect);
51 painter->drawPath(m_path);
59 painter->drawPath(m_path);
52
60
53 QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(m_series);
61 const QVector<QPointF> points = XYChartItem::points();
54 for (int i = 0; i < m_points.size() - 1; i++)
62
63 for (int i = 0; i < points.size() - 1; i++)
55 {
64 {
56 painter->setPen(Qt::red);
65 painter->setPen(Qt::red);
57 painter->drawEllipse(m_points[i], 2, 2);
66 painter->drawEllipse(points[i], 2, 2);
58
67
59 painter->setPen(Qt::blue);
68 painter->setPen(Qt::blue);
60 // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i));
69 // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i));
61 // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1));
70 // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1));
62 // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4);
71 // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4);
63 // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4);
72 // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4);
64 }
73 }
65 if (m_points.count() > 0)
74 if (points.count() > 0)
66 {
75 {
67 painter->setPen(Qt::red);
76 painter->setPen(Qt::red);
68 painter->drawEllipse(m_points[m_points.count() - 1], 2, 2);
77 painter->drawEllipse(points[points.count() - 1], 2, 2);
69 }
78 }
70 painter->restore();
79 painter->restore();
71 }
80 }
72
81
73 #include "moc_splinechartitem_p.cpp"
82 #include "moc_splinechartitem_p.cpp"
74
83
75 QTCOMMERCIALCHART_END_NAMESPACE
84 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,28 +1,40
1 #ifndef SPLINECHARTITEM_P_H
1 #ifndef SPLINECHARTITEM_P_H
2 #define SPLINECHARTITEM_P_H
2 #define SPLINECHARTITEM_P_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5 #include <QObject>
5 #include <QObject>
6 #include "qsplineseries.h"
6 #include "qsplineseries.h"
7 #include "linechartitem_p.h"
7 #include "xychartitem_p.h"
8
8
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
10
11 class SplineChartItem : public LineChartItem
11 class SplineChartItem : public XYChartItem
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14 public:
14 public:
15 SplineChartItem(QSplineSeries* series, QGraphicsObject *parent = 0);
15 SplineChartItem(QSplineSeries* series, QGraphicsObject *parent = 0);
16
16
17 void updateGeometry();
17 //from QGraphicsItem
18 QRectF boundingRect() const;
19 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
20 QPainterPath shape() const;
18
21
22 void setPen(const QPen& pen);
23 void setPointsVisible(bool visible);
24
25 protected:
19 void setGeometry(QVector<QPointF>& points);
26 void setGeometry(QVector<QPointF>& points);
20
27
28 private:
21 QPointF calculateGeometryControlPoint(int index) const;
29 QPointF calculateGeometryControlPoint(int index) const;
22
30
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
31 private:
32 QSplineSeries* m_series;
33 QPainterPath m_path;
34 QRectF m_rect;
35 QPen m_pen;
24 };
36 };
25
37
26 QTCOMMERCIALCHART_END_NAMESPACE
38 QTCOMMERCIALCHART_END_NAMESPACE
27
39
28 #endif // SPLINECHARTITEM_P_H
40 #endif // SPLINECHARTITEM_P_H
@@ -1,94 +1,95
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
2 TARGET = QtCommercialChart
2 TARGET = QtCommercialChart
3 DESTDIR = $$CHART_BUILD_LIB_DIR
3 DESTDIR = $$CHART_BUILD_LIB_DIR
4 TEMPLATE = lib
4 TEMPLATE = lib
5 QT += core \
5 QT += core \
6 gui
6 gui
7 CONFIG += debug_and_release
7 CONFIG += debug_and_release
8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 SOURCES += axisitem.cpp \
9 SOURCES += axisitem.cpp \
10 axisanimationitem.cpp \
10 axisanimationitem.cpp \
11 chartdataset.cpp \
11 chartdataset.cpp \
12 chartpresenter.cpp \
12 chartpresenter.cpp \
13 charttheme.cpp \
13 charttheme.cpp \
14 domain.cpp \
14 domain.cpp \
15 qchart.cpp \
15 qchart.cpp \
16 qchartaxis.cpp \
16 qchartaxis.cpp \
17 qchartaxiscategories.cpp \
17 qchartaxiscategories.cpp \
18 qchartview.cpp \
18 qchartview.cpp \
19 qseries.cpp
19 qseries.cpp
20 PRIVATE_HEADERS += axisitem_p.h \
20 PRIVATE_HEADERS += axisitem_p.h \
21 axisanimationitem_p.h \
21 axisanimationitem_p.h \
22 chartdataset_p.h \
22 chartdataset_p.h \
23 chartitem_p.h \
23 chartitem_p.h \
24 chartpresenter_p.h \
24 chartpresenter_p.h \
25 charttheme_p.h \
25 charttheme_p.h \
26 domain_p.h
26 domain_p.h
27 PUBLIC_HEADERS += qchart.h \
27 PUBLIC_HEADERS += qchart.h \
28 qchartaxis.h \
28 qchartaxis.h \
29 qchartaxiscategories.h \
29 qchartaxiscategories.h \
30 qchartglobal.h \
30 qchartglobal.h \
31 qseries.h \
31 qseries.h \
32 qchartview.h
32 qchartview.h
33 include(xychart/xychart.pri)
33 include(linechart/linechart.pri)
34 include(linechart/linechart.pri)
34 include(areachart/areachart.pri)
35 include(areachart/areachart.pri)
35 include(barchart/barchart.pri)
36 include(barchart/barchart.pri)
36 include(piechart/piechart.pri)
37 include(piechart/piechart.pri)
37 include(scatterseries/scatter.pri)
38 include(scatterseries/scatter.pri)
38 include(splinechart/splinechart.pri)
39 include(splinechart/splinechart.pri)
39
40
40 THEMES += themes/chartthemeicy_p.h \
41 THEMES += themes/chartthemeicy_p.h \
41 themes/chartthemegrayscale_p.h \
42 themes/chartthemegrayscale_p.h \
42 themes/chartthemescientific_p.h \
43 themes/chartthemescientific_p.h \
43 themes/chartthemevanilla_p.h
44 themes/chartthemevanilla_p.h
44 HEADERS += $$PUBLIC_HEADERS
45 HEADERS += $$PUBLIC_HEADERS
45 HEADERS += $$PRIVATE_HEADERS
46 HEADERS += $$PRIVATE_HEADERS
46 HEADERS += $$THEMES
47 HEADERS += $$THEMES
47 INCLUDEPATH += linechart \
48 INCLUDEPATH += linechart \
48 barchart \
49 barchart \
49 themes \
50 themes \
50 .
51 .
51 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
52 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
52 MOC_DIR = $$CHART_BUILD_DIR/lib
53 MOC_DIR = $$CHART_BUILD_DIR/lib
53 UI_DIR = $$CHART_BUILD_DIR/lib
54 UI_DIR = $$CHART_BUILD_DIR/lib
54 RCC_DIR = $$CHART_BUILD_DIR/lib
55 RCC_DIR = $$CHART_BUILD_DIR/lib
55 DEFINES += QTCOMMERCIALCHART_LIBRARY
56 DEFINES += QTCOMMERCIALCHART_LIBRARY
56 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
57 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
57 public_headers.files = $$PUBLIC_HEADERS
58 public_headers.files = $$PUBLIC_HEADERS
58 target.path = $$[QT_INSTALL_LIBS]
59 target.path = $$[QT_INSTALL_LIBS]
59 INSTALLS += target \
60 INSTALLS += target \
60 public_headers
61 public_headers
61 install_build_public_headers.name = bild_public_headers
62 install_build_public_headers.name = bild_public_headers
62 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
63 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
63 install_build_public_headers.input = PUBLIC_HEADERS
64 install_build_public_headers.input = PUBLIC_HEADERS
64 install_build_public_headers.commands = $$QMAKE_COPY \
65 install_build_public_headers.commands = $$QMAKE_COPY \
65 ${QMAKE_FILE_NAME} \
66 ${QMAKE_FILE_NAME} \
66 $$CHART_BUILD_PUBLIC_HEADER_DIR
67 $$CHART_BUILD_PUBLIC_HEADER_DIR
67 install_build_public_headers.CONFIG += target_predeps \
68 install_build_public_headers.CONFIG += target_predeps \
68 no_link
69 no_link
69 install_build_private_headers.name = bild_private_headers
70 install_build_private_headers.name = bild_private_headers
70 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
71 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
71 install_build_private_headers.input = PRIVATE_HEADERS
72 install_build_private_headers.input = PRIVATE_HEADERS
72 install_build_private_headers.commands = $$QMAKE_COPY \
73 install_build_private_headers.commands = $$QMAKE_COPY \
73 ${QMAKE_FILE_NAME} \
74 ${QMAKE_FILE_NAME} \
74 $$CHART_BUILD_PRIVATE_HEADER_DIR
75 $$CHART_BUILD_PRIVATE_HEADER_DIR
75 install_build_private_headers.CONFIG += target_predeps \
76 install_build_private_headers.CONFIG += target_predeps \
76 no_link
77 no_link
77 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
78 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
78 install_build_private_headers
79 install_build_private_headers
79 chartversion.target = qchartversion_p.h
80 chartversion.target = qchartversion_p.h
80 chartversion.commands = @echo \
81 chartversion.commands = @echo \
81 "build_time" \
82 "build_time" \
82 > \
83 > \
83 $$chartversion.target;
84 $$chartversion.target;
84 chartversion.depends = $$HEADERS \
85 chartversion.depends = $$HEADERS \
85 $$SOURCES
86 $$SOURCES
86 PRE_TARGETDEPS += qchartversion_p.h
87 PRE_TARGETDEPS += qchartversion_p.h
87 QMAKE_CLEAN += qchartversion_p.h
88 QMAKE_CLEAN += qchartversion_p.h
88 QMAKE_EXTRA_TARGETS += chartversion
89 QMAKE_EXTRA_TARGETS += chartversion
89 unix:QMAKE_DISTCLEAN += -r \
90 unix:QMAKE_DISTCLEAN += -r \
90 $$CHART_BUILD_HEADER_DIR \
91 $$CHART_BUILD_HEADER_DIR \
91 $$CHART_BUILD_LIB_DIR
92 $$CHART_BUILD_LIB_DIR
92 win32:QMAKE_DISTCLEAN += /Q \
93 win32:QMAKE_DISTCLEAN += /Q \
93 $$CHART_BUILD_HEADER_DIR \
94 $$CHART_BUILD_HEADER_DIR \
94 $$CHART_BUILD_LIB_DIR
95 $$CHART_BUILD_LIB_DIR
General Comments 0
You need to be logged in to leave comments. Login now