##// END OF EJS Templates
Add build stamp and git head support for debug
Michal Klocek -
r715:f8597835a464
parent child
Show More
@@ -1,43 +1,57
1 #include "chartbackground_p.h"
1 #include "chartbackground_p.h"
2 #include "qchartversion_p.h"
2 #include <QPen>
3 #include <QPen>
3 #include <QBrush>
4 #include <QBrush>
4 #include <QPainter>
5 #include <QPainter>
5
6
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
8
8 ChartBackground::ChartBackground(QGraphicsItem* parent):QGraphicsRectItem(parent),
9 ChartBackground::ChartBackground(QGraphicsItem* parent):QGraphicsRectItem(parent),
9 m_diameter(15)
10 m_diameter(15)
10 {
11 {
11
12 #ifndef QT_NO_DEBUG
13 qDebug()<<"buildTime" <<buildTime;
14 qDebug()<<"gitHead" << gitHead;
15 #endif
12 }
16 }
13
17
14 ChartBackground::~ChartBackground()
18 ChartBackground::~ChartBackground()
15 {
19 {
16
20
17 }
21 }
18
22
19 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
23 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
20 {
24 {
21 Q_UNUSED(option);
25 Q_UNUSED(option);
22 Q_UNUSED(widget);
26 Q_UNUSED(widget);
27 painter->save();
23 painter->setPen(pen());
28 painter->setPen(pen());
24 painter->setBrush(brush());
29 painter->setBrush(brush());
25 painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height()));
30 painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height()));
31 #ifndef QT_NO_DEBUG
32 painter->setPen(Qt::black);
33 QFont font;
34 QString build("build %1");
35 font.setPointSize(6);
36 painter->setFont(font);
37 painter->drawText(rect().bottomLeft(),build.arg(buildTime));
38 #endif
39 painter->restore();
26 }
40 }
27
41
28 int ChartBackground::roundness(qreal size) const
42 int ChartBackground::roundness(qreal size) const
29 {
43 {
30 return 100*m_diameter/int(size);
44 return 100*m_diameter/int(size);
31 }
45 }
32
46
33 int ChartBackground::diameter() const
47 int ChartBackground::diameter() const
34 {
48 {
35 return m_diameter;
49 return m_diameter;
36 }
50 }
37
51
38 void ChartBackground::setDimeter(int dimater)
52 void ChartBackground::setDimeter(int dimater)
39 {
53 {
40 m_diameter=dimater;
54 m_diameter=dimater;
41 }
55 }
42
56
43 QTCOMMERCIALCHART_END_NAMESPACE
57 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,392 +1,391
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 #include "qlegend.h"
3 #include "qlegend.h"
4 #include "chartpresenter_p.h"
4 #include "chartpresenter_p.h"
5 #include "chartdataset_p.h"
5 #include "chartdataset_p.h"
6 #include "chartbackground_p.h"
6 #include "chartbackground_p.h"
7 #include <QGraphicsScene>
7 #include <QGraphicsScene>
8 #include <QGraphicsSceneResizeEvent>
8 #include <QGraphicsSceneResizeEvent>
9 #include <QDebug>
10
9
11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
12
11
13 /*!
12 /*!
14 \enum QChart::ChartTheme
13 \enum QChart::ChartTheme
15
14
16 This enum describes the theme used by the chart.
15 This enum describes the theme used by the chart.
17
16
18 \value ChartThemeDefault Follows the GUI style of the Operating System
17 \value ChartThemeDefault Follows the GUI style of the Operating System
19 \value ChartThemeLight
18 \value ChartThemeLight
20 \value ChartThemeBlueCerulean
19 \value ChartThemeBlueCerulean
21 \value ChartThemeDark
20 \value ChartThemeDark
22 \value ChartThemeBrownSand
21 \value ChartThemeBrownSand
23 \value ChartThemeBlueNcs
22 \value ChartThemeBlueNcs
24 \value ChartThemeIcy
23 \value ChartThemeIcy
25 \value ChartThemeScientific
24 \value ChartThemeScientific
26 \value ChartThemeCount Not really a theme; the total count of themes.
25 \value ChartThemeCount Not really a theme; the total count of themes.
27 */
26 */
28
27
29 /*!
28 /*!
30 \enum QChart::AnimationOption
29 \enum QChart::AnimationOption
31
30
32 For enabling/disabling animations. Defaults to NoAnimation.
31 For enabling/disabling animations. Defaults to NoAnimation.
33
32
34 \value NoAnimation
33 \value NoAnimation
35 \value GridAxisAnimations
34 \value GridAxisAnimations
36 \value SeriesAnimations
35 \value SeriesAnimations
37 \value AllAnimations
36 \value AllAnimations
38 */
37 */
39
38
40 /*!
39 /*!
41 \class QChart
40 \class QChart
42 \brief QtCommercial chart API.
41 \brief QtCommercial chart API.
43
42
44 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
43 QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical
45 representation of different types of QChartSeries and other chart related objects like
44 representation of different types of QChartSeries and other chart related objects like
46 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
45 QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the
47 convenience class QChartView instead of QChart.
46 convenience class QChartView instead of QChart.
48 \sa QChartView
47 \sa QChartView
49 */
48 */
50
49
51 /*!
50 /*!
52 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
51 Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor.
53 */
52 */
54 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
53 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
55 m_backgroundItem(0),
54 m_backgroundItem(0),
56 m_titleItem(0),
55 m_titleItem(0),
57 m_legend(new QLegend(this)),
56 m_legend(new QLegend(this)),
58 m_dataset(new ChartDataSet(this)),
57 m_dataset(new ChartDataSet(this)),
59 m_presenter(new ChartPresenter(this,m_dataset)),
58 m_presenter(new ChartPresenter(this,m_dataset)),
60 m_padding(50),
59 m_padding(50),
61 m_backgroundPadding(10)
60 m_backgroundPadding(10)
62 {
61 {
63 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
62 connect(m_dataset,SIGNAL(seriesAdded(QSeries*,Domain*)),m_legend,SLOT(handleSeriesAdded(QSeries*,Domain*)));
64 connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
63 connect(m_dataset,SIGNAL(seriesRemoved(QSeries*)),m_legend,SLOT(handleSeriesRemoved(QSeries*)));
65 }
64 }
66
65
67 /*!
66 /*!
68 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
67 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
69 */
68 */
70 QChart::~QChart()
69 QChart::~QChart()
71 {
70 {
72 //delete first presenter , since this is a root of all the graphical items
71 //delete first presenter , since this is a root of all the graphical items
73 delete m_presenter;
72 delete m_presenter;
74 m_presenter=0;
73 m_presenter=0;
75 }
74 }
76
75
77 /*!
76 /*!
78 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
77 Adds the \a series and optional \a axisY onto the chart and takes the ownership of the objects.
79 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
78 If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and
80 the y axis).
79 the y axis).
81 */
80 */
82 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
81 void QChart::addSeries(QSeries* series, QChartAxis* axisY)
83 {
82 {
84 m_dataset->addSeries(series, axisY);
83 m_dataset->addSeries(series, axisY);
85 }
84 }
86
85
87 /*!
86 /*!
88 Removes the \a series specified in a perameter from the QChartView.
87 Removes the \a series specified in a perameter from the QChartView.
89 It releses its ownership of the specified QChartSeries object.
88 It releses its ownership of the specified QChartSeries object.
90 It does not delete the pointed QChartSeries data object
89 It does not delete the pointed QChartSeries data object
91 \sa addSeries(), removeAllSeries()
90 \sa addSeries(), removeAllSeries()
92 */
91 */
93 void QChart::removeSeries(QSeries* series)
92 void QChart::removeSeries(QSeries* series)
94 {
93 {
95 m_dataset->removeSeries(series);
94 m_dataset->removeSeries(series);
96 }
95 }
97
96
98 /*!
97 /*!
99 Removes all the QChartSeries that have been added to the QChartView
98 Removes all the QChartSeries that have been added to the QChartView
100 It also deletes the pointed QChartSeries data objects
99 It also deletes the pointed QChartSeries data objects
101 \sa addSeries(), removeSeries()
100 \sa addSeries(), removeSeries()
102 */
101 */
103 void QChart::removeAllSeries()
102 void QChart::removeAllSeries()
104 {
103 {
105 m_dataset->removeAllSeries();
104 m_dataset->removeAllSeries();
106 }
105 }
107
106
108 /*!
107 /*!
109 Sets the \a brush that is used for painting the background of the chart area.
108 Sets the \a brush that is used for painting the background of the chart area.
110 */
109 */
111 void QChart::setBackgroundBrush(const QBrush& brush)
110 void QChart::setBackgroundBrush(const QBrush& brush)
112 {
111 {
113 createChartBackgroundItem();
112 createChartBackgroundItem();
114 m_backgroundItem->setBrush(brush);
113 m_backgroundItem->setBrush(brush);
115 m_backgroundItem->update();
114 m_backgroundItem->update();
116 }
115 }
117
116
118 QBrush QChart::backgroundBrush() const
117 QBrush QChart::backgroundBrush() const
119 {
118 {
120 if(!m_backgroundItem) return QBrush();
119 if(!m_backgroundItem) return QBrush();
121 return m_backgroundItem->brush();
120 return m_backgroundItem->brush();
122 }
121 }
123
122
124 /*!
123 /*!
125 Sets the \a pen that is used for painting the background of the chart area.
124 Sets the \a pen that is used for painting the background of the chart area.
126 */
125 */
127 void QChart::setBackgroundPen(const QPen& pen)
126 void QChart::setBackgroundPen(const QPen& pen)
128 {
127 {
129 createChartBackgroundItem();
128 createChartBackgroundItem();
130 m_backgroundItem->setPen(pen);
129 m_backgroundItem->setPen(pen);
131 m_backgroundItem->update();
130 m_backgroundItem->update();
132 }
131 }
133
132
134 QPen QChart::backgroundPen() const
133 QPen QChart::backgroundPen() const
135 {
134 {
136 if(!m_backgroundItem) return QPen();
135 if(!m_backgroundItem) return QPen();
137 return m_backgroundItem->pen();
136 return m_backgroundItem->pen();
138 }
137 }
139
138
140 /*!
139 /*!
141 Sets the chart \a title. The description text that is drawn above the chart.
140 Sets the chart \a title. The description text that is drawn above the chart.
142 */
141 */
143 void QChart::setTitle(const QString& title)
142 void QChart::setTitle(const QString& title)
144 {
143 {
145 createChartTitleItem();
144 createChartTitleItem();
146 m_titleItem->setText(title);
145 m_titleItem->setText(title);
147 updateLayout();
146 updateLayout();
148 }
147 }
149
148
150 /*!
149 /*!
151 Returns the chart title. The description text that is drawn above the chart.
150 Returns the chart title. The description text that is drawn above the chart.
152 */
151 */
153 QString QChart::title() const
152 QString QChart::title() const
154 {
153 {
155 if(m_titleItem)
154 if(m_titleItem)
156 return m_titleItem->text();
155 return m_titleItem->text();
157 else
156 else
158 return QString();
157 return QString();
159 }
158 }
160
159
161 /*!
160 /*!
162 Sets the \a font that is used for rendering the description text that is rendered above the chart.
161 Sets the \a font that is used for rendering the description text that is rendered above the chart.
163 */
162 */
164 void QChart::setTitleFont(const QFont& font)
163 void QChart::setTitleFont(const QFont& font)
165 {
164 {
166 createChartTitleItem();
165 createChartTitleItem();
167 m_titleItem->setFont(font);
166 m_titleItem->setFont(font);
168 updateLayout();
167 updateLayout();
169 }
168 }
170
169
171 /*!
170 /*!
172 Sets the \a brush used for rendering the title text.
171 Sets the \a brush used for rendering the title text.
173 */
172 */
174 void QChart::setTitleBrush(const QBrush &brush)
173 void QChart::setTitleBrush(const QBrush &brush)
175 {
174 {
176 createChartTitleItem();
175 createChartTitleItem();
177 m_titleItem->setBrush(brush);
176 m_titleItem->setBrush(brush);
178 updateLayout();
177 updateLayout();
179 }
178 }
180
179
181 /*!
180 /*!
182 Returns the brush used for rendering the title text.
181 Returns the brush used for rendering the title text.
183 */
182 */
184 QBrush QChart::titleBrush() const
183 QBrush QChart::titleBrush() const
185 {
184 {
186 if(!m_titleItem) return QBrush();
185 if(!m_titleItem) return QBrush();
187 return m_titleItem->brush();
186 return m_titleItem->brush();
188 }
187 }
189
188
190 void QChart::createChartBackgroundItem()
189 void QChart::createChartBackgroundItem()
191 {
190 {
192 if(!m_backgroundItem) {
191 if(!m_backgroundItem) {
193 m_backgroundItem = new ChartBackground(this);
192 m_backgroundItem = new ChartBackground(this);
194 m_backgroundItem->setPen(Qt::NoPen);
193 m_backgroundItem->setPen(Qt::NoPen);
195 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
194 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
196 }
195 }
197 }
196 }
198
197
199 void QChart::createChartTitleItem()
198 void QChart::createChartTitleItem()
200 {
199 {
201 if(!m_titleItem) {
200 if(!m_titleItem) {
202 m_titleItem = new QGraphicsSimpleTextItem(this);
201 m_titleItem = new QGraphicsSimpleTextItem(this);
203 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
202 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
204 }
203 }
205 }
204 }
206
205
207 /*!
206 /*!
208 Sets the \a theme used by the chart for rendering the graphical representation of the data
207 Sets the \a theme used by the chart for rendering the graphical representation of the data
209 \sa ChartTheme, chartTheme()
208 \sa ChartTheme, chartTheme()
210 */
209 */
211 void QChart::setChartTheme(QChart::ChartTheme theme)
210 void QChart::setChartTheme(QChart::ChartTheme theme)
212 {
211 {
213 m_presenter->setChartTheme(theme);
212 m_presenter->setChartTheme(theme);
214 }
213 }
215
214
216 /*!
215 /*!
217 Returns the theme enum used by the chart.
216 Returns the theme enum used by the chart.
218 \sa ChartTheme, setChartTheme()
217 \sa ChartTheme, setChartTheme()
219 */
218 */
220 QChart::ChartTheme QChart::chartTheme() const
219 QChart::ChartTheme QChart::chartTheme() const
221 {
220 {
222 return m_presenter->chartTheme();
221 return m_presenter->chartTheme();
223 }
222 }
224
223
225 /*!
224 /*!
226 Zooms in the view by a factor of 2
225 Zooms in the view by a factor of 2
227 */
226 */
228 void QChart::zoomIn()
227 void QChart::zoomIn()
229 {
228 {
230 m_presenter->zoomIn();
229 m_presenter->zoomIn();
231 }
230 }
232
231
233 /*!
232 /*!
234 Zooms in the view to a maximum level at which \a rect is still fully visible.
233 Zooms in the view to a maximum level at which \a rect is still fully visible.
235 */
234 */
236 void QChart::zoomIn(const QRectF& rect)
235 void QChart::zoomIn(const QRectF& rect)
237 {
236 {
238
237
239 if(!rect.isValid()) return;
238 if(!rect.isValid()) return;
240 m_presenter->zoomIn(rect);
239 m_presenter->zoomIn(rect);
241 }
240 }
242
241
243 /*!
242 /*!
244 Restores the view zoom level to the previous one.
243 Restores the view zoom level to the previous one.
245 */
244 */
246 void QChart::zoomOut()
245 void QChart::zoomOut()
247 {
246 {
248 m_presenter->zoomOut();
247 m_presenter->zoomOut();
249 }
248 }
250
249
251 /*!
250 /*!
252 Returns the pointer to the x axis object of the chart
251 Returns the pointer to the x axis object of the chart
253 */
252 */
254 QChartAxis* QChart::axisX() const
253 QChartAxis* QChart::axisX() const
255 {
254 {
256 return m_dataset->axisX();
255 return m_dataset->axisX();
257 }
256 }
258
257
259 /*!
258 /*!
260 Returns the pointer to the y axis object of the chart
259 Returns the pointer to the y axis object of the chart
261 */
260 */
262 QChartAxis* QChart::axisY() const
261 QChartAxis* QChart::axisY() const
263 {
262 {
264 return m_dataset->axisY();
263 return m_dataset->axisY();
265 }
264 }
266
265
267 /*!
266 /*!
268 Returns the legend object of the chart. Ownership stays in chart.
267 Returns the legend object of the chart. Ownership stays in chart.
269 */
268 */
270 QLegend* QChart::legend() const
269 QLegend* QChart::legend() const
271 {
270 {
272 return m_legend;
271 return m_legend;
273 }
272 }
274
273
275 /*!
274 /*!
276 Resizes and updates the chart area using the \a event data
275 Resizes and updates the chart area using the \a event data
277 */
276 */
278 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
277 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
279 {
278 {
280
279
281 m_rect = QRectF(QPoint(0,0),event->newSize());
280 m_rect = QRectF(QPoint(0,0),event->newSize());
282 updateLayout();
281 updateLayout();
283 QGraphicsWidget::resizeEvent(event);
282 QGraphicsWidget::resizeEvent(event);
284 update();
283 update();
285 }
284 }
286
285
287 /*!
286 /*!
288 Sets animation \a options for the chart
287 Sets animation \a options for the chart
289 */
288 */
290 void QChart::setAnimationOptions(AnimationOptions options)
289 void QChart::setAnimationOptions(AnimationOptions options)
291 {
290 {
292 m_presenter->setAnimationOptions(options);
291 m_presenter->setAnimationOptions(options);
293 }
292 }
294
293
295 /*!
294 /*!
296 Returns animation options for the chart
295 Returns animation options for the chart
297 */
296 */
298 QChart::AnimationOptions QChart::animationOptions() const
297 QChart::AnimationOptions QChart::animationOptions() const
299 {
298 {
300 return m_presenter->animationOptions();
299 return m_presenter->animationOptions();
301 }
300 }
302
301
303 void QChart::scrollLeft()
302 void QChart::scrollLeft()
304 {
303 {
305 m_presenter->scroll(-m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
304 m_presenter->scroll(-m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
306 }
305 }
307
306
308 void QChart::scrollRight()
307 void QChart::scrollRight()
309 {
308 {
310 m_presenter->scroll(m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
309 m_presenter->scroll(m_presenter->geometry().width()/(axisX()->ticksCount()-1),0);
311 }
310 }
312 void QChart::scrollUp()
311 void QChart::scrollUp()
313 {
312 {
314 m_presenter->scroll(0,m_presenter->geometry().width()/(axisY()->ticksCount()-1));
313 m_presenter->scroll(0,m_presenter->geometry().width()/(axisY()->ticksCount()-1));
315 }
314 }
316 void QChart::scrollDown()
315 void QChart::scrollDown()
317 {
316 {
318 m_presenter->scroll(0,-m_presenter->geometry().width()/(axisY()->ticksCount()-1));
317 m_presenter->scroll(0,-m_presenter->geometry().width()/(axisY()->ticksCount()-1));
319 }
318 }
320
319
321 void QChart::updateLayout()
320 void QChart::updateLayout()
322 {
321 {
323 if(!m_rect.isValid()) return;
322 if(!m_rect.isValid()) return;
324
323
325 QRectF rect = m_rect.adjusted(m_padding,m_padding, -m_padding, -m_padding);
324 QRectF rect = m_rect.adjusted(m_padding,m_padding, -m_padding, -m_padding);
326
325
327 // recalculate title position
326 // recalculate title position
328 if (m_titleItem) {
327 if (m_titleItem) {
329 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
328 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
330 m_titleItem->setPos(center.x(),m_rect.top()/2 + m_padding/2);
329 m_titleItem->setPos(center.x(),m_rect.top()/2 + m_padding/2);
331 }
330 }
332
331
333 //recalculate background gradient
332 //recalculate background gradient
334 if (m_backgroundItem) {
333 if (m_backgroundItem) {
335 m_backgroundItem->setRect(m_rect.adjusted(m_backgroundPadding,m_backgroundPadding, -m_backgroundPadding, -m_backgroundPadding));
334 m_backgroundItem->setRect(m_rect.adjusted(m_backgroundPadding,m_backgroundPadding, -m_backgroundPadding, -m_backgroundPadding));
336 }
335 }
337
336
338 // recalculate legend position
337 // recalculate legend position
339 if (m_legend) {
338 if (m_legend) {
340 if (m_legend->parentObject() == this) {
339 if (m_legend->parentObject() == this) {
341 m_legend->setMaximumSize(rect.size());
340 m_legend->setMaximumSize(rect.size());
342 m_legend->setPos(rect.topLeft());
341 m_legend->setPos(rect.topLeft());
343 }
342 }
344 }
343 }
345 }
344 }
346
345
347
346
348 int QChart::padding() const
347 int QChart::padding() const
349 {
348 {
350 return m_padding;
349 return m_padding;
351 }
350 }
352
351
353 void QChart::setPadding(int padding)
352 void QChart::setPadding(int padding)
354 {
353 {
355 if(m_padding==padding){
354 if(m_padding==padding){
356 m_padding = padding;
355 m_padding = padding;
357 m_presenter->handleGeometryChanged();
356 m_presenter->handleGeometryChanged();
358 updateLayout();
357 updateLayout();
359 }
358 }
360 }
359 }
361
360
362 void QChart::setBackgroundPadding(int padding)
361 void QChart::setBackgroundPadding(int padding)
363 {
362 {
364 if(m_backgroundPadding!=padding){
363 if(m_backgroundPadding!=padding){
365 m_backgroundPadding = padding;
364 m_backgroundPadding = padding;
366 updateLayout();
365 updateLayout();
367 }
366 }
368 }
367 }
369
368
370 void QChart::setBackgroundDiameter(int diameter)
369 void QChart::setBackgroundDiameter(int diameter)
371 {
370 {
372 createChartBackgroundItem();
371 createChartBackgroundItem();
373 m_backgroundItem->setDimeter(diameter);
372 m_backgroundItem->setDimeter(diameter);
374 m_backgroundItem->update();
373 m_backgroundItem->update();
375 }
374 }
376
375
377 void QChart::setBackgroundVisible(bool visible)
376 void QChart::setBackgroundVisible(bool visible)
378 {
377 {
379 createChartBackgroundItem();
378 createChartBackgroundItem();
380 m_backgroundItem->setVisible(visible);
379 m_backgroundItem->setVisible(visible);
381 }
380 }
382
381
383 bool QChart::isBackgroundVisible() const
382 bool QChart::isBackgroundVisible() const
384 {
383 {
385 if(!m_backgroundItem) return false;
384 if(!m_backgroundItem) return false;
386 return m_backgroundItem->isVisible();
385 return m_backgroundItem->isVisible();
387 }
386 }
388
387
389
388
390 #include "moc_qchart.cpp"
389 #include "moc_qchart.cpp"
391
390
392 QTCOMMERCIALCHART_END_NAMESPACE
391 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,146 +1,156
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 win32-msvc*: LIBS += User32.lib
7 win32-msvc*: LIBS += User32.lib
8 CONFIG += debug_and_release
8 CONFIG += debug_and_release
9 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
10 SOURCES += \
10 SOURCES += \
11 $$PWD/chartdataset.cpp \
11 $$PWD/chartdataset.cpp \
12 $$PWD/chartpresenter.cpp \
12 $$PWD/chartpresenter.cpp \
13 $$PWD/charttheme.cpp \
13 $$PWD/charttheme.cpp \
14 $$PWD/domain.cpp \
14 $$PWD/domain.cpp \
15 $$PWD/qchart.cpp \
15 $$PWD/qchart.cpp \
16 $$PWD/qchartview.cpp \
16 $$PWD/qchartview.cpp \
17 $$PWD/qseries.cpp \
17 $$PWD/qseries.cpp \
18 $$PWD/qlegend.cpp \
18 $$PWD/qlegend.cpp \
19 $$PWD/legendmarker.cpp \
19 $$PWD/legendmarker.cpp \
20 $$PWD/chartbackground.cpp \
20 $$PWD/chartbackground.cpp \
21 $$PWD/chart.cpp
21 $$PWD/chart.cpp
22 PRIVATE_HEADERS += \
22 PRIVATE_HEADERS += \
23 $$PWD/chartdataset_p.h \
23 $$PWD/chartdataset_p.h \
24 $$PWD/chartitem_p.h \
24 $$PWD/chartitem_p.h \
25 $$PWD/chartpresenter_p.h \
25 $$PWD/chartpresenter_p.h \
26 $$PWD/charttheme_p.h \
26 $$PWD/charttheme_p.h \
27 $$PWD/domain_p.h \
27 $$PWD/domain_p.h \
28 $$PWD/legendmarker_p.h \
28 $$PWD/legendmarker_p.h \
29 $$PWD/chartbackground_p.h \
29 $$PWD/chartbackground_p.h \
30 $$PWD/chart_p.h
30 $$PWD/chart_p.h
31 PUBLIC_HEADERS += \
31 PUBLIC_HEADERS += \
32 $$PWD/qchart.h \
32 $$PWD/qchart.h \
33 $$PWD/qchartglobal.h \
33 $$PWD/qchartglobal.h \
34 $$PWD/qseries.h \
34 $$PWD/qseries.h \
35 $$PWD/qchartview.h \
35 $$PWD/qchartview.h \
36 $$PWD/qlegend.h
36 $$PWD/qlegend.h
37
37
38 include(animations/animations.pri)
38 include(animations/animations.pri)
39 include(axis/axis.pri)
39 include(axis/axis.pri)
40 include(xychart/xychart.pri)
40 include(xychart/xychart.pri)
41 include(linechart/linechart.pri)
41 include(linechart/linechart.pri)
42 include(areachart/areachart.pri)
42 include(areachart/areachart.pri)
43 include(barchart/barchart.pri)
43 include(barchart/barchart.pri)
44 include(piechart/piechart.pri)
44 include(piechart/piechart.pri)
45 include(scatterseries/scatter.pri)
45 include(scatterseries/scatter.pri)
46 include(splinechart/splinechart.pri)
46 include(splinechart/splinechart.pri)
47 include(themes/themes.pri)
47 include(themes/themes.pri)
48
48
49
49
50 HEADERS += $$PUBLIC_HEADERS
50 HEADERS += $$PUBLIC_HEADERS
51 HEADERS += $$PRIVATE_HEADERS
51 HEADERS += $$PRIVATE_HEADERS
52 HEADERS += $$THEMES
52 HEADERS += $$THEMES
53 INCLUDEPATH += linechart \
53 INCLUDEPATH += linechart \
54 barchart \
54 barchart \
55 themes \
55 themes \
56 .
56 .
57 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
57 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
58 MOC_DIR = $$CHART_BUILD_DIR/lib
58 MOC_DIR = $$CHART_BUILD_DIR/lib
59 UI_DIR = $$CHART_BUILD_DIR/lib
59 UI_DIR = $$CHART_BUILD_DIR/lib
60 RCC_DIR = $$CHART_BUILD_DIR/lib
60 RCC_DIR = $$CHART_BUILD_DIR/lib
61 DEFINES += QTCOMMERCIALCHART_LIBRARY
61 DEFINES += QTCOMMERCIALCHART_LIBRARY
62
62
63 #qt public headers
63 #qt public headers
64 #this is very primitive and lame parser , TODO: make perl script insted
64 #this is very primitive and lame parser , TODO: make perl script insted
65 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
65 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
66 {
66 {
67 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
67 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
68 win32:{
68 win32:{
69 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
69 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
70 }else{
70 }else{
71 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
71 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
72 }
72 }
73 system($$command)
73 system($$command)
74 }
74 }
75
75
76 for(file, PUBLIC_HEADERS) {
76 for(file, PUBLIC_HEADERS) {
77 name = $$split(file,'/')
77 name = $$split(file,'/')
78 name = $$last(name)
78 name = $$last(name)
79 class = "$$cat($$file)"
79 class = "$$cat($$file)"
80 class = $$find(class,class)
80 class = $$find(class,class)
81 !isEmpty(class){
81 !isEmpty(class){
82 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
82 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
83 class = $$member(class,1)
83 class = $$member(class,1)
84 class = $$split(class,' ')
84 class = $$split(class,' ')
85 class = $$replace(class,' ','')
85 class = $$replace(class,' ','')
86 class = $$member(class,0)
86 class = $$member(class,0)
87 win32:{
87 win32:{
88 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
88 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
89 }else{
89 }else{
90 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
90 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
91 }
91 }
92 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
92 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
93 system($$command)
93 system($$command)
94 }
94 }
95 }
95 }
96
96
97 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
97 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
98 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
98 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
99
99
100 target.path = $$[QT_INSTALL_LIBS]
100 target.path = $$[QT_INSTALL_LIBS]
101 INSTALLS += target public_headers
101 INSTALLS += target public_headers
102
102
103 install_build_public_headers.name = build_public_headers
103 install_build_public_headers.name = build_public_headers
104 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
104 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
105 install_build_public_headers.input = PUBLIC_HEADERS
105 install_build_public_headers.input = PUBLIC_HEADERS
106 install_build_public_headers.commands = $$QMAKE_COPY \
106 install_build_public_headers.commands = $$QMAKE_COPY \
107 ${QMAKE_FILE_NAME} \
107 ${QMAKE_FILE_NAME} \
108 $$CHART_BUILD_PUBLIC_HEADER_DIR
108 $$CHART_BUILD_PUBLIC_HEADER_DIR
109 install_build_public_headers.CONFIG += target_predeps \
109 install_build_public_headers.CONFIG += target_predeps \
110 no_link
110 no_link
111
111
112 install_build_private_headers.name = buld_private_headers
112 install_build_private_headers.name = buld_private_headers
113 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
113 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
114 install_build_private_headers.input = PRIVATE_HEADERS
114 install_build_private_headers.input = PRIVATE_HEADERS
115 install_build_private_headers.commands = $$QMAKE_COPY \
115 install_build_private_headers.commands = $$QMAKE_COPY \
116 ${QMAKE_FILE_NAME} \
116 ${QMAKE_FILE_NAME} \
117 $$CHART_BUILD_PRIVATE_HEADER_DIR
117 $$CHART_BUILD_PRIVATE_HEADER_DIR
118 install_build_private_headers.CONFIG += target_predeps \
118 install_build_private_headers.CONFIG += target_predeps \
119 no_link
119 no_link
120
120
121 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
121 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
122 install_build_private_headers \
122 install_build_private_headers \
123
123
124
124 chartversion.target = qchartversion_p.h
125 chartversion.target = qchartversion_p.h
125 chartversion.commands = @echo \
126 unix:{
126 "build_time" \
127 chartversion.commands = @echo \
127 > \
128 "const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" \\; \
128 $$chartversion.target;
129 const char *gitHead = \\\"`git rev-parse HEAD`\\\" \\; " \
130 > \
131 $$chartversion.target;
132 }else{
133 chartversion.commands = @echo \
134 "const char *buildTime = \"%date%_%time%\" ; \
135 const char *gitHead = \"unknown\" ; " \
136 > \
137 $$chartversion.target
138 }
129 chartversion.depends = $$HEADERS \
139 chartversion.depends = $$HEADERS \
130 $$SOURCES
140 $$SOURCES
131 PRE_TARGETDEPS += qchartversion_p.h
141 PRE_TARGETDEPS += qchartversion_p.h
132 QMAKE_CLEAN += qchartversion_p.h
142 QMAKE_CLEAN += qchartversion_p.h
133 QMAKE_EXTRA_TARGETS += chartversion
143 QMAKE_EXTRA_TARGETS += chartversion
134 unix:QMAKE_DISTCLEAN += -r \
144 unix:QMAKE_DISTCLEAN += -r \
135 $$CHART_BUILD_HEADER_DIR \
145 $$CHART_BUILD_HEADER_DIR \
136 $$CHART_BUILD_LIB_DIR
146 $$CHART_BUILD_LIB_DIR
137 win32:QMAKE_DISTCLEAN += /Q \
147 win32:QMAKE_DISTCLEAN += /Q \
138 $$CHART_BUILD_HEADER_DIR \
148 $$CHART_BUILD_HEADER_DIR \
139 $$CHART_BUILD_LIB_DIR
149 $$CHART_BUILD_LIB_DIR
140
150
141 # treat warnings as errors
151 # treat warnings as errors
142 win32-msvc*: {
152 win32-msvc*: {
143 QMAKE_CXXFLAGS += /WX
153 QMAKE_CXXFLAGS += /WX
144 } else {
154 } else {
145 QMAKE_CXXFLAGS += -Werror
155 QMAKE_CXXFLAGS += -Werror
146 }
156 }
General Comments 0
You need to be logged in to leave comments. Login now