@@ -1,187 +1,187 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | // W A R N I N G |
|
19 | // W A R N I N G | |
20 | // ------------- |
|
20 | // ------------- | |
21 | // |
|
21 | // | |
22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
22 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an | |
23 | // implementation detail. This header file may change from version to |
|
23 | // implementation detail. This header file may change from version to | |
24 | // version without notice, or even be removed. |
|
24 | // version without notice, or even be removed. | |
25 | // |
|
25 | // | |
26 | // We mean it. |
|
26 | // We mean it. | |
27 |
|
27 | |||
28 | #ifndef CHARTTHEMESYSTEM_P_H |
|
28 | #ifndef CHARTTHEMESYSTEM_P_H | |
29 | #define CHARTTHEMESYSTEM_P_H |
|
29 | #define CHARTTHEMESYSTEM_P_H | |
30 |
|
30 | |||
31 | #include <private/charttheme_p.h> |
|
31 | #include <private/charttheme_p.h> | |
32 | #ifdef Q_OS_WIN |
|
32 | #ifdef Q_OS_WIN | |
33 | #include <windows.h> |
|
33 | #include <windows.h> | |
34 | #include <stdio.h> |
|
34 | #include <stdio.h> | |
35 | #endif |
|
35 | #endif | |
36 |
|
36 | |||
37 | QT_CHARTS_BEGIN_NAMESPACE |
|
37 | QT_CHARTS_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class ChartThemeSystem: public ChartTheme |
|
39 | class ChartThemeSystem: public ChartTheme | |
40 | { |
|
40 | { | |
41 | public: |
|
41 | public: | |
42 | // System theme not used at the moment (the user is not able to select this theme) |
|
42 | // System theme not used at the moment (the user is not able to select this theme) | |
43 | ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/) |
|
43 | ChartThemeSystem() : ChartTheme(QChart::ChartThemeLight /*QChart::ChartThemeSystem*/) | |
44 | { |
|
44 | { | |
45 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) |
|
45 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) | |
46 | // We could also use theme specific window frame color as a series base color (it would give more |
|
46 | // We could also use theme specific window frame color as a series base color (it would give more | |
47 | // variation to the base colors in addition to the blue and black used now) |
|
47 | // variation to the base colors in addition to the blue and black used now) | |
48 |
|
48 | |||
49 | // First series base color from COLOR_HIGHLIGHT |
|
49 | // First series base color from COLOR_HIGHLIGHT | |
50 | DWORD colorHighlight; |
|
50 | DWORD colorHighlight; | |
51 | colorHighlight = GetSysColor(COLOR_HIGHLIGHT); |
|
51 | colorHighlight = GetSysColor(COLOR_HIGHLIGHT); | |
52 | m_seriesColors.append(QColor(GetRValue(colorHighlight), |
|
52 | m_seriesColors.append(QColor(GetRValue(colorHighlight), | |
53 | GetGValue(colorHighlight), |
|
53 | GetGValue(colorHighlight), | |
54 | GetBValue(colorHighlight))); |
|
54 | GetBValue(colorHighlight))); | |
55 |
|
55 | |||
56 | // Second series base color from COLOR_WINDOWFRAME |
|
56 | // Second series base color from COLOR_WINDOWFRAME | |
57 | DWORD colorWindowFrame; |
|
57 | DWORD colorWindowFrame; | |
58 | colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME); |
|
58 | colorWindowFrame = GetSysColor(COLOR_WINDOWFRAME); | |
59 | m_seriesColors.append(QColor(GetRValue(colorWindowFrame), |
|
59 | m_seriesColors.append(QColor(GetRValue(colorWindowFrame), | |
60 | GetGValue(colorWindowFrame), |
|
60 | GetGValue(colorWindowFrame), | |
61 | GetBValue(colorWindowFrame))); |
|
61 | GetBValue(colorWindowFrame))); | |
62 |
|
62 | |||
63 | // Third series base color from the middle of the COLOR_ACTIVECAPTION / |
|
63 | // Third series base color from the middle of the COLOR_ACTIVECAPTION / | |
64 | // COLOR_GRADIENTACTIVECAPTION gradient |
|
64 | // COLOR_GRADIENTACTIVECAPTION gradient | |
65 | DWORD colorGradientActiveCaptionLeft; |
|
65 | DWORD colorGradientActiveCaptionLeft; | |
66 | colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION); |
|
66 | colorGradientActiveCaptionLeft = GetSysColor(COLOR_ACTIVECAPTION); | |
67 | DWORD colorGradientActiveCaptionRight; |
|
67 | DWORD colorGradientActiveCaptionRight; | |
68 | colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION); |
|
68 | colorGradientActiveCaptionRight = GetSysColor(COLOR_GRADIENTACTIVECAPTION); | |
69 | QLinearGradient g; |
|
69 | QLinearGradient g; | |
70 | QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft), |
|
70 | QColor start = QColor(GetRValue(colorGradientActiveCaptionLeft), | |
71 | GetGValue(colorGradientActiveCaptionLeft), |
|
71 | GetGValue(colorGradientActiveCaptionLeft), | |
72 | GetBValue(colorGradientActiveCaptionLeft)); |
|
72 | GetBValue(colorGradientActiveCaptionLeft)); | |
73 | g.setColorAt(0.0, start); |
|
73 | g.setColorAt(0.0, start); | |
74 | QColor end = QColor(GetRValue(colorGradientActiveCaptionRight), |
|
74 | QColor end = QColor(GetRValue(colorGradientActiveCaptionRight), | |
75 | GetGValue(colorGradientActiveCaptionRight), |
|
75 | GetGValue(colorGradientActiveCaptionRight), | |
76 | GetBValue(colorGradientActiveCaptionRight)); |
|
76 | GetBValue(colorGradientActiveCaptionRight)); | |
77 | g.setColorAt(1.0, end); |
|
77 | g.setColorAt(1.0, end); | |
78 | m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); |
|
78 | m_seriesColors.append(ChartThemeManager::colorAt(g, 0.5)); | |
79 |
|
79 | |||
80 | // Generate gradients from the base colors |
|
80 | // Generate gradients from the base colors | |
81 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); |
|
81 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
82 |
|
82 | |||
83 | // Background fill color from COLOR_WINDOW |
|
83 | // Background fill color from COLOR_WINDOW | |
84 | QLinearGradient backgroundGradient; |
|
84 | QLinearGradient backgroundGradient; | |
85 | DWORD colorWindow; |
|
85 | DWORD colorWindow; | |
86 | colorWindow = GetSysColor(COLOR_WINDOW); |
|
86 | colorWindow = GetSysColor(COLOR_WINDOW); | |
87 | backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow), |
|
87 | backgroundGradient.setColorAt(0.0, QColor(GetRValue(colorWindow), | |
88 | GetGValue(colorWindow), |
|
88 | GetGValue(colorWindow), | |
89 | GetBValue(colorWindow))); |
|
89 | GetBValue(colorWindow))); | |
90 | backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow), |
|
90 | backgroundGradient.setColorAt(1.0, QColor(GetRValue(colorWindow), | |
91 | GetGValue(colorWindow), |
|
91 | GetGValue(colorWindow), | |
92 | GetBValue(colorWindow))); |
|
92 | GetBValue(colorWindow))); | |
93 | // Axes and other |
|
93 | // Axes and other | |
94 | m_axisLinePen = QPen(0xd6d6d6); |
|
94 | m_axisLinePen = QPen(0xd6d6d6); | |
95 | m_axisLinePen.setWidth(1); |
|
95 | m_axisLinePen.setWidth(1); | |
96 | m_labelBrush = QBrush(QRgb(0x404044)); |
|
96 | m_labelBrush = QBrush(QRgb(0x404044)); | |
97 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
97 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); | |
98 | m_gridLinePen.setWidth(1); |
|
98 | m_gridLinePen.setWidth(1); | |
99 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); |
|
99 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); | |
100 | m_minorGridLinePen.setWidth(1); |
|
100 | m_minorGridLinePen.setWidth(1); | |
101 | m_minorGridLinePen.setStyle(Qt::DashLine); |
|
101 | m_minorGridLinePen.setStyle(Qt::DashLine); | |
102 | m_backgroundShades = BackgroundShadesNone; |
|
102 | m_backgroundShades = BackgroundShadesNone; | |
103 |
|
103 | |||
104 | #elif defined(Q_OS_LINUX) |
|
104 | #elif defined(Q_OS_LINUX) | |
105 | // Using a hard coded theme for Linux system theme |
|
105 | // Using a hard coded theme for Linux system theme | |
106 | m_seriesColors << QRgb(0x60a6e6); |
|
106 | m_seriesColors << QRgb(0x60a6e6); | |
107 | m_seriesColors << QRgb(0x92ca66); |
|
107 | m_seriesColors << QRgb(0x92ca66); | |
108 | m_seriesColors << QRgb(0xeba85f); |
|
108 | m_seriesColors << QRgb(0xeba85f); | |
109 | m_seriesColors << QRgb(0xfc5751); |
|
109 | m_seriesColors << QRgb(0xfc5751); | |
110 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); |
|
110 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
111 |
|
111 | |||
112 | // Background |
|
112 | // Background | |
113 | QLinearGradient backgroundGradient; |
|
113 | QLinearGradient backgroundGradient; | |
114 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); |
|
114 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); | |
115 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); |
|
115 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); | |
116 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
116 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
117 | m_chartBackgroundGradient = backgroundGradient; |
|
117 | m_chartBackgroundGradient = backgroundGradient; | |
118 |
|
118 | |||
119 | // Axes and other |
|
119 | // Axes and other | |
120 | m_axisLinePen = QPen(0xd6d6d6); |
|
120 | m_axisLinePen = QPen(0xd6d6d6); | |
121 | m_axisLinePen.setWidth(1); |
|
121 | m_axisLinePen.setWidth(1); | |
122 | m_labelBrush = QBrush(QRgb(0x404044)); |
|
122 | m_labelBrush = QBrush(QRgb(0x404044)); | |
123 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
123 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); | |
124 | m_gridLinePen.setWidth(1); |
|
124 | m_gridLinePen.setWidth(1); | |
125 |
m_minorGridLinePen = Q |
|
125 | m_minorGridLinePen = QPen(QRgb(0x404044)); | |
126 | m_minorGridLinePen.setWidth(1); |
|
126 | m_minorGridLinePen.setWidth(1); | |
127 | m_minorGridLinePen.setStyle(Qt::DashLine); |
|
127 | m_minorGridLinePen.setStyle(Qt::DashLine); | |
128 | m_backgroundShades = BackgroundShadesNone; |
|
128 | m_backgroundShades = BackgroundShadesNone; | |
129 |
|
129 | |||
130 | #elif defined(Q_OS_MAC) |
|
130 | #elif defined(Q_OS_MAC) | |
131 | // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors |
|
131 | // Using a hard coded theme for OSX system theme; the colors match the OSX 10.7 colors | |
132 | m_seriesColors << QRgb(0x60a6e6); |
|
132 | m_seriesColors << QRgb(0x60a6e6); | |
133 | m_seriesColors << QRgb(0x92ca66); |
|
133 | m_seriesColors << QRgb(0x92ca66); | |
134 | m_seriesColors << QRgb(0xeba85f); |
|
134 | m_seriesColors << QRgb(0xeba85f); | |
135 | m_seriesColors << QRgb(0xfc5751); |
|
135 | m_seriesColors << QRgb(0xfc5751); | |
136 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); |
|
136 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
137 |
|
137 | |||
138 | // Background |
|
138 | // Background | |
139 | QLinearGradient backgroundGradient; |
|
139 | QLinearGradient backgroundGradient; | |
140 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); |
|
140 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); | |
141 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); |
|
141 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); | |
142 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
142 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
143 | m_chartBackgroundGradient = backgroundGradient; |
|
143 | m_chartBackgroundGradient = backgroundGradient; | |
144 |
|
144 | |||
145 | // Axes and other |
|
145 | // Axes and other | |
146 | m_axisLinePen = QPen(0xd6d6d6); |
|
146 | m_axisLinePen = QPen(0xd6d6d6); | |
147 | m_axisLinePen.setWidth(1); |
|
147 | m_axisLinePen.setWidth(1); | |
148 | m_labelBrush = QBrush(QRgb(0x404044)); |
|
148 | m_labelBrush = QBrush(QRgb(0x404044)); | |
149 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
149 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); | |
150 | m_gridLinePen.setWidth(1); |
|
150 | m_gridLinePen.setWidth(1); | |
151 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); |
|
151 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); | |
152 | m_minorGridLinePen.setWidth(1); |
|
152 | m_minorGridLinePen.setWidth(1); | |
153 | m_minorGridLinePen.setStyle(Qt::DashLine); |
|
153 | m_minorGridLinePen.setStyle(Qt::DashLine); | |
154 | m_backgroundShades = BackgroundShadesNone; |
|
154 | m_backgroundShades = BackgroundShadesNone; | |
155 |
|
155 | |||
156 | #else |
|
156 | #else | |
157 | // Hard coded theme |
|
157 | // Hard coded theme | |
158 | m_seriesColors << QRgb(0x60a6e6); |
|
158 | m_seriesColors << QRgb(0x60a6e6); | |
159 | m_seriesColors << QRgb(0x92ca66); |
|
159 | m_seriesColors << QRgb(0x92ca66); | |
160 | m_seriesColors << QRgb(0xeba85f); |
|
160 | m_seriesColors << QRgb(0xeba85f); | |
161 | m_seriesColors << QRgb(0xfc5751); |
|
161 | m_seriesColors << QRgb(0xfc5751); | |
162 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); |
|
162 | m_seriesGradients = ChartThemeManager::generateSeriesGradients(m_seriesColors); | |
163 |
|
163 | |||
164 | // Background |
|
164 | // Background | |
165 | QLinearGradient backgroundGradient; |
|
165 | QLinearGradient backgroundGradient; | |
166 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); |
|
166 | backgroundGradient.setColorAt(0.0, QRgb(0xffffff)); | |
167 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); |
|
167 | backgroundGradient.setColorAt(1.0, QRgb(0xffffff)); | |
168 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
168 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
169 | m_chartBackgroundGradient = backgroundGradient; |
|
169 | m_chartBackgroundGradient = backgroundGradient; | |
170 |
|
170 | |||
171 | // Axes and other |
|
171 | // Axes and other | |
172 | m_axisLinePen = QPen(0xd6d6d6); |
|
172 | m_axisLinePen = QPen(0xd6d6d6); | |
173 | m_axisLinePen.setWidth(1); |
|
173 | m_axisLinePen.setWidth(1); | |
174 | m_labelBrush = QBrush(QRgb(0x404044)); |
|
174 | m_labelBrush = QBrush(QRgb(0x404044)); | |
175 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); |
|
175 | m_gridLinePen = QPen(QRgb(0xe2e2e2)); | |
176 | m_gridLinePen.setWidth(1); |
|
176 | m_gridLinePen.setWidth(1); | |
177 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); |
|
177 | m_minorGridLinePen = QPen(QRgb(0xe2e2e2)); | |
178 | m_minorGridLinePen.setWidth(1); |
|
178 | m_minorGridLinePen.setWidth(1); | |
179 | m_minorGridLinePen.setStyle(Qt::DashLine); |
|
179 | m_minorGridLinePen.setStyle(Qt::DashLine); | |
180 | m_backgroundShades = BackgroundShadesNone; |
|
180 | m_backgroundShades = BackgroundShadesNone; | |
181 | #endif |
|
181 | #endif | |
182 | } |
|
182 | } | |
183 | }; |
|
183 | }; | |
184 |
|
184 | |||
185 | QT_CHARTS_END_NAMESPACE |
|
185 | QT_CHARTS_END_NAMESPACE | |
186 |
|
186 | |||
187 | #endif // CHARTTHEMESYSTEM_P_H |
|
187 | #endif // CHARTTHEMESYSTEM_P_H |
@@ -1,112 +1,111 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include "declarativecategoryaxis.h" |
|
19 | #include "declarativecategoryaxis.h" | |
20 | #include <QtCore/QDebug> |
|
20 | #include <QtCore/QDebug> | |
21 |
|
21 | |||
22 | QT_CHARTS_BEGIN_NAMESPACE |
|
22 | QT_CHARTS_BEGIN_NAMESPACE | |
23 |
|
23 | |||
24 | /*! |
|
24 | /*! | |
25 | \qmltype CategoryRange |
|
25 | \qmltype CategoryRange | |
26 | \inqmlmodule QtCharts |
|
26 | \inqmlmodule QtCharts | |
27 |
|
27 | |||
28 | \brief With CategoryRange you can define a range used by a CategoryAxis. |
|
28 | \brief With CategoryRange you can define a range used by a CategoryAxis. | |
29 | \sa CategoryAxis |
|
29 | \sa CategoryAxis | |
30 | */ |
|
30 | */ | |
31 |
|
31 | |||
32 | DeclarativeCategoryRange::DeclarativeCategoryRange(QObject *parent) : |
|
32 | DeclarativeCategoryRange::DeclarativeCategoryRange(QObject *parent) : | |
33 | QObject(parent), |
|
33 | QObject(parent), | |
34 | m_endValue(0), |
|
34 | m_endValue(0), | |
35 | m_label(QString()) |
|
35 | m_label(QString()) | |
36 | { |
|
36 | { | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | DeclarativeCategoryAxis::DeclarativeCategoryAxis(QObject *parent) : |
|
39 | DeclarativeCategoryAxis::DeclarativeCategoryAxis(QObject *parent) : | |
40 | QCategoryAxis(parent) |
|
40 | QCategoryAxis(parent) | |
41 | { |
|
41 | { | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void DeclarativeCategoryAxis::classBegin() |
|
44 | void DeclarativeCategoryAxis::classBegin() | |
45 | { |
|
45 | { | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | void DeclarativeCategoryAxis::componentComplete() |
|
48 | void DeclarativeCategoryAxis::componentComplete() | |
49 | { |
|
49 | { | |
50 | QList<QPair<QString, qreal> > ranges; |
|
50 | QList<QPair<QString, qreal> > ranges; | |
51 | foreach (QObject *child, children()) { |
|
51 | foreach (QObject *child, children()) { | |
52 | if (qobject_cast<DeclarativeCategoryRange *>(child)) { |
|
52 | if (qobject_cast<DeclarativeCategoryRange *>(child)) { | |
53 | DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); |
|
53 | DeclarativeCategoryRange *range = qobject_cast<DeclarativeCategoryRange *>(child); | |
54 | ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); |
|
54 | ranges.append(QPair<QString, qreal>(range->label(), range->endValue())); | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // Sort and append the range objects according to end value |
|
58 | // Sort and append the range objects according to end value | |
59 | qSort(ranges.begin(), ranges.end(), endValueLessThan); |
|
59 | qSort(ranges.begin(), ranges.end(), endValueLessThan); | |
60 | for (int i(0); i < ranges.count(); i++) |
|
60 | for (int i(0); i < ranges.count(); i++) | |
61 | append(ranges.at(i).first, ranges.at(i).second); |
|
61 | append(ranges.at(i).first, ranges.at(i).second); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) |
|
64 | bool DeclarativeCategoryAxis::endValueLessThan(const QPair<QString, qreal> &value1, const QPair<QString, qreal> &value2) | |
65 | { |
|
65 | { | |
66 | return value1.second < value2.second; |
|
66 | return value1.second < value2.second; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | QQmlListProperty<QObject> DeclarativeCategoryAxis::axisChildren() |
|
69 | QQmlListProperty<QObject> DeclarativeCategoryAxis::axisChildren() | |
70 | { |
|
70 | { | |
71 | return QQmlListProperty<QObject>(this, 0, &DeclarativeCategoryAxis::appendAxisChildren ,0,0,0); |
|
71 | return QQmlListProperty<QObject>(this, 0, &DeclarativeCategoryAxis::appendAxisChildren ,0,0,0); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void DeclarativeCategoryAxis::append(const QString &label, qreal categoryEndValue) |
|
74 | void DeclarativeCategoryAxis::append(const QString &label, qreal categoryEndValue) | |
75 | { |
|
75 | { | |
76 | QCategoryAxis::append(label, categoryEndValue); |
|
76 | QCategoryAxis::append(label, categoryEndValue); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void DeclarativeCategoryAxis::remove(const QString &label) |
|
79 | void DeclarativeCategoryAxis::remove(const QString &label) | |
80 | { |
|
80 | { | |
81 | QCategoryAxis::remove(label); |
|
81 | QCategoryAxis::remove(label); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void DeclarativeCategoryAxis::replace(const QString &oldLabel, const QString &newLabel) |
|
84 | void DeclarativeCategoryAxis::replace(const QString &oldLabel, const QString &newLabel) | |
85 | { |
|
85 | { | |
86 | QCategoryAxis::replaceLabel(oldLabel, newLabel); |
|
86 | QCategoryAxis::replaceLabel(oldLabel, newLabel); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void DeclarativeCategoryAxis::appendAxisChildren(QQmlListProperty<QObject> *list, QObject *element) |
|
89 | void DeclarativeCategoryAxis::appendAxisChildren(QQmlListProperty<QObject> *list, QObject *element) | |
90 | { |
|
90 | { | |
91 | // Empty implementation; the children are parsed in componentComplete instead |
|
91 | // Empty implementation; the children are parsed in componentComplete instead | |
92 | Q_UNUSED(list) |
|
92 | Q_UNUSED(list) | |
93 | Q_UNUSED(element) |
|
93 | Q_UNUSED(element) | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | DeclarativeCategoryAxis::AxisLabelsPosition DeclarativeCategoryAxis::labelsPosition() const |
|
96 | DeclarativeCategoryAxis::AxisLabelsPosition DeclarativeCategoryAxis::labelsPosition() const | |
97 | { |
|
97 | { | |
98 | return (DeclarativeCategoryAxis::AxisLabelsPosition) QCategoryAxis::labelsPosition(); |
|
98 | return (DeclarativeCategoryAxis::AxisLabelsPosition) QCategoryAxis::labelsPosition(); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | void DeclarativeCategoryAxis::setLabelsPosition(AxisLabelsPosition position) |
|
101 | void DeclarativeCategoryAxis::setLabelsPosition(AxisLabelsPosition position) | |
102 | { |
|
102 | { | |
103 | QCategoryAxis::AxisLabelsPosition labelsPosition = (QCategoryAxis::AxisLabelsPosition) position; |
|
103 | if (position != m_labelsPosition) { | |
104 | if (labelsPosition != m_labelsPosition) { |
|
104 | QCategoryAxis::setLabelsPosition((QCategoryAxis::AxisLabelsPosition)position); | |
105 | QCategoryAxis::setLabelsPosition(labelsPosition); |
|
|||
106 | emit labelsPositionChanged(position); |
|
105 | emit labelsPositionChanged(position); | |
107 | } |
|
106 | } | |
108 | } |
|
107 | } | |
109 |
|
108 | |||
110 | #include "moc_declarativecategoryaxis.cpp" |
|
109 | #include "moc_declarativecategoryaxis.cpp" | |
111 |
|
110 | |||
112 | QT_CHARTS_END_NAMESPACE |
|
111 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now