@@ -1,360 +1,371 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include <QGraphicsScene> |
|
23 | #include <QGraphicsScene> | |
24 | #include <QGraphicsSceneResizeEvent> |
|
24 | #include <QGraphicsSceneResizeEvent> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \enum QChart::ChartTheme |
|
29 | \enum QChart::ChartTheme | |
30 |
|
30 | |||
31 | This enum describes the theme used by the chart. |
|
31 | This enum describes the theme used by the chart. | |
32 |
|
32 | |||
33 | \value ChartThemeLight The default theme |
|
33 | \value ChartThemeLight The default theme | |
34 | \value ChartThemeBlueCerulean |
|
34 | \value ChartThemeBlueCerulean | |
35 | \value ChartThemeDark |
|
35 | \value ChartThemeDark | |
36 | \value ChartThemeBrownSand |
|
36 | \value ChartThemeBrownSand | |
37 | \value ChartThemeBlueNcs |
|
37 | \value ChartThemeBlueNcs | |
38 | \value ChartThemeHighContrast |
|
38 | \value ChartThemeHighContrast | |
39 | \value ChartThemeBlueIcy |
|
39 | \value ChartThemeBlueIcy | |
40 | \value ChartThemeCount Not really a theme; the total count of themes. |
|
40 | \value ChartThemeCount Not really a theme; the total count of themes. | |
41 | */ |
|
41 | */ | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | \enum QChart::AnimationOption |
|
44 | \enum QChart::AnimationOption | |
45 |
|
45 | |||
46 | For enabling/disabling animations. Defaults to NoAnimation. |
|
46 | For enabling/disabling animations. Defaults to NoAnimation. | |
47 |
|
47 | |||
48 | \value NoAnimation |
|
48 | \value NoAnimation | |
49 | \value GridAxisAnimations |
|
49 | \value GridAxisAnimations | |
50 | \value SeriesAnimations |
|
50 | \value SeriesAnimations | |
51 | \value AllAnimations |
|
51 | \value AllAnimations | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | /*! |
|
54 | /*! | |
55 | \class QChart |
|
55 | \class QChart | |
56 | \brief QtCommercial chart API. |
|
56 | \brief QtCommercial chart API. | |
57 |
|
57 | |||
58 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
58 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
59 | representation of different types of QChartSeries and other chart related objects like |
|
59 | representation of different types of QChartSeries and other chart related objects like | |
60 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the |
|
60 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the | |
61 | convenience class QChartView instead of QChart. |
|
61 | convenience class QChartView instead of QChart. | |
62 | \sa QChartView |
|
62 | \sa QChartView | |
63 | */ |
|
63 | */ | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
66 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
67 | */ |
|
67 | */ | |
68 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
68 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
69 | d_ptr(new QChartPrivate()) |
|
69 | d_ptr(new QChartPrivate()) | |
70 | { |
|
70 | { | |
71 | d_ptr->m_legend = new ScrolledQLegend(this); |
|
71 | d_ptr->m_legend = new ScrolledQLegend(this); | |
72 | d_ptr->m_dataset = new ChartDataSet(this); |
|
72 | d_ptr->m_dataset = new ChartDataSet(this); | |
73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
73 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
74 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
74 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
75 | d_ptr->createConnections(); |
|
75 | d_ptr->createConnections(); | |
76 | //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3); |
|
76 | //TODO:fix me setMinimumSize(d_ptr->m_padding.left() * 3, d_ptr->m_padding.top() * 3); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. |
|
80 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. | |
81 | */ |
|
81 | */ | |
82 | QChart::~QChart() |
|
82 | QChart::~QChart() | |
83 | { |
|
83 | { | |
84 | //delete first presenter , since this is a root of all the graphical items |
|
84 | //delete first presenter , since this is a root of all the graphical items | |
85 | delete d_ptr->m_presenter; |
|
85 | delete d_ptr->m_presenter; | |
86 | d_ptr->m_presenter=0; |
|
86 | d_ptr->m_presenter=0; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | /*! |
|
89 | /*! | |
90 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. |
|
90 | Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects. | |
91 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
91 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
92 | the y axis). |
|
92 | the y axis). | |
93 | */ |
|
93 | */ | |
94 | void QChart::addSeries(QSeries* series, QChartAxis* axisY) |
|
94 | void QChart::addSeries(QSeries* series, QChartAxis* axisY) | |
95 | { |
|
95 | { | |
96 | d_ptr->m_dataset->addSeries(series, axisY); |
|
96 | d_ptr->m_dataset->addSeries(series, axisY); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | Removes the \a series specified in a perameter from the QChartView. |
|
100 | Removes the \a series specified in a perameter from the QChartView. | |
101 | It releses its ownership of the specified QChartSeries object. |
|
101 | It releses its ownership of the specified QChartSeries object. | |
102 | It does not delete the pointed QChartSeries data object |
|
102 | It does not delete the pointed QChartSeries data object | |
103 | \sa addSeries(), removeAllSeries() |
|
103 | \sa addSeries(), removeAllSeries() | |
104 | */ |
|
104 | */ | |
105 | void QChart::removeSeries(QSeries* series) |
|
105 | void QChart::removeSeries(QSeries* series) | |
106 | { |
|
106 | { | |
107 | d_ptr->m_dataset->removeSeries(series); |
|
107 | d_ptr->m_dataset->removeSeries(series); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | Removes all the QChartSeries that have been added to the QChartView |
|
111 | Removes all the QChartSeries that have been added to the QChartView | |
112 | It also deletes the pointed QChartSeries data objects |
|
112 | It also deletes the pointed QChartSeries data objects | |
113 | \sa addSeries(), removeSeries() |
|
113 | \sa addSeries(), removeSeries() | |
114 | */ |
|
114 | */ | |
115 | void QChart::removeAllSeries() |
|
115 | void QChart::removeAllSeries() | |
116 | { |
|
116 | { | |
117 | d_ptr->m_dataset->removeAllSeries(); |
|
117 | d_ptr->m_dataset->removeAllSeries(); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | /*! |
|
120 | /*! | |
121 | Sets the \a brush that is used for painting the background of the chart area. |
|
121 | Sets the \a brush that is used for painting the background of the chart area. | |
122 | */ |
|
122 | */ | |
123 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
123 | void QChart::setBackgroundBrush(const QBrush& brush) | |
124 | { |
|
124 | { | |
|
125 | //TODO: refactor me | |||
125 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
126 | d_ptr->m_presenter->createChartBackgroundItem(); | |
126 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); |
|
127 | d_ptr->m_presenter->m_backgroundItem->setBrush(brush); | |
127 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
128 | d_ptr->m_presenter->m_backgroundItem->update(); | |
128 | } |
|
129 | } | |
129 |
|
130 | |||
130 | QBrush QChart::backgroundBrush() const |
|
131 | QBrush QChart::backgroundBrush() const | |
131 | { |
|
132 | { | |
|
133 | //TODO: refactor me | |||
132 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); |
|
134 | if (!d_ptr->m_presenter->m_backgroundItem) return QBrush(); | |
133 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); |
|
135 | return (d_ptr->m_presenter->m_backgroundItem)->brush(); | |
134 | } |
|
136 | } | |
135 |
|
137 | |||
136 | /*! |
|
138 | /*! | |
137 | Sets the \a pen that is used for painting the background of the chart area. |
|
139 | Sets the \a pen that is used for painting the background of the chart area. | |
138 | */ |
|
140 | */ | |
139 | void QChart::setBackgroundPen(const QPen& pen) |
|
141 | void QChart::setBackgroundPen(const QPen& pen) | |
140 | { |
|
142 | { | |
|
143 | //TODO: refactor me | |||
141 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
144 | d_ptr->m_presenter->createChartBackgroundItem(); | |
142 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); |
|
145 | d_ptr->m_presenter->m_backgroundItem->setPen(pen); | |
143 | d_ptr->m_presenter->m_backgroundItem->update(); |
|
146 | d_ptr->m_presenter->m_backgroundItem->update(); | |
144 | } |
|
147 | } | |
145 |
|
148 | |||
146 | QPen QChart::backgroundPen() const |
|
149 | QPen QChart::backgroundPen() const | |
147 | { |
|
150 | { | |
|
151 | //TODO: refactor me | |||
148 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); |
|
152 | if (!d_ptr->m_presenter->m_backgroundItem) return QPen(); | |
149 | return d_ptr->m_presenter->m_backgroundItem->pen(); |
|
153 | return d_ptr->m_presenter->m_backgroundItem->pen(); | |
150 | } |
|
154 | } | |
151 |
|
155 | |||
152 | /*! |
|
156 | /*! | |
153 | Sets the chart \a title. The description text that is drawn above the chart. |
|
157 | Sets the chart \a title. The description text that is drawn above the chart. | |
154 | */ |
|
158 | */ | |
155 | void QChart::setTitle(const QString& title) |
|
159 | void QChart::setTitle(const QString& title) | |
156 | { |
|
160 | { | |
|
161 | //TODO: refactor me | |||
157 | d_ptr->m_presenter->createChartTitleItem(); |
|
162 | d_ptr->m_presenter->createChartTitleItem(); | |
158 | d_ptr->m_presenter->m_titleItem->setText(title); |
|
163 | d_ptr->m_presenter->m_titleItem->setText(title); | |
159 | d_ptr->m_presenter->updateLayout(); |
|
164 | d_ptr->m_presenter->updateLayout(); | |
160 | } |
|
165 | } | |
161 |
|
166 | |||
162 | /*! |
|
167 | /*! | |
163 | Returns the chart title. The description text that is drawn above the chart. |
|
168 | Returns the chart title. The description text that is drawn above the chart. | |
164 | */ |
|
169 | */ | |
165 | QString QChart::title() const |
|
170 | QString QChart::title() const | |
166 | { |
|
171 | { | |
|
172 | //TODO: refactor me | |||
167 | if (d_ptr->m_presenter->m_titleItem) |
|
173 | if (d_ptr->m_presenter->m_titleItem) | |
168 | return d_ptr->m_presenter->m_titleItem->text(); |
|
174 | return d_ptr->m_presenter->m_titleItem->text(); | |
169 | else |
|
175 | else | |
170 | return QString(); |
|
176 | return QString(); | |
171 | } |
|
177 | } | |
172 |
|
178 | |||
173 | /*! |
|
179 | /*! | |
174 | Sets the \a font that is used for rendering the description text that is rendered above the chart. |
|
180 | Sets the \a font that is used for rendering the description text that is rendered above the chart. | |
175 | */ |
|
181 | */ | |
176 | void QChart::setTitleFont(const QFont& font) |
|
182 | void QChart::setTitleFont(const QFont& font) | |
177 | { |
|
183 | { | |
|
184 | //TODO: refactor me | |||
178 | d_ptr->m_presenter->createChartTitleItem(); |
|
185 | d_ptr->m_presenter->createChartTitleItem(); | |
179 | d_ptr->m_presenter->m_titleItem->setFont(font); |
|
186 | d_ptr->m_presenter->m_titleItem->setFont(font); | |
180 | d_ptr->m_presenter->updateLayout(); |
|
187 | d_ptr->m_presenter->updateLayout(); | |
181 | } |
|
188 | } | |
182 |
|
189 | |||
183 | /*! |
|
190 | /*! | |
184 | Sets the \a brush used for rendering the title text. |
|
191 | Sets the \a brush used for rendering the title text. | |
185 | */ |
|
192 | */ | |
186 | void QChart::setTitleBrush(const QBrush &brush) |
|
193 | void QChart::setTitleBrush(const QBrush &brush) | |
187 | { |
|
194 | { | |
|
195 | //TODO: refactor me | |||
188 | d_ptr->m_presenter->createChartTitleItem(); |
|
196 | d_ptr->m_presenter->createChartTitleItem(); | |
189 | d_ptr->m_presenter->m_titleItem->setBrush(brush); |
|
197 | d_ptr->m_presenter->m_titleItem->setBrush(brush); | |
190 | d_ptr->m_presenter->updateLayout(); |
|
198 | d_ptr->m_presenter->updateLayout(); | |
191 | } |
|
199 | } | |
192 |
|
200 | |||
193 | /*! |
|
201 | /*! | |
194 | Returns the brush used for rendering the title text. |
|
202 | Returns the brush used for rendering the title text. | |
195 | */ |
|
203 | */ | |
196 | QBrush QChart::titleBrush() const |
|
204 | QBrush QChart::titleBrush() const | |
197 | { |
|
205 | { | |
|
206 | //TODO: refactor me | |||
198 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); |
|
207 | if (!d_ptr->m_presenter->m_titleItem) return QBrush(); | |
199 | return d_ptr->m_presenter->m_titleItem->brush(); |
|
208 | return d_ptr->m_presenter->m_titleItem->brush(); | |
200 | } |
|
209 | } | |
201 |
|
210 | |||
202 | /*! |
|
211 | /*! | |
203 | Sets the \a theme used by the chart for rendering the graphical representation of the data |
|
212 | Sets the \a theme used by the chart for rendering the graphical representation of the data | |
204 | \sa ChartTheme, chartTheme() |
|
213 | \sa ChartTheme, chartTheme() | |
205 | */ |
|
214 | */ | |
206 | void QChart::setTheme(QChart::ChartTheme theme) |
|
215 | void QChart::setTheme(QChart::ChartTheme theme) | |
207 | { |
|
216 | { | |
208 | d_ptr->m_presenter->setTheme(theme); |
|
217 | d_ptr->m_presenter->setTheme(theme); | |
209 | } |
|
218 | } | |
210 |
|
219 | |||
211 | /*! |
|
220 | /*! | |
212 | Returns the theme enum used by the chart. |
|
221 | Returns the theme enum used by the chart. | |
213 | \sa ChartTheme, setChartTheme() |
|
222 | \sa ChartTheme, setChartTheme() | |
214 | */ |
|
223 | */ | |
215 | QChart::ChartTheme QChart::theme() const |
|
224 | QChart::ChartTheme QChart::theme() const | |
216 | { |
|
225 | { | |
217 | return d_ptr->m_presenter->theme(); |
|
226 | return d_ptr->m_presenter->theme(); | |
218 | } |
|
227 | } | |
219 |
|
228 | |||
220 | /*! |
|
229 | /*! | |
221 | Zooms in the view by a factor of 2 |
|
230 | Zooms in the view by a factor of 2 | |
222 | */ |
|
231 | */ | |
223 | void QChart::zoomIn() |
|
232 | void QChart::zoomIn() | |
224 | { |
|
233 | { | |
225 | d_ptr->m_presenter->zoomIn(); |
|
234 | d_ptr->m_presenter->zoomIn(); | |
226 | } |
|
235 | } | |
227 |
|
236 | |||
228 | /*! |
|
237 | /*! | |
229 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
238 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
230 | */ |
|
239 | */ | |
231 | void QChart::zoomIn(const QRectF& rect) |
|
240 | void QChart::zoomIn(const QRectF& rect) | |
232 | { |
|
241 | { | |
233 | if (!rect.isValid()) return; |
|
242 | if (!rect.isValid()) return; | |
234 | d_ptr->m_presenter->zoomIn(rect); |
|
243 | d_ptr->m_presenter->zoomIn(rect); | |
235 | } |
|
244 | } | |
236 |
|
245 | |||
237 | /*! |
|
246 | /*! | |
238 | Restores the view zoom level to the previous one. |
|
247 | Restores the view zoom level to the previous one. | |
239 | */ |
|
248 | */ | |
240 | void QChart::zoomOut() |
|
249 | void QChart::zoomOut() | |
241 | { |
|
250 | { | |
242 | d_ptr->m_presenter->zoomOut(); |
|
251 | d_ptr->m_presenter->zoomOut(); | |
243 | } |
|
252 | } | |
244 |
|
253 | |||
245 | /*! |
|
254 | /*! | |
246 | Returns the pointer to the x axis object of the chart |
|
255 | Returns the pointer to the x axis object of the chart | |
247 | */ |
|
256 | */ | |
248 | QChartAxis* QChart::axisX() const |
|
257 | QChartAxis* QChart::axisX() const | |
249 | { |
|
258 | { | |
250 | return d_ptr->m_dataset->axisX(); |
|
259 | return d_ptr->m_dataset->axisX(); | |
251 | } |
|
260 | } | |
252 |
|
261 | |||
253 | /*! |
|
262 | /*! | |
254 | Returns the pointer to the y axis object of the chart |
|
263 | Returns the pointer to the y axis object of the chart | |
255 | */ |
|
264 | */ | |
256 | QChartAxis* QChart::axisY() const |
|
265 | QChartAxis* QChart::axisY() const | |
257 | { |
|
266 | { | |
258 | return d_ptr->m_dataset->axisY(); |
|
267 | return d_ptr->m_dataset->axisY(); | |
259 | } |
|
268 | } | |
260 |
|
269 | |||
261 | /*! |
|
270 | /*! | |
262 | Returns the legend object of the chart. Ownership stays in chart. |
|
271 | Returns the legend object of the chart. Ownership stays in chart. | |
263 | */ |
|
272 | */ | |
264 | QLegend* QChart::legend() const |
|
273 | QLegend* QChart::legend() const | |
265 | { |
|
274 | { | |
266 | return d_ptr->m_legend; |
|
275 | return d_ptr->m_legend; | |
267 | } |
|
276 | } | |
268 |
|
277 | |||
269 | QRect QChart::margins() const |
|
278 | QRect QChart::margins() const | |
270 | { |
|
279 | { | |
271 | return d_ptr->m_presenter->margins(); |
|
280 | return d_ptr->m_presenter->margins(); | |
272 | } |
|
281 | } | |
273 |
|
282 | |||
274 |
|
283 | |||
275 | /*! |
|
284 | /*! | |
276 | Resizes and updates the chart area using the \a event data |
|
285 | Resizes and updates the chart area using the \a event data | |
277 | */ |
|
286 | */ | |
278 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) |
|
287 | void QChart::resizeEvent(QGraphicsSceneResizeEvent *event) | |
279 | { |
|
288 | { | |
280 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); |
|
289 | d_ptr->m_rect = QRectF(QPoint(0,0),event->newSize()); | |
281 | QGraphicsWidget::resizeEvent(event); |
|
290 | QGraphicsWidget::resizeEvent(event); | |
282 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); |
|
291 | d_ptr->m_presenter->setGeometry(d_ptr->m_rect); | |
283 | } |
|
292 | } | |
284 |
|
293 | |||
285 | /*! |
|
294 | /*! | |
286 | Sets animation \a options for the chart |
|
295 | Sets animation \a options for the chart | |
287 | */ |
|
296 | */ | |
288 | void QChart::setAnimationOptions(AnimationOptions options) |
|
297 | void QChart::setAnimationOptions(AnimationOptions options) | |
289 | { |
|
298 | { | |
290 | d_ptr->m_presenter->setAnimationOptions(options); |
|
299 | d_ptr->m_presenter->setAnimationOptions(options); | |
291 | } |
|
300 | } | |
292 |
|
301 | |||
293 | /*! |
|
302 | /*! | |
294 | Returns animation options for the chart |
|
303 | Returns animation options for the chart | |
295 | */ |
|
304 | */ | |
296 | QChart::AnimationOptions QChart::animationOptions() const |
|
305 | QChart::AnimationOptions QChart::animationOptions() const | |
297 | { |
|
306 | { | |
298 | return d_ptr->m_presenter->animationOptions(); |
|
307 | return d_ptr->m_presenter->animationOptions(); | |
299 | } |
|
308 | } | |
300 |
|
309 | |||
301 | void QChart::scrollLeft() |
|
310 | void QChart::scrollLeft() | |
302 | { |
|
311 | { | |
303 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
312 | d_ptr->m_presenter->scroll(-d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
304 | } |
|
313 | } | |
305 |
|
314 | |||
306 | void QChart::scrollRight() |
|
315 | void QChart::scrollRight() | |
307 | { |
|
316 | { | |
308 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); |
|
317 | d_ptr->m_presenter->scroll(d_ptr->m_presenter->chartGeometry().width()/(axisX()->ticksCount()-1),0); | |
309 | } |
|
318 | } | |
310 |
|
319 | |||
311 | void QChart::scrollUp() |
|
320 | void QChart::scrollUp() | |
312 | { |
|
321 | { | |
313 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
322 | d_ptr->m_presenter->scroll(0,d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
314 | } |
|
323 | } | |
315 |
|
324 | |||
316 | void QChart::scrollDown() |
|
325 | void QChart::scrollDown() | |
317 | { |
|
326 | { | |
318 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); |
|
327 | d_ptr->m_presenter->scroll(0,-d_ptr->m_presenter->chartGeometry().width()/(axisY()->ticksCount()-1)); | |
319 | } |
|
328 | } | |
320 |
|
329 | |||
321 | void QChart::setBackgroundVisible(bool visible) |
|
330 | void QChart::setBackgroundVisible(bool visible) | |
322 | { |
|
331 | { | |
|
332 | //TODO: refactor me | |||
323 | d_ptr->m_presenter->createChartBackgroundItem(); |
|
333 | d_ptr->m_presenter->createChartBackgroundItem(); | |
324 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); |
|
334 | d_ptr->m_presenter->m_backgroundItem->setVisible(visible); | |
325 | } |
|
335 | } | |
326 |
|
336 | |||
327 | bool QChart::isBackgroundVisible() const |
|
337 | bool QChart::isBackgroundVisible() const | |
328 | { |
|
338 | { | |
|
339 | //TODO: refactor me | |||
329 | if (!d_ptr->m_presenter->m_backgroundItem) return false; |
|
340 | if (!d_ptr->m_presenter->m_backgroundItem) return false; | |
330 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); |
|
341 | return d_ptr->m_presenter->m_backgroundItem->isVisible(); | |
331 | } |
|
342 | } | |
332 |
|
343 | |||
333 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
344 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
334 |
|
345 | |||
335 | QChartPrivate::QChartPrivate(): |
|
346 | QChartPrivate::QChartPrivate(): | |
336 | m_legend(0), |
|
347 | m_legend(0), | |
337 | m_dataset(0), |
|
348 | m_dataset(0), | |
338 | m_presenter(0) |
|
349 | m_presenter(0) | |
339 | { |
|
350 | { | |
340 |
|
351 | |||
341 | } |
|
352 | } | |
342 |
|
353 | |||
343 | QChartPrivate::~QChartPrivate() |
|
354 | QChartPrivate::~QChartPrivate() | |
344 | { |
|
355 | { | |
345 |
|
356 | |||
346 | } |
|
357 | } | |
347 |
|
358 | |||
348 | void QChartPrivate::createConnections() |
|
359 | void QChartPrivate::createConnections() | |
349 | { |
|
360 | { | |
350 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
361 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
351 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*))); |
|
362 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*))); | |
352 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); |
|
363 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QSeries*,Domain*))); | |
353 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); |
|
364 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_presenter,SLOT(handleSeriesRemoved(QSeries*))); | |
354 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); |
|
365 | QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QChartAxis*,Domain*))); | |
355 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); |
|
366 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),m_presenter,SLOT(handleAxisRemoved(QChartAxis*))); | |
356 | } |
|
367 | } | |
357 |
|
368 | |||
358 | #include "moc_qchart.cpp" |
|
369 | #include "moc_qchart.cpp" | |
359 |
|
370 | |||
360 | QTCOMMERCIALCHART_END_NAMESPACE |
|
371 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now