##// END OF EJS Templates
Adds ChartConfig class
Michal Klocek -
r719:05b8360d3351
parent child
Show More
@@ -0,0 +1,45
1 #ifndef CHARTCONFIG_H_
2 #define CHARTCONFIG_H_
3
4 #include "qchartglobal.h"
5 #include "qchartversion_p.h"
6
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
10 class ChartConfig {
11
12 private:
13 ChartConfig(){
14 #ifndef QT_NO_DEBUG
15 qDebug()<<"buildTime" << buildTime;
16 qDebug()<<"gitHead" << gitHead;
17 #endif
18 m_instance = this;
19 }
20 public:
21 static ChartConfig* instance(){
22 if(!m_instance){
23 m_instance= new ChartConfig();
24 }
25 return m_instance;
26 }
27
28 QString compilationTime(){
29 return buildTime;
30 }
31
32 QString compilationHead(){
33 return gitHead;
34 }
35
36 private:
37 static ChartConfig* m_instance;
38 };
39
40
41 ChartConfig* ChartConfig::m_instance=0;
42
43 #endif
44
45 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,57 +1,53
1 #include "chartbackground_p.h"
1 #include "chartbackground_p.h"
2 #include "qchartversion_p.h"
2 #include "chartconfig_p.h"
3 #include <QPen>
3 #include <QPen>
4 #include <QBrush>
4 #include <QBrush>
5 #include <QPainter>
5 #include <QPainter>
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 ChartBackground::ChartBackground(QGraphicsItem* parent):QGraphicsRectItem(parent),
9 ChartBackground::ChartBackground(QGraphicsItem* parent):QGraphicsRectItem(parent),
10 m_diameter(15)
10 m_diameter(15)
11 {
11 {
12 #ifndef QT_NO_DEBUG
13 qDebug()<<"buildTime" <<buildTime;
14 qDebug()<<"gitHead" << gitHead;
15 #endif
16 }
12 }
17
13
18 ChartBackground::~ChartBackground()
14 ChartBackground::~ChartBackground()
19 {
15 {
20
16
21 }
17 }
22
18
23 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
19 void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
24 {
20 {
25 Q_UNUSED(option);
21 Q_UNUSED(option);
26 Q_UNUSED(widget);
22 Q_UNUSED(widget);
27 painter->save();
23 painter->save();
28 painter->setPen(pen());
24 painter->setPen(pen());
29 painter->setBrush(brush());
25 painter->setBrush(brush());
30 painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height()));
26 painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height()));
31 #ifndef QT_NO_DEBUG
27 #ifndef QT_NO_DEBUG
32 painter->setPen(Qt::black);
28 painter->setPen(Qt::black);
33 QFont font;
29 QFont font;
34 QString build("build %1");
30 QString build("build %1");
35 font.setPointSize(6);
31 font.setPointSize(6);
36 painter->setFont(font);
32 painter->setFont(font);
37 painter->drawText(rect().bottomLeft(),build.arg(buildTime));
33 painter->drawText(rect().bottomLeft(),build.arg(ChartConfig::instance()->compilationTime()));
38 #endif
34 #endif
39 painter->restore();
35 painter->restore();
40 }
36 }
41
37
42 int ChartBackground::roundness(qreal size) const
38 int ChartBackground::roundness(qreal size) const
43 {
39 {
44 return 100*m_diameter/int(size);
40 return 100*m_diameter/int(size);
45 }
41 }
46
42
47 int ChartBackground::diameter() const
43 int ChartBackground::diameter() const
48 {
44 {
49 return m_diameter;
45 return m_diameter;
50 }
46 }
51
47
52 void ChartBackground::setDimeter(int dimater)
48 void ChartBackground::setDimeter(int dimater)
53 {
49 {
54 m_diameter=dimater;
50 m_diameter=dimater;
55 }
51 }
56
52
57 QTCOMMERCIALCHART_END_NAMESPACE
53 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,158 +1,159
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/legendscrollbutton.cpp \
20 $$PWD/legendscrollbutton.cpp \
21 $$PWD/chartbackground.cpp \
21 $$PWD/chartbackground.cpp \
22 $$PWD/chart.cpp
22 $$PWD/chart.cpp
23 PRIVATE_HEADERS += \
23 PRIVATE_HEADERS += \
24 $$PWD/chartdataset_p.h \
24 $$PWD/chartdataset_p.h \
25 $$PWD/chartitem_p.h \
25 $$PWD/chartitem_p.h \
26 $$PWD/chartpresenter_p.h \
26 $$PWD/chartpresenter_p.h \
27 $$PWD/charttheme_p.h \
27 $$PWD/charttheme_p.h \
28 $$PWD/domain_p.h \
28 $$PWD/domain_p.h \
29 $$PWD/legendmarker_p.h \
29 $$PWD/legendmarker_p.h \
30 $$PWD/legendscrollbutton_p.h \
30 $$PWD/legendscrollbutton_p.h \
31 $$PWD/chartbackground_p.h \
31 $$PWD/chartbackground_p.h \
32 $$PWD/chart_p.h
32 $$PWD/chart_p.h \
33 $$PWD/chartconfig_p.h
33 PUBLIC_HEADERS += \
34 PUBLIC_HEADERS += \
34 $$PWD/qchart.h \
35 $$PWD/qchart.h \
35 $$PWD/qchartglobal.h \
36 $$PWD/qchartglobal.h \
36 $$PWD/qseries.h \
37 $$PWD/qseries.h \
37 $$PWD/qchartview.h \
38 $$PWD/qchartview.h \
38 $$PWD/qlegend.h
39 $$PWD/qlegend.h
39
40
40 include(animations/animations.pri)
41 include(animations/animations.pri)
41 include(axis/axis.pri)
42 include(axis/axis.pri)
42 include(xychart/xychart.pri)
43 include(xychart/xychart.pri)
43 include(linechart/linechart.pri)
44 include(linechart/linechart.pri)
44 include(areachart/areachart.pri)
45 include(areachart/areachart.pri)
45 include(barchart/barchart.pri)
46 include(barchart/barchart.pri)
46 include(piechart/piechart.pri)
47 include(piechart/piechart.pri)
47 include(scatterseries/scatter.pri)
48 include(scatterseries/scatter.pri)
48 include(splinechart/splinechart.pri)
49 include(splinechart/splinechart.pri)
49 include(themes/themes.pri)
50 include(themes/themes.pri)
50
51
51
52
52 HEADERS += $$PUBLIC_HEADERS
53 HEADERS += $$PUBLIC_HEADERS
53 HEADERS += $$PRIVATE_HEADERS
54 HEADERS += $$PRIVATE_HEADERS
54 HEADERS += $$THEMES
55 HEADERS += $$THEMES
55 INCLUDEPATH += linechart \
56 INCLUDEPATH += linechart \
56 barchart \
57 barchart \
57 themes \
58 themes \
58 .
59 .
59 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
60 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
60 MOC_DIR = $$CHART_BUILD_DIR/lib
61 MOC_DIR = $$CHART_BUILD_DIR/lib
61 UI_DIR = $$CHART_BUILD_DIR/lib
62 UI_DIR = $$CHART_BUILD_DIR/lib
62 RCC_DIR = $$CHART_BUILD_DIR/lib
63 RCC_DIR = $$CHART_BUILD_DIR/lib
63 DEFINES += QTCOMMERCIALCHART_LIBRARY
64 DEFINES += QTCOMMERCIALCHART_LIBRARY
64
65
65 #qt public headers
66 #qt public headers
66 #this is very primitive and lame parser , TODO: make perl script insted
67 #this is very primitive and lame parser , TODO: make perl script insted
67 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
68 !exists($$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal)
68 {
69 {
69 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
70 system($$QMAKE_MKDIR $$CHART_BUILD_PUBLIC_HEADER_DIR)
70 win32:{
71 win32:{
71 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
72 command = "echo $${LITERAL_HASH}include \"qchartglobal.h\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
72 }else{
73 }else{
73 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
74 command = "echo \"$${LITERAL_HASH}include \\\"qchartglobal.h\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/QChartGlobal"
74 }
75 }
75 system($$command)
76 system($$command)
76 }
77 }
77
78
78 for(file, PUBLIC_HEADERS) {
79 for(file, PUBLIC_HEADERS) {
79 name = $$split(file,'/')
80 name = $$split(file,'/')
80 name = $$last(name)
81 name = $$last(name)
81 class = "$$cat($$file)"
82 class = "$$cat($$file)"
82 class = $$find(class,class)
83 class = $$find(class,class)
83 !isEmpty(class){
84 !isEmpty(class){
84 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
85 class = $$split(class,QTCOMMERCIALCHART_EXPORT)
85 class = $$member(class,1)
86 class = $$member(class,1)
86 class = $$split(class,' ')
87 class = $$split(class,' ')
87 class = $$replace(class,' ','')
88 class = $$replace(class,' ','')
88 class = $$member(class,0)
89 class = $$member(class,0)
89 win32:{
90 win32:{
90 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
91 command = "echo $${LITERAL_HASH}include \"$$name\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
91 }else{
92 }else{
92 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
93 command = "echo \"$${LITERAL_HASH}include \\\"$$name\\\"\" > $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class"
93 }
94 }
94 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
95 PUBLIC_QT_HEADERS += $$CHART_BUILD_PUBLIC_HEADER_DIR/$$class
95 system($$command)
96 system($$command)
96 }
97 }
97 }
98 }
98
99
99 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
100 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
100 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
101 public_headers.files = $$PUBLIC_HEADERS $$PUBLIC_QT_HEADERS
101
102
102 target.path = $$[QT_INSTALL_LIBS]
103 target.path = $$[QT_INSTALL_LIBS]
103 INSTALLS += target public_headers
104 INSTALLS += target public_headers
104
105
105 install_build_public_headers.name = build_public_headers
106 install_build_public_headers.name = build_public_headers
106 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
107 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
107 install_build_public_headers.input = PUBLIC_HEADERS
108 install_build_public_headers.input = PUBLIC_HEADERS
108 install_build_public_headers.commands = $$QMAKE_COPY \
109 install_build_public_headers.commands = $$QMAKE_COPY \
109 ${QMAKE_FILE_NAME} \
110 ${QMAKE_FILE_NAME} \
110 $$CHART_BUILD_PUBLIC_HEADER_DIR
111 $$CHART_BUILD_PUBLIC_HEADER_DIR
111 install_build_public_headers.CONFIG += target_predeps \
112 install_build_public_headers.CONFIG += target_predeps \
112 no_link
113 no_link
113
114
114 install_build_private_headers.name = buld_private_headers
115 install_build_private_headers.name = buld_private_headers
115 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
116 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
116 install_build_private_headers.input = PRIVATE_HEADERS
117 install_build_private_headers.input = PRIVATE_HEADERS
117 install_build_private_headers.commands = $$QMAKE_COPY \
118 install_build_private_headers.commands = $$QMAKE_COPY \
118 ${QMAKE_FILE_NAME} \
119 ${QMAKE_FILE_NAME} \
119 $$CHART_BUILD_PRIVATE_HEADER_DIR
120 $$CHART_BUILD_PRIVATE_HEADER_DIR
120 install_build_private_headers.CONFIG += target_predeps \
121 install_build_private_headers.CONFIG += target_predeps \
121 no_link
122 no_link
122
123
123 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
124 QMAKE_EXTRA_COMPILERS += install_build_public_headers \
124 install_build_private_headers \
125 install_build_private_headers \
125
126
126
127
127 chartversion.target = qchartversion_p.h
128 chartversion.target = qchartversion_p.h
128 unix:{
129 unix:{
129 chartversion.commands = @echo \
130 chartversion.commands = @echo \
130 "const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" \\; \
131 "const char *buildTime = \\\"`date +'%y%m%d%H%M'`\\\" \\; \
131 const char *gitHead = \\\"`git rev-parse HEAD`\\\" \\; " \
132 const char *gitHead = \\\"`git rev-parse HEAD`\\\" \\; " \
132 > \
133 > \
133 $$chartversion.target;
134 $$chartversion.target;
134 }else{
135 }else{
135 chartversion.commands = @echo \
136 chartversion.commands = @echo \
136 "const char *buildTime = \"%date%_%time%\" ; \
137 "const char *buildTime = \"%date%_%time%\" ; \
137 const char *gitHead = \"unknown\" ; " \
138 const char *gitHead = \"unknown\" ; " \
138 > \
139 > \
139 $$chartversion.target
140 $$chartversion.target
140 }
141 }
141 chartversion.depends = $$HEADERS \
142 chartversion.depends = $$HEADERS \
142 $$SOURCES
143 $$SOURCES
143 PRE_TARGETDEPS += qchartversion_p.h
144 PRE_TARGETDEPS += qchartversion_p.h
144 QMAKE_CLEAN += qchartversion_p.h
145 QMAKE_CLEAN += qchartversion_p.h
145 QMAKE_EXTRA_TARGETS += chartversion
146 QMAKE_EXTRA_TARGETS += chartversion
146 unix:QMAKE_DISTCLEAN += -r \
147 unix:QMAKE_DISTCLEAN += -r \
147 $$CHART_BUILD_HEADER_DIR \
148 $$CHART_BUILD_HEADER_DIR \
148 $$CHART_BUILD_LIB_DIR
149 $$CHART_BUILD_LIB_DIR
149 win32:QMAKE_DISTCLEAN += /Q \
150 win32:QMAKE_DISTCLEAN += /Q \
150 $$CHART_BUILD_HEADER_DIR \
151 $$CHART_BUILD_HEADER_DIR \
151 $$CHART_BUILD_LIB_DIR
152 $$CHART_BUILD_LIB_DIR
152
153
153 # treat warnings as errors
154 # treat warnings as errors
154 win32-msvc*: {
155 win32-msvc*: {
155 QMAKE_CXXFLAGS += /WX
156 QMAKE_CXXFLAGS += /WX
156 } else {
157 } else {
157 QMAKE_CXXFLAGS += -Werror
158 QMAKE_CXXFLAGS += -Werror
158 }
159 }
General Comments 0
You need to be logged in to leave comments. Login now