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