@@ -0,0 +1,14 | |||
|
1 | /*! | |
|
2 | \page qml.html | |
|
3 | \title QtCommercial Charts QML API | |
|
4 | \keyword Charts QML API | |
|
5 | ||
|
6 | Charts QML API is an intuitive and simple way to use QtCommercial Charts in your QML applications. | |
|
7 | ||
|
8 | \raw HTML | |
|
9 | <ul> | |
|
10 | <li><a href="qml-chartview.html">ChartView</a></li> | |
|
11 | <li><a href="qml-pieseries.html">PieSeries</a></li> | |
|
12 | </ul> | |
|
13 | \endraw | |
|
14 | */ |
@@ -1,58 +1,59 | |||
|
1 | 1 | include(qchart-html.qdocconf) |
|
2 | 2 | |
|
3 | 3 | HTML.postheader = \ |
|
4 | 4 | "<div class=\"header\" id=\"qtdocheader\">\n" \ |
|
5 | 5 | " <div class=\"content\"> \n" \ |
|
6 | 6 | " <img src=\"images/qcharts.png\" alt=\"qcharts\"/>\n" \ |
|
7 | 7 | " <p class=\"qtref\"> \n" \ |
|
8 | 8 | " <span>Reference Documentation</span>\n" \ |
|
9 | 9 | " </p>\n" \ |
|
10 | 10 | " </div>\n" \ |
|
11 | 11 | " <div class=\"breadcrumb toolblock\">\n" \ |
|
12 | 12 | " <ul>\n" \ |
|
13 | 13 | " <li class=\"first\"><a href=\"index.html\">About</a></li>\n" \ |
|
14 | 14 | " <li><a href=\"introduction.html\">Getting started</a></li>\n" \ |
|
15 | 15 | " <li><a href=\"classes.html\">API Classes</a></li>\n" \ |
|
16 | " <li><a href=\"qml.html\">QML API</a></li>\n" \ | |
|
16 | 17 | " <li><a href=\"examples.html\">Examples</a></li>\n" \ |
|
17 | 18 | " <li><a href=\"demos.html\">Demos</a></li>\n" \ |
|
18 | 19 | " <!-- Breadcrumbs go here -->\n" |
|
19 | 20 | |
|
20 | 21 | HTML.postpostheader = \ |
|
21 | 22 | " </ul>\n" \ |
|
22 | 23 | " </div>\n" \ |
|
23 | 24 | "</div>\n" \ |
|
24 | 25 | "<div class=\"content mainContent\">\n" |
|
25 | 26 | |
|
26 | 27 | HTML.footer = \ |
|
27 | 28 | " <div class=\"ft\">\n" \ |
|
28 | 29 | " <span></span>\n" \ |
|
29 | 30 | " </div>\n" \ |
|
30 | 31 | "</div> \n" \ |
|
31 | 32 | "<div class=\"footer\">\n" \ |
|
32 | 33 | " <p>\n" \ |
|
33 | 34 | " <acronym title=\"Copyright\">©</acronym> 2012 Digia ." \ |
|
34 | 35 | " Qt and Qt logos are trademarks of of Nokia Corporation \n" \ |
|
35 | 36 | " in Finland and/or other countries worldwide.</p>\n" \ |
|
36 | 37 | " <p>\n" \ |
|
37 | 38 | " All other trademarks are property of their respective owners.</p>\n" \ |
|
38 | 39 | " <br />\n" \ |
|
39 | 40 | " <p>\n" \ |
|
40 | 41 | " Licensees holding valid Qt Commercial licenses may use this document in accordance with the" \ |
|
41 | 42 | " Qt Commercial License Agreement provided with the Software or, alternatively, in accordance" \ |
|
42 | 43 | " with the terms contained in a written agreement between you and Digia.</p>\n" \ |
|
43 | 44 | " <p>\n" \ |
|
44 | 45 | " <img src=\"images/digia_logo.png\" alt=\"digia\" /></p>\n" \ |
|
45 | 46 | "</div>\n" \ |
|
46 | 47 | |
|
47 | 48 | # Files not referenced in any qdoc file. |
|
48 | 49 | # See also extraimages.HTML |
|
49 | 50 | qhp.QDoc.extraFiles = index.html \ |
|
50 | 51 | images/arrow_down.png \ |
|
51 | 52 | images/breadcrumb.png \ |
|
52 | 53 | images/bullet_gt.png \ |
|
53 | 54 | images/bullet_dn.png \ |
|
54 | 55 | images/bullet_sq.png \ |
|
55 | 56 | images/bullet_up.png \ |
|
56 | 57 | images/horBar.png \ |
|
57 | 58 | images/qcharts.png \ |
|
58 | 59 | style/offline.css |
@@ -1,46 +1,48 | |||
|
1 | 1 | include(compat.qdocconf) |
|
2 | 2 | include(macros.qdocconf) |
|
3 | 3 | include(qchart-html-template.qdocconf) |
|
4 | 4 | |
|
5 | 5 | project = QtCommercialCharts |
|
6 | 6 | description = Library for creating charts |
|
7 | 7 | |
|
8 | 8 | sourcedirs = ../src \ |
|
9 | 9 | ../examples \ |
|
10 | ./src | |
|
10 | ./src \ | |
|
11 | ../plugins/declarative | |
|
11 | 12 | headerdirs = ../src \ |
|
12 | ../examples | |
|
13 | ../examples \ | |
|
14 | ../plugins/declarative | |
|
13 | 15 | exampledirs = ../ \ |
|
14 | 16 | ../src \ |
|
15 | 17 | ../examples |
|
16 | 18 | |
|
17 | 19 | excludefiles += ../examples/linechart/linechart.pro |
|
18 | 20 | |
|
19 | 21 | sources.fileextensions = *.cpp *.qdoc *.mm *.qml |
|
20 | 22 | headers.fileextensions = *.h *.ch *.h++ *.hh *.hpp *.hxx |
|
21 | 23 | examples.fileextensions = *.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml |
|
22 | 24 | examples.imageextensions = *.png *.jpeg *.jpg *.gif *.mng |
|
23 | 25 | |
|
24 | 26 | imagedirs = ./images |
|
25 | 27 | outputdir = ./html |
|
26 | 28 | |
|
27 | 29 | |
|
28 | 30 | Cpp.ignoretokens = QTCOMMERCIALCHART_EXPORT \ |
|
29 | 31 | QTCOMMERCIALCHART_END_NAMESPACE \ |
|
30 | 32 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 33 | Cpp.ignoredirectives = Q_DECLARE_HANDLE \ |
|
32 | 34 | Q_DECLARE_INTERFACE \ |
|
33 | 35 | Q_DECLARE_METATYPE \ |
|
34 | 36 | Q_DECLARE_OPERATORS_FOR_FLAGS \ |
|
35 | 37 | Q_DECLARE_PRIVATE \ |
|
36 | 38 | Q_DECLARE_PUBLIC \ |
|
37 | 39 | Q_DECLARE_SHARED \ |
|
38 | 40 | Q_DECLARE_TR_FUNCTIONS \ |
|
39 | 41 | Q_DECLARE_TYPEINFO \ |
|
40 | 42 | Q_DISABLE_COPY \ |
|
41 | 43 | QT_FORWARD_DECLARE_CLASS \ |
|
42 | 44 | Q_DUMMY_COMPARISON_OPERATOR \ |
|
43 | 45 | Q_ENUMS \ |
|
44 | 46 | Q_FLAGS \ |
|
45 | 47 | Q_INTERFACES \ |
|
46 | __attribute__ No newline at end of file | |
|
48 | __attribute__ |
@@ -1,268 +1,281 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativechart.h" |
|
22 | 22 | #include <QPainter> |
|
23 | 23 | #include "declarativelineseries.h" |
|
24 | 24 | #include "declarativeareaseries.h" |
|
25 | 25 | #include "declarativebarseries.h" |
|
26 | 26 | #include "declarativepieseries.h" |
|
27 | 27 | #include "declarativesplineseries.h" |
|
28 | 28 | #include "declarativescatterseries.h" |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | /*! | |
|
33 | \qmlclass ChartView DeclarativeChart | |
|
34 | ||
|
35 | ChartView element is the parent that is responsible for showing different chart series types. | |
|
36 | ||
|
37 | \section1 Example Usage | |
|
38 | ||
|
39 | \beginfloatleft | |
|
40 | \image demos_qmlchart1.png | |
|
41 | \endfloat | |
|
42 | \clearfloat | |
|
43 | */ | |
|
44 | ||
|
32 | 45 | DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) |
|
33 | 46 | : QDeclarativeItem(parent), |
|
34 | 47 | m_chart(new QChart(this)) |
|
35 | 48 | { |
|
36 | 49 | setFlag(QGraphicsItem::ItemHasNoContents, false); |
|
37 | 50 | // m_chart->axisX()->setNiceNumbersEnabled(false); |
|
38 | 51 | } |
|
39 | 52 | |
|
40 | 53 | DeclarativeChart::~DeclarativeChart() |
|
41 | 54 | { |
|
42 | 55 | delete m_chart; |
|
43 | 56 | } |
|
44 | 57 | |
|
45 | 58 | void DeclarativeChart::childEvent(QChildEvent *event) |
|
46 | 59 | { |
|
47 | 60 | if (event->type() == QEvent::ChildAdded) { |
|
48 | 61 | if (qobject_cast<QAbstractSeries *>(event->child())) { |
|
49 | 62 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(event->child())); |
|
50 | 63 | } |
|
51 | 64 | } |
|
52 | 65 | } |
|
53 | 66 | |
|
54 | 67 | void DeclarativeChart::componentComplete() |
|
55 | 68 | { |
|
56 | 69 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
57 | 70 | foreach(QObject *child, children()) { |
|
58 | 71 | if (qobject_cast<QAbstractSeries *>(child)) { |
|
59 | 72 | // qDebug() << "DeclarativeChart::componentComplete(), add: " << child; |
|
60 | 73 | m_chart->addSeries(qobject_cast<QAbstractSeries *>(child)); |
|
61 | 74 | } |
|
62 | 75 | } |
|
63 | 76 | // qDebug() << "DeclarativeChart::componentComplete(), maxX: " << axisX()->max(); |
|
64 | 77 | |
|
65 | 78 | QDeclarativeItem::componentComplete(); |
|
66 | 79 | } |
|
67 | 80 | |
|
68 | 81 | void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) |
|
69 | 82 | { |
|
70 | 83 | // qDebug() << "DeclarativeChart::geometryChanged" << newGeometry.width() << newGeometry.height(); |
|
71 | 84 | if (newGeometry.isValid()) { |
|
72 | 85 | if (newGeometry.width() > 0 && newGeometry.height() > 0) { |
|
73 | 86 | m_chart->resize(newGeometry.width(), newGeometry.height()); |
|
74 | 87 | } |
|
75 | 88 | } |
|
76 | 89 | QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); |
|
77 | 90 | } |
|
78 | 91 | |
|
79 | 92 | void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
80 | 93 | { |
|
81 | 94 | Q_UNUSED(option) |
|
82 | 95 | Q_UNUSED(widget) |
|
83 | 96 | |
|
84 | 97 | // TODO: optimized? |
|
85 | 98 | painter->setRenderHint(QPainter::Antialiasing, true); |
|
86 | 99 | } |
|
87 | 100 | |
|
88 | 101 | void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) |
|
89 | 102 | { |
|
90 | 103 | QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; |
|
91 | 104 | if (chartTheme != m_chart->theme()) { |
|
92 | 105 | m_chart->setTheme(chartTheme); |
|
93 | 106 | themeChanged(); |
|
94 | 107 | } |
|
95 | 108 | } |
|
96 | 109 | |
|
97 | 110 | DeclarativeChart::Theme DeclarativeChart::theme() |
|
98 | 111 | { |
|
99 | 112 | return (DeclarativeChart::Theme) m_chart->theme(); |
|
100 | 113 | } |
|
101 | 114 | |
|
102 | 115 | void DeclarativeChart::setAnimationOptions(DeclarativeChart::Animation animations) |
|
103 | 116 | { |
|
104 | 117 | QChart::AnimationOption animationOptions = (QChart::AnimationOption) animations; |
|
105 | 118 | if (animationOptions != m_chart->animationOptions()) { |
|
106 | 119 | m_chart->setAnimationOptions(animationOptions); |
|
107 | 120 | animationOptionsChanged(); |
|
108 | 121 | } |
|
109 | 122 | } |
|
110 | 123 | |
|
111 | 124 | DeclarativeChart::Animation DeclarativeChart::animationOptions() |
|
112 | 125 | { |
|
113 | 126 | if (m_chart->animationOptions().testFlag(QChart::AllAnimations)) |
|
114 | 127 | return DeclarativeChart::AllAnimations; |
|
115 | 128 | else if (m_chart->animationOptions().testFlag(QChart::GridAxisAnimations)) |
|
116 | 129 | return DeclarativeChart::GridAxisAnimations; |
|
117 | 130 | else if (m_chart->animationOptions().testFlag(QChart::SeriesAnimations)) |
|
118 | 131 | return DeclarativeChart::SeriesAnimations; |
|
119 | 132 | else |
|
120 | 133 | return DeclarativeChart::NoAnimation; |
|
121 | 134 | } |
|
122 | 135 | |
|
123 | 136 | void DeclarativeChart::setTitle(QString title) |
|
124 | 137 | { |
|
125 | 138 | if (title != m_chart->title()) { |
|
126 | 139 | m_chart->setTitle(title); |
|
127 | 140 | emit titleChanged(); |
|
128 | 141 | } |
|
129 | 142 | } |
|
130 | 143 | QString DeclarativeChart::title() |
|
131 | 144 | { |
|
132 | 145 | return m_chart->title(); |
|
133 | 146 | } |
|
134 | 147 | |
|
135 | 148 | QAxis *DeclarativeChart::axisX() |
|
136 | 149 | { |
|
137 | 150 | return m_chart->axisX(); |
|
138 | 151 | } |
|
139 | 152 | |
|
140 | 153 | QAxis *DeclarativeChart::axisY() |
|
141 | 154 | { |
|
142 | 155 | return m_chart->axisY(); |
|
143 | 156 | } |
|
144 | 157 | |
|
145 | 158 | QLegend *DeclarativeChart::legend() |
|
146 | 159 | { |
|
147 | 160 | return m_chart->legend(); |
|
148 | 161 | } |
|
149 | 162 | |
|
150 | 163 | QVariantList DeclarativeChart::axisXLabels() |
|
151 | 164 | { |
|
152 | 165 | QVariantList labels; |
|
153 | 166 | foreach (qreal value, m_chart->axisX()->categories()->values()) { |
|
154 | 167 | labels.append(value); |
|
155 | 168 | labels.append(m_chart->axisX()->categories()->label(value)); |
|
156 | 169 | } |
|
157 | 170 | return labels; |
|
158 | 171 | } |
|
159 | 172 | |
|
160 | 173 | void DeclarativeChart::setAxisXLabels(QVariantList list) |
|
161 | 174 | { |
|
162 | 175 | QVariant value(QVariant::Invalid); |
|
163 | 176 | foreach (QVariant element, list) { |
|
164 | 177 | if (value.isValid() && element.type() == QVariant::String) { |
|
165 | 178 | m_chart->axisX()->categories()->insert(value.toDouble(), element.toString()); |
|
166 | 179 | value = QVariant(QVariant::Invalid); |
|
167 | 180 | } else { |
|
168 | 181 | if (element.canConvert(QVariant::Double)) |
|
169 | 182 | value = element; |
|
170 | 183 | } |
|
171 | 184 | } |
|
172 | 185 | emit axisLabelsChanged(); |
|
173 | 186 | } |
|
174 | 187 | |
|
175 | 188 | void DeclarativeChart::setTitleColor(QColor color) |
|
176 | 189 | { |
|
177 | 190 | QBrush b = m_chart->titleBrush(); |
|
178 | 191 | if (color != b.color()) { |
|
179 | 192 | b.setColor(color); |
|
180 | 193 | m_chart->setTitleBrush(b); |
|
181 | 194 | emit titleColorChanged(); |
|
182 | 195 | } |
|
183 | 196 | } |
|
184 | 197 | |
|
185 | 198 | QColor DeclarativeChart::titleColor() |
|
186 | 199 | { |
|
187 | 200 | return m_chart->titleBrush().color(); |
|
188 | 201 | } |
|
189 | 202 | |
|
190 | 203 | void DeclarativeChart::setBackgroundColor(QColor color) |
|
191 | 204 | { |
|
192 | 205 | QBrush b = m_chart->backgroundBrush(); |
|
193 | 206 | if (color != b.color()) { |
|
194 | 207 | b.setColor(color); |
|
195 | 208 | m_chart->setBackgroundBrush(b); |
|
196 | 209 | emit backgroundColorChanged(); |
|
197 | 210 | } |
|
198 | 211 | } |
|
199 | 212 | |
|
200 | 213 | QColor DeclarativeChart::backgroundColor() |
|
201 | 214 | { |
|
202 | 215 | return m_chart->backgroundBrush().color(); |
|
203 | 216 | } |
|
204 | 217 | |
|
205 | 218 | int DeclarativeChart::count() |
|
206 | 219 | { |
|
207 | 220 | return m_chart->series().count(); |
|
208 | 221 | } |
|
209 | 222 | |
|
210 | 223 | QAbstractSeries *DeclarativeChart::series(int index) |
|
211 | 224 | { |
|
212 | 225 | if (index < m_chart->series().count()) { |
|
213 | 226 | return m_chart->series().at(index); |
|
214 | 227 | } |
|
215 | 228 | return 0; |
|
216 | 229 | } |
|
217 | 230 | |
|
218 | 231 | QAbstractSeries *DeclarativeChart::series(QString seriesName) |
|
219 | 232 | { |
|
220 | 233 | foreach(QAbstractSeries *series, m_chart->series()) { |
|
221 | 234 | if (series->name() == seriesName) |
|
222 | 235 | return series; |
|
223 | 236 | } |
|
224 | 237 | return 0; |
|
225 | 238 | } |
|
226 | 239 | |
|
227 | 240 | QAbstractSeries *DeclarativeChart::createSeries(DeclarativeChart::SeriesType type, QString name) |
|
228 | 241 | { |
|
229 | 242 | QAbstractSeries *series = 0; |
|
230 | 243 | switch (type) { |
|
231 | 244 | case DeclarativeChart::SeriesTypeLine: |
|
232 | 245 | series = new DeclarativeLineSeries(); |
|
233 | 246 | break; |
|
234 | 247 | case DeclarativeChart::SeriesTypeArea: |
|
235 | 248 | series = new DeclarativeAreaSeries(); |
|
236 | 249 | break; |
|
237 | 250 | case DeclarativeChart::SeriesTypeBar: |
|
238 | 251 | series = new DeclarativeBarSeries(); |
|
239 | 252 | break; |
|
240 | 253 | case DeclarativeChart::SeriesTypeStackedBar: |
|
241 | 254 | // TODO |
|
242 | 255 | break; |
|
243 | 256 | case DeclarativeChart::SeriesTypePercentBar: |
|
244 | 257 | // TODO |
|
245 | 258 | break; |
|
246 | 259 | case DeclarativeChart::SeriesTypeGroupedBar: |
|
247 | 260 | series = new DeclarativeGroupedBarSeries(); |
|
248 | 261 | break; |
|
249 | 262 | case DeclarativeChart::SeriesTypePie: |
|
250 | 263 | series = new DeclarativePieSeries(); |
|
251 | 264 | break; |
|
252 | 265 | case DeclarativeChart::SeriesTypeScatter: |
|
253 | 266 | series = new DeclarativeScatterSeries(); |
|
254 | 267 | break; |
|
255 | 268 | case DeclarativeChart::SeriesTypeSpline: |
|
256 | 269 | series = new DeclarativeSplineSeries(); |
|
257 | 270 | break; |
|
258 | 271 | default: |
|
259 | 272 | qWarning() << "Illegal series type"; |
|
260 | 273 | } |
|
261 | 274 | series->setName(name); |
|
262 | 275 | m_chart->addSeries(series); |
|
263 | 276 | return series; |
|
264 | 277 | } |
|
265 | 278 | |
|
266 | 279 | #include "moc_declarativechart.cpp" |
|
267 | 280 | |
|
268 | 281 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,96 +1,143 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "declarativepieseries.h" |
|
22 | 22 | #include "declarativechart.h" |
|
23 | 23 | #include "qchart.h" |
|
24 | 24 | #include <qdeclarativelist.h> |
|
25 | 25 | #include <QVPieModelMapper> |
|
26 | 26 | #include <QHPieModelMapper> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 | /*! | |
|
31 | \qmlclass PieSeries DeclarativePieSeries | |
|
32 | ||
|
33 | \section1 Example Usage | |
|
34 | ||
|
35 | \beginfloatleft | |
|
36 | \image demos_qmlchart1.png | |
|
37 | \endfloat | |
|
38 | \clearfloat | |
|
39 | ||
|
40 | The following QML shows how to create a simple pie chart. | |
|
41 | ||
|
42 | \snippet ../demos/qmlchart/qml/qmlchart/View1.qml 1 | |
|
43 | */ | |
|
44 | ||
|
45 | /*! | |
|
46 | \qmlproperty real PieSeries::horizontalPosition | |
|
47 | \brief Defines the horizontal position of the pie. | |
|
48 | ||
|
49 | The value is a relative value to the chart rectangle where: | |
|
50 | ||
|
51 | \list | |
|
52 | \o 0.0 is the absolute left. | |
|
53 | \o 1.0 is the absolute right. | |
|
54 | \endlist | |
|
55 | ||
|
56 | Default value is 0.5 (center). | |
|
57 | ||
|
58 | \sa verticalPosition | |
|
59 | */ | |
|
60 | ||
|
61 | /*! | |
|
62 | \qmlproperty real PieSeries::verticalPosition | |
|
63 | \brief Defines the vertical position of the pie. | |
|
64 | ||
|
65 | The value is a relative value to the chart rectangle where: | |
|
66 | ||
|
67 | \list | |
|
68 | \o 0.0 is the absolute top. | |
|
69 | \o 1.0 is the absolute bottom. | |
|
70 | \endlist | |
|
71 | ||
|
72 | Default value is 0.5 (center). | |
|
73 | ||
|
74 | \sa horizontalPosition | |
|
75 | */ | |
|
76 | ||
|
30 | 77 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
31 | 78 | QPieSeries(parent) |
|
32 | 79 | { |
|
33 | 80 | } |
|
34 | 81 | |
|
35 | 82 | void DeclarativePieSeries::classBegin() |
|
36 | 83 | { |
|
37 | 84 | } |
|
38 | 85 | |
|
39 | 86 | void DeclarativePieSeries::componentComplete() |
|
40 | 87 | { |
|
41 | 88 | foreach(QObject *child, children()) { |
|
42 | 89 | if (qobject_cast<QPieSlice *>(child)) { |
|
43 | 90 | QPieSeries::append(qobject_cast<QPieSlice *>(child)); |
|
44 | 91 | } else if(qobject_cast<QVPieModelMapper *>(child)) { |
|
45 | 92 | QVPieModelMapper *mapper = qobject_cast<QVPieModelMapper *>(child); |
|
46 | 93 | mapper->setSeries(this); |
|
47 | 94 | } else if(qobject_cast<QHPieModelMapper *>(child)) { |
|
48 | 95 | QHPieModelMapper *mapper = qobject_cast<QHPieModelMapper *>(child); |
|
49 | 96 | mapper->setSeries(this); |
|
50 | 97 | } |
|
51 | 98 | } |
|
52 | 99 | } |
|
53 | 100 | |
|
54 | 101 | QDeclarativeListProperty<QObject> DeclarativePieSeries::seriesChildren() |
|
55 | 102 | { |
|
56 | 103 | return QDeclarativeListProperty<QObject>(this, 0, &DeclarativePieSeries::appendSeriesChildren); |
|
57 | 104 | } |
|
58 | 105 | |
|
59 | 106 | void DeclarativePieSeries::appendSeriesChildren(QDeclarativeListProperty<QObject> * list, QObject *element) |
|
60 | 107 | { |
|
61 | 108 | // Empty implementation; the children are parsed in componentComplete instead |
|
62 | 109 | Q_UNUSED(list); |
|
63 | 110 | Q_UNUSED(element); |
|
64 | 111 | } |
|
65 | 112 | |
|
66 | 113 | QPieSlice *DeclarativePieSeries::at(int index) |
|
67 | 114 | { |
|
68 | 115 | QList<QPieSlice*> sliceList = slices(); |
|
69 | 116 | if (index < sliceList.count()) |
|
70 | 117 | return sliceList[index]; |
|
71 | 118 | |
|
72 | 119 | return 0; |
|
73 | 120 | } |
|
74 | 121 | |
|
75 | 122 | QPieSlice* DeclarativePieSeries::find(QString label) |
|
76 | 123 | { |
|
77 | 124 | foreach (QPieSlice *slice, slices()) { |
|
78 | 125 | if (slice->label() == label) |
|
79 | 126 | return slice; |
|
80 | 127 | } |
|
81 | 128 | return 0; |
|
82 | 129 | } |
|
83 | 130 | |
|
84 | 131 | QPieSlice* DeclarativePieSeries::append(QString label, qreal value) |
|
85 | 132 | { |
|
86 | 133 | // TODO: parameter order is wrong, switch it: |
|
87 | 134 | QPieSlice *slice = new QPieSlice(this); |
|
88 | 135 | slice->setLabel(label); |
|
89 | 136 | slice->setValue(value); |
|
90 | 137 | QPieSeries::append(slice); |
|
91 | 138 | return slice; |
|
92 | 139 | } |
|
93 | 140 | |
|
94 | 141 | #include "moc_declarativepieseries.cpp" |
|
95 | 142 | |
|
96 | 143 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now