@@ -0,0 +1,6 | |||||
|
1 | #include "qsplineseries.h" | |||
|
2 | ||||
|
3 | QSplineSeries::QSplineSeries(QObject *parent) : | |||
|
4 | QObject(parent) | |||
|
5 | { | |||
|
6 | } |
@@ -0,0 +1,24 | |||||
|
1 | #ifndef QSPLINESERIES_H | |||
|
2 | #define QSPLINESERIES_H | |||
|
3 | ||||
|
4 | #include "qchartseries.h" | |||
|
5 | ||||
|
6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
7 | ||||
|
8 | class QSplineSeries : public QChartSeries | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit QSplineSeries(QObject *parent = 0); | |||
|
13 | ||||
|
14 | public: // from QChartSeries | |||
|
15 | QChartSeriesType type() const { return QChartSeries::SeriesTypeSpline; } | |||
|
16 | signals: | |||
|
17 | ||||
|
18 | public slots: | |||
|
19 | ||||
|
20 | }; | |||
|
21 | ||||
|
22 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
23 | ||||
|
24 | #endif // QSPLINESERIES_H |
@@ -0,0 +1,15 | |||||
|
1 | INCLUDEPATH += $$PWD | |||
|
2 | DEPENDPATH += $$PWD | |||
|
3 | ||||
|
4 | SOURCES += \ | |||
|
5 | $$PWD/qsplineseries.cpp \ | |||
|
6 | splinechart/splinepresenter.cpp | |||
|
7 | ||||
|
8 | PRIVATE_HEADERS += | |||
|
9 | ||||
|
10 | PUBLIC_HEADERS += \ | |||
|
11 | $$PWD/qsplineseries.h | |||
|
12 | ||||
|
13 | HEADERS += \ | |||
|
14 | splinechart/qsplineseries.h \ | |||
|
15 | splinechart/splinepresenter_p.h |
@@ -0,0 +1,16 | |||||
|
1 | #include "splinepresenter_p.h" | |||
|
2 | ||||
|
3 | SplinePresenter::SplinePresenter(QObject *parent) : | |||
|
4 | QObject(parent) | |||
|
5 | { | |||
|
6 | } | |||
|
7 | ||||
|
8 | void SplinePresenter::handleGeometryChanged(const QRectF&) | |||
|
9 | { | |||
|
10 | // | |||
|
11 | } | |||
|
12 | ||||
|
13 | void SplinePresenter::handleDomainChanged(const Domain& domain) | |||
|
14 | { | |||
|
15 | // | |||
|
16 | } |
@@ -0,0 +1,26 | |||||
|
1 | #ifndef SPLINEPRESENTER_P_H | |||
|
2 | #define SPLINEPRESENTER_P_H | |||
|
3 | ||||
|
4 | #include "chartitem_p.h" | |||
|
5 | #include <QObject> | |||
|
6 | ||||
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
8 | ||||
|
9 | class SplinePresenter : public QObject, public ChartItem | |||
|
10 | { | |||
|
11 | Q_OBJECT | |||
|
12 | public: | |||
|
13 | SplinePresenter(QObject *parent = 0); | |||
|
14 | ||||
|
15 | void handleGeometryChanged(const QRectF&); | |||
|
16 | void handleDomainChanged(const Domain& domain); | |||
|
17 | ||||
|
18 | signals: | |||
|
19 | ||||
|
20 | public slots: | |||
|
21 | ||||
|
22 | }; | |||
|
23 | ||||
|
24 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
25 | ||||
|
26 | #endif // SPLINEPRESENTER_P_H |
@@ -1,226 +1,233 | |||||
1 | #include "qchart.h" |
|
1 | #include "qchart.h" | |
2 | #include "qchartaxis.h" |
|
2 | #include "qchartaxis.h" | |
3 | #include "chartpresenter_p.h" |
|
3 | #include "chartpresenter_p.h" | |
4 | #include "chartdataset_p.h" |
|
4 | #include "chartdataset_p.h" | |
5 | #include "charttheme_p.h" |
|
5 | #include "charttheme_p.h" | |
6 | //series |
|
6 | //series | |
7 | #include "qbarchartseries.h" |
|
7 | #include "qbarchartseries.h" | |
8 | #include "qstackedbarchartseries.h" |
|
8 | #include "qstackedbarchartseries.h" | |
9 | #include "qpercentbarchartseries.h" |
|
9 | #include "qpercentbarchartseries.h" | |
10 | #include "qlinechartseries.h" |
|
10 | #include "qlinechartseries.h" | |
11 | #include "qpieseries.h" |
|
11 | #include "qpieseries.h" | |
12 | #include "qscatterseries.h" |
|
12 | #include "qscatterseries.h" | |
|
13 | #include "qsplineseries.h" | |||
13 | //items |
|
14 | //items | |
14 | #include "axisitem_p.h" |
|
15 | #include "axisitem_p.h" | |
15 | #include "barpresenter.h" |
|
16 | #include "barpresenter.h" | |
16 | #include "stackedbarpresenter.h" |
|
17 | #include "stackedbarpresenter.h" | |
17 | #include "linechartitem_p.h" |
|
18 | #include "linechartitem_p.h" | |
18 | #include "percentbarpresenter.h" |
|
19 | #include "percentbarpresenter.h" | |
19 | #include "linechartanimationitem_p.h" |
|
20 | #include "linechartanimationitem_p.h" | |
20 | #include "piepresenter.h" |
|
21 | #include "piepresenter.h" | |
21 | #include "scatterpresenter_p.h" |
|
22 | #include "scatterpresenter_p.h" | |
|
23 | #include "splinepresenter_p.h" | |||
22 |
|
24 | |||
23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
24 |
|
26 | |||
25 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), |
|
27 | ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart), | |
26 | m_chart(chart), |
|
28 | m_chart(chart), | |
27 | m_dataset(dataset), |
|
29 | m_dataset(dataset), | |
28 | m_chartTheme(0), |
|
30 | m_chartTheme(0), | |
29 | m_marginSize(0), |
|
31 | m_marginSize(0), | |
30 | m_rect(QRectF(QPoint(0,0),m_chart->size())) |
|
32 | m_rect(QRectF(QPoint(0,0),m_chart->size())) | |
31 | { |
|
33 | { | |
32 | createConnections(); |
|
34 | createConnections(); | |
33 | setChartTheme(QChart::ChartThemeDefault); |
|
35 | setChartTheme(QChart::ChartThemeDefault); | |
34 |
|
36 | |||
35 | } |
|
37 | } | |
36 |
|
38 | |||
37 | ChartPresenter::~ChartPresenter() |
|
39 | ChartPresenter::~ChartPresenter() | |
38 | { |
|
40 | { | |
39 | } |
|
41 | } | |
40 |
|
42 | |||
41 | void ChartPresenter::createConnections() |
|
43 | void ChartPresenter::createConnections() | |
42 | { |
|
44 | { | |
43 | QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged())); |
|
45 | QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged())); | |
44 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*))); |
|
46 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*))); | |
45 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*))); |
|
47 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*))); | |
46 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*))); |
|
48 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*))); | |
47 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); |
|
49 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*))); | |
48 | QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&))); |
|
50 | QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&))); | |
49 | QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&))); |
|
51 | QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&))); | |
50 | } |
|
52 | } | |
51 |
|
53 | |||
52 |
|
54 | |||
53 | QRectF ChartPresenter::geometry() const |
|
55 | QRectF ChartPresenter::geometry() const | |
54 | { |
|
56 | { | |
55 | return m_rect; |
|
57 | return m_rect; | |
56 | } |
|
58 | } | |
57 |
|
59 | |||
58 | void ChartPresenter::handleGeometryChanged() |
|
60 | void ChartPresenter::handleGeometryChanged() | |
59 | { |
|
61 | { | |
60 | m_rect = QRectF(QPoint(0,0),m_chart->size()); |
|
62 | m_rect = QRectF(QPoint(0,0),m_chart->size()); | |
61 | m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize); |
|
63 | m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize); | |
62 | Q_ASSERT(m_rect.isValid()); |
|
64 | Q_ASSERT(m_rect.isValid()); | |
63 | emit geometryChanged(m_rect); |
|
65 | emit geometryChanged(m_rect); | |
64 | } |
|
66 | } | |
65 |
|
67 | |||
66 | int ChartPresenter::margin() const |
|
68 | int ChartPresenter::margin() const | |
67 | { |
|
69 | { | |
68 | return m_marginSize; |
|
70 | return m_marginSize; | |
69 | } |
|
71 | } | |
70 |
|
72 | |||
71 | void ChartPresenter::setMargin(int margin) |
|
73 | void ChartPresenter::setMargin(int margin) | |
72 | { |
|
74 | { | |
73 | m_marginSize = margin; |
|
75 | m_marginSize = margin; | |
74 | } |
|
76 | } | |
75 |
|
77 | |||
76 | void ChartPresenter::handleAxisAdded(QChartAxis* axis) |
|
78 | void ChartPresenter::handleAxisAdded(QChartAxis* axis) | |
77 | { |
|
79 | { | |
78 | AxisItem* item ; |
|
80 | AxisItem* item ; | |
79 |
|
81 | |||
80 | if(axis==m_dataset->axisX()){ |
|
82 | if(axis==m_dataset->axisX()){ | |
81 | item = new AxisItem(AxisItem::X_AXIS,m_chart); |
|
83 | item = new AxisItem(AxisItem::X_AXIS,m_chart); | |
82 | }else{ |
|
84 | }else{ | |
83 | item = new AxisItem(AxisItem::Y_AXIS,m_chart); |
|
85 | item = new AxisItem(AxisItem::Y_AXIS,m_chart); | |
84 | } |
|
86 | } | |
85 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
87 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
86 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); |
|
88 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); | |
87 |
|
89 | |||
88 | item->handleAxisUpdate(axis); |
|
90 | item->handleAxisUpdate(axis); | |
89 | item->handleGeometryChanged(m_rect); |
|
91 | item->handleGeometryChanged(m_rect); | |
90 | m_chartTheme->decorate(axis,item); |
|
92 | m_chartTheme->decorate(axis,item); | |
91 | m_axisItems.insert(axis,item); |
|
93 | m_axisItems.insert(axis,item); | |
92 | } |
|
94 | } | |
93 |
|
95 | |||
94 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) |
|
96 | void ChartPresenter::handleAxisRemoved(QChartAxis* axis) | |
95 | { |
|
97 | { | |
96 | AxisItem* item = m_axisItems.take(axis); |
|
98 | AxisItem* item = m_axisItems.take(axis); | |
97 | Q_ASSERT(item); |
|
99 | Q_ASSERT(item); | |
98 | delete item; |
|
100 | delete item; | |
99 | } |
|
101 | } | |
100 |
|
102 | |||
101 |
|
103 | |||
102 | void ChartPresenter::handleSeriesAdded(QChartSeries* series) |
|
104 | void ChartPresenter::handleSeriesAdded(QChartSeries* series) | |
103 | { |
|
105 | { | |
104 | switch(series->type()) |
|
106 | switch(series->type()) | |
105 | { |
|
107 | { | |
106 | case QChartSeries::SeriesTypeLine: { |
|
108 | case QChartSeries::SeriesTypeLine: { | |
107 | QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series); |
|
109 | QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series); | |
108 | LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); |
|
110 | LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart); | |
109 | m_chartTheme->decorate(item,lineSeries,m_chartItems.count()); |
|
111 | m_chartTheme->decorate(item,lineSeries,m_chartItems.count()); | |
110 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
112 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
111 | QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
113 | QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
112 | m_chartItems.insert(series,item); |
|
114 | m_chartItems.insert(series,item); | |
113 | break; |
|
115 | break; | |
114 | } |
|
116 | } | |
115 |
|
117 | |||
116 | case QChartSeries::SeriesTypeBar: { |
|
118 | case QChartSeries::SeriesTypeBar: { | |
117 | QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series); |
|
119 | QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series); | |
118 | BarPresenter* item = new BarPresenter(barSeries,m_chart); |
|
120 | BarPresenter* item = new BarPresenter(barSeries,m_chart); | |
119 | m_chartTheme->decorate(item,barSeries,m_chartItems.count()); |
|
121 | m_chartTheme->decorate(item,barSeries,m_chartItems.count()); | |
120 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
122 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
121 | QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
123 | QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
122 | m_chartItems.insert(series,item); |
|
124 | m_chartItems.insert(series,item); | |
123 | // m_axisXItem->setVisible(false); |
|
125 | // m_axisXItem->setVisible(false); | |
124 | break; |
|
126 | break; | |
125 | } |
|
127 | } | |
126 |
|
128 | |||
127 | case QChartSeries::SeriesTypeStackedBar: { |
|
129 | case QChartSeries::SeriesTypeStackedBar: { | |
128 |
|
130 | |||
129 | QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series); |
|
131 | QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series); | |
130 | StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries,m_chart); |
|
132 | StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries,m_chart); | |
131 | m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count()); |
|
133 | m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count()); | |
132 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
134 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
133 | QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
135 | QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
134 | m_chartItems.insert(series,item); |
|
136 | m_chartItems.insert(series,item); | |
135 | break; |
|
137 | break; | |
136 | } |
|
138 | } | |
137 |
|
139 | |||
138 | case QChartSeries::SeriesTypePercentBar: { |
|
140 | case QChartSeries::SeriesTypePercentBar: { | |
139 |
|
141 | |||
140 | QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series); |
|
142 | QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series); | |
141 | PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries,m_chart); |
|
143 | PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries,m_chart); | |
142 | m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count()); |
|
144 | m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count()); | |
143 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
145 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
144 | QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); |
|
146 | QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int))); | |
145 | m_chartItems.insert(series,item); |
|
147 | m_chartItems.insert(series,item); | |
146 | break; |
|
148 | break; | |
147 | } |
|
149 | } | |
148 | case QChartSeries::SeriesTypeScatter: { |
|
150 | case QChartSeries::SeriesTypeScatter: { | |
149 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); |
|
151 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); | |
150 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); |
|
152 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); | |
151 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), |
|
153 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), | |
152 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); |
|
154 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); | |
153 | m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count()); |
|
155 | m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count()); | |
154 | m_chartItems.insert(scatterSeries, scatterPresenter); |
|
156 | m_chartItems.insert(scatterSeries, scatterPresenter); | |
155 | break; |
|
157 | break; | |
156 | } |
|
158 | } | |
157 | case QChartSeries::SeriesTypePie: { |
|
159 | case QChartSeries::SeriesTypePie: { | |
158 | QPieSeries *s = qobject_cast<QPieSeries *>(series); |
|
160 | QPieSeries *s = qobject_cast<QPieSeries *>(series); | |
159 | PiePresenter* pie = new PiePresenter(m_chart, s); |
|
161 | PiePresenter* pie = new PiePresenter(m_chart, s); | |
160 | m_chartTheme->decorate(pie, s, m_chartItems.count()); |
|
162 | m_chartTheme->decorate(pie, s, m_chartItems.count()); | |
161 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&))); |
|
163 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&))); | |
162 | m_chartItems.insert(series, pie); |
|
164 | m_chartItems.insert(series, pie); | |
163 | break; |
|
165 | break; | |
164 | } |
|
166 | } | |
|
167 | case QChartSeries::SeriesTypeSpline: { | |||
|
168 | QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(series); | |||
|
169 | SplinePresenter* splinePresenter = new SplinePresenter | |||
|
170 | break; | |||
|
171 | } | |||
165 | default: { |
|
172 | default: { | |
166 | qDebug()<< "Series type" << series->type() << "not implemented."; |
|
173 | qDebug()<< "Series type" << series->type() << "not implemented."; | |
167 | break; |
|
174 | break; | |
168 | } |
|
175 | } | |
169 | } |
|
176 | } | |
170 |
|
177 | |||
171 | if(m_rect.isValid()) emit geometryChanged(m_rect); |
|
178 | if(m_rect.isValid()) emit geometryChanged(m_rect); | |
172 | } |
|
179 | } | |
173 |
|
180 | |||
174 | void ChartPresenter::handleSeriesRemoved(QChartSeries* series) |
|
181 | void ChartPresenter::handleSeriesRemoved(QChartSeries* series) | |
175 | { |
|
182 | { | |
176 | ChartItem* item = m_chartItems.take(series); |
|
183 | ChartItem* item = m_chartItems.take(series); | |
177 | delete item; |
|
184 | delete item; | |
178 | } |
|
185 | } | |
179 |
|
186 | |||
180 | void ChartPresenter::handleSeriesChanged(QChartSeries* series) |
|
187 | void ChartPresenter::handleSeriesChanged(QChartSeries* series) | |
181 | { |
|
188 | { | |
182 | //TODO: |
|
189 | //TODO: | |
183 | } |
|
190 | } | |
184 |
|
191 | |||
185 | void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain) |
|
192 | void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain) | |
186 | { |
|
193 | { | |
187 | m_chartItems.value(series)->handleDomainChanged(domain); |
|
194 | m_chartItems.value(series)->handleDomainChanged(domain); | |
188 | } |
|
195 | } | |
189 |
|
196 | |||
190 | void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels) |
|
197 | void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels) | |
191 | { |
|
198 | { | |
192 | m_axisItems.value(axis)->handleLabelsChanged(axis,labels); |
|
199 | m_axisItems.value(axis)->handleLabelsChanged(axis,labels); | |
193 | } |
|
200 | } | |
194 |
|
201 | |||
195 | void ChartPresenter::setChartTheme(QChart::ChartTheme theme) |
|
202 | void ChartPresenter::setChartTheme(QChart::ChartTheme theme) | |
196 | { |
|
203 | { | |
197 | delete m_chartTheme; |
|
204 | delete m_chartTheme; | |
198 |
|
205 | |||
199 | m_chartTheme = ChartTheme::createTheme(theme); |
|
206 | m_chartTheme = ChartTheme::createTheme(theme); | |
200 |
|
207 | |||
201 | m_chartTheme->decorate(m_chart); |
|
208 | m_chartTheme->decorate(m_chart); | |
202 | QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems); |
|
209 | QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems); | |
203 |
|
210 | |||
204 | int index=0; |
|
211 | int index=0; | |
205 | while (i.hasNext()) { |
|
212 | while (i.hasNext()) { | |
206 | i.next(); |
|
213 | i.next(); | |
207 | index++; |
|
214 | index++; | |
208 | m_chartTheme->decorate(i.value(),i.key(),index); |
|
215 | m_chartTheme->decorate(i.value(),i.key(),index); | |
209 | } |
|
216 | } | |
210 |
|
217 | |||
211 | QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems); |
|
218 | QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems); | |
212 | while (j.hasNext()) { |
|
219 | while (j.hasNext()) { | |
213 | j.next(); |
|
220 | j.next(); | |
214 | m_chartTheme->decorate(j.key(),j.value()); |
|
221 | m_chartTheme->decorate(j.key(),j.value()); | |
215 | } |
|
222 | } | |
216 | } |
|
223 | } | |
217 |
|
224 | |||
218 | QChart::ChartTheme ChartPresenter::chartTheme() |
|
225 | QChart::ChartTheme ChartPresenter::chartTheme() | |
219 | { |
|
226 | { | |
220 | return m_chartTheme->id(); |
|
227 | return m_chartTheme->id(); | |
221 | } |
|
228 | } | |
222 |
|
229 | |||
223 |
|
230 | |||
224 | #include "moc_chartpresenter_p.cpp" |
|
231 | #include "moc_chartpresenter_p.cpp" | |
225 |
|
232 | |||
226 | QTCOMMERCIALCHART_END_NAMESPACE |
|
233 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,45 +1,45 | |||||
1 | #ifndef QCHARTSERIES_H |
|
1 | #ifndef QCHARTSERIES_H | |
2 | #define QCHARTSERIES_H |
|
2 | #define QCHARTSERIES_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QAbstractItemModel> |
|
6 | #include <QAbstractItemModel> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject |
|
10 | class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject | |
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
13 | public: | |
14 | enum QChartSeriesType { |
|
14 | enum QChartSeriesType { | |
15 | SeriesTypeInvalid = -1, |
|
15 | SeriesTypeInvalid = -1, | |
16 | SeriesTypeLine, |
|
16 | SeriesTypeLine, | |
17 | // SeriesTypeArea, |
|
17 | // SeriesTypeArea, | |
18 | SeriesTypeBar, |
|
18 | SeriesTypeBar, | |
19 | SeriesTypeStackedBar, |
|
19 | SeriesTypeStackedBar, | |
20 | SeriesTypePercentBar, |
|
20 | SeriesTypePercentBar, | |
21 | SeriesTypePie, |
|
21 | SeriesTypePie, | |
22 | SeriesTypeScatter |
|
22 | SeriesTypeScatter, | |
23 |
|
|
23 | SeriesTypeSpline | |
24 | }; |
|
24 | }; | |
25 |
|
25 | |||
26 | protected: |
|
26 | protected: | |
27 | QChartSeries(QObject *parent = 0):QObject(parent){}; |
|
27 | QChartSeries(QObject *parent = 0):QObject(parent){}; | |
28 |
|
28 | |||
29 | public: |
|
29 | public: | |
30 | virtual ~QChartSeries(){}; |
|
30 | virtual ~QChartSeries(){}; | |
31 |
|
31 | |||
32 | // Pure virtual |
|
32 | // Pure virtual | |
33 | virtual QChartSeriesType type() const = 0; |
|
33 | virtual QChartSeriesType type() const = 0; | |
34 |
|
34 | |||
35 | virtual bool setData(QList<qreal> /*data*/) { return false; } |
|
35 | virtual bool setData(QList<qreal> /*data*/) { return false; } | |
36 | virtual bool setData(QList<qreal> /*x*/, QList<qreal> /*y*/){ return false; } |
|
36 | virtual bool setData(QList<qreal> /*x*/, QList<qreal> /*y*/){ return false; } | |
37 |
|
37 | |||
38 | // Prototype for data model. TODO: remove the other setData methods and use something like this for now? |
|
38 | // Prototype for data model. TODO: remove the other setData methods and use something like this for now? | |
39 | virtual bool setModel(QAbstractItemModel* /*model*/) { return false; } |
|
39 | virtual bool setModel(QAbstractItemModel* /*model*/) { return false; } | |
40 | }; |
|
40 | }; | |
41 |
|
41 | |||
42 | QTCOMMERCIALCHART_END_NAMESPACE |
|
42 | QTCOMMERCIALCHART_END_NAMESPACE | |
43 |
|
43 | |||
44 | #endif |
|
44 | #endif | |
45 |
|
45 |
@@ -1,92 +1,93 | |||||
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 += \ |
|
9 | SOURCES += \ | |
10 | axisitem.cpp \ |
|
10 | axisitem.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 | qchartseries.cpp \ |
|
17 | qchartseries.cpp \ | |
18 | qchartview.cpp |
|
18 | qchartview.cpp | |
19 | PRIVATE_HEADERS += \ |
|
19 | PRIVATE_HEADERS += \ | |
20 | axisitem_p.h \ |
|
20 | axisitem_p.h \ | |
21 | chartdataset_p.h \ |
|
21 | chartdataset_p.h \ | |
22 | chartitem_p.h \ |
|
22 | chartitem_p.h \ | |
23 | chartpresenter_p.h \ |
|
23 | chartpresenter_p.h \ | |
24 | charttheme_p.h \ |
|
24 | charttheme_p.h \ | |
25 | domain_p.h |
|
25 | domain_p.h | |
26 | PUBLIC_HEADERS += \ |
|
26 | PUBLIC_HEADERS += \ | |
27 | qchart.h \ |
|
27 | qchart.h \ | |
28 | qchartaxis.h \ |
|
28 | qchartaxis.h \ | |
29 | qchartglobal.h \ |
|
29 | qchartglobal.h \ | |
30 | qchartseries.h \ |
|
30 | qchartseries.h \ | |
31 | qchartview.h \ |
|
31 | qchartview.h \ | |
32 |
|
32 | |||
33 | include(linechart/linechart.pri) |
|
33 | include(linechart/linechart.pri) | |
34 | include(barchart/barchart.pri) |
|
34 | include(barchart/barchart.pri) | |
35 | include(piechart/piechart.pri) |
|
35 | include(piechart/piechart.pri) | |
36 | include(scatterseries/scatter.pri) |
|
36 | include(scatterseries/scatter.pri) | |
|
37 | include(splinechart/splinechart.pri) | |||
37 |
|
38 | |||
38 | THEMES += themes/chartthemeicy_p.h \ |
|
39 | THEMES += themes/chartthemeicy_p.h \ | |
39 | themes/chartthemegrayscale_p.h \ |
|
40 | themes/chartthemegrayscale_p.h \ | |
40 | themes/chartthemescientific_p.h \ |
|
41 | themes/chartthemescientific_p.h \ | |
41 | themes/chartthemevanilla_p.h |
|
42 | themes/chartthemevanilla_p.h | |
42 | HEADERS += $$PUBLIC_HEADERS |
|
43 | HEADERS += $$PUBLIC_HEADERS | |
43 | HEADERS += $$PRIVATE_HEADERS |
|
44 | HEADERS += $$PRIVATE_HEADERS | |
44 | HEADERS += $$THEMES |
|
45 | HEADERS += $$THEMES | |
45 | INCLUDEPATH += linechart \ |
|
46 | INCLUDEPATH += linechart \ | |
46 | barchart \ |
|
47 | barchart \ | |
47 | themes \ |
|
48 | themes \ | |
48 | . |
|
49 | . | |
49 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
|
50 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib | |
50 | MOC_DIR = $$CHART_BUILD_DIR/lib |
|
51 | MOC_DIR = $$CHART_BUILD_DIR/lib | |
51 | UI_DIR = $$CHART_BUILD_DIR/lib |
|
52 | UI_DIR = $$CHART_BUILD_DIR/lib | |
52 | RCC_DIR = $$CHART_BUILD_DIR/lib |
|
53 | RCC_DIR = $$CHART_BUILD_DIR/lib | |
53 | DEFINES += QTCOMMERCIALCHART_LIBRARY |
|
54 | DEFINES += QTCOMMERCIALCHART_LIBRARY | |
54 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart |
|
55 | public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart | |
55 | public_headers.files = $$PUBLIC_HEADERS |
|
56 | public_headers.files = $$PUBLIC_HEADERS | |
56 | target.path = $$[QT_INSTALL_LIBS] |
|
57 | target.path = $$[QT_INSTALL_LIBS] | |
57 | INSTALLS += target \ |
|
58 | INSTALLS += target \ | |
58 | public_headers |
|
59 | public_headers | |
59 | install_build_public_headers.name = bild_public_headers |
|
60 | install_build_public_headers.name = bild_public_headers | |
60 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
61 | install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
61 | install_build_public_headers.input = PUBLIC_HEADERS |
|
62 | install_build_public_headers.input = PUBLIC_HEADERS | |
62 | install_build_public_headers.commands = $$QMAKE_COPY \ |
|
63 | install_build_public_headers.commands = $$QMAKE_COPY \ | |
63 | ${QMAKE_FILE_NAME} \ |
|
64 | ${QMAKE_FILE_NAME} \ | |
64 | $$CHART_BUILD_PUBLIC_HEADER_DIR |
|
65 | $$CHART_BUILD_PUBLIC_HEADER_DIR | |
65 | install_build_public_headers.CONFIG += target_predeps \ |
|
66 | install_build_public_headers.CONFIG += target_predeps \ | |
66 | no_link |
|
67 | no_link | |
67 | install_build_private_headers.name = bild_private_headers |
|
68 | install_build_private_headers.name = bild_private_headers | |
68 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h |
|
69 | install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h | |
69 | install_build_private_headers.input = PRIVATE_HEADERS |
|
70 | install_build_private_headers.input = PRIVATE_HEADERS | |
70 | install_build_private_headers.commands = $$QMAKE_COPY \ |
|
71 | install_build_private_headers.commands = $$QMAKE_COPY \ | |
71 | ${QMAKE_FILE_NAME} \ |
|
72 | ${QMAKE_FILE_NAME} \ | |
72 | $$CHART_BUILD_PRIVATE_HEADER_DIR |
|
73 | $$CHART_BUILD_PRIVATE_HEADER_DIR | |
73 | install_build_private_headers.CONFIG += target_predeps \ |
|
74 | install_build_private_headers.CONFIG += target_predeps \ | |
74 | no_link |
|
75 | no_link | |
75 | QMAKE_EXTRA_COMPILERS += install_build_public_headers install_build_private_headers |
|
76 | QMAKE_EXTRA_COMPILERS += install_build_public_headers install_build_private_headers | |
76 | chartversion.target = qchartversion_p.h |
|
77 | chartversion.target = qchartversion_p.h | |
77 | chartversion.commands = @echo \ |
|
78 | chartversion.commands = @echo \ | |
78 | "build_time" \ |
|
79 | "build_time" \ | |
79 | > \ |
|
80 | > \ | |
80 | $$chartversion.target; |
|
81 | $$chartversion.target; | |
81 | chartversion.depends = $$HEADERS \ |
|
82 | chartversion.depends = $$HEADERS \ | |
82 | $$SOURCES |
|
83 | $$SOURCES | |
83 | PRE_TARGETDEPS += qchartversion_p.h |
|
84 | PRE_TARGETDEPS += qchartversion_p.h | |
84 | QMAKE_CLEAN += qchartversion_p.h |
|
85 | QMAKE_CLEAN += qchartversion_p.h | |
85 | QMAKE_EXTRA_TARGETS += chartversion |
|
86 | QMAKE_EXTRA_TARGETS += chartversion | |
86 | unix:QMAKE_DISTCLEAN += -r \ |
|
87 | unix:QMAKE_DISTCLEAN += -r \ | |
87 | $$CHART_BUILD_HEADER_DIR \ |
|
88 | $$CHART_BUILD_HEADER_DIR \ | |
88 | $$CHART_BUILD_LIB_DIR |
|
89 | $$CHART_BUILD_LIB_DIR | |
89 | win32:QMAKE_DISTCLEAN += /Q \ |
|
90 | win32:QMAKE_DISTCLEAN += /Q \ | |
90 | $$CHART_BUILD_HEADER_DIR \ |
|
91 | $$CHART_BUILD_HEADER_DIR \ | |
91 | $$CHART_BUILD_LIB_DIR |
|
92 | $$CHART_BUILD_LIB_DIR | |
92 |
|
93 |
General Comments 0
You need to be logged in to leave comments.
Login now