1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,44 | |||||
|
1 | #include($QTDIR/compat.qdocconf) | |||
|
2 | #include($QTDIR/qt-html-templates.qdocconf) | |||
|
3 | #include(C:/Qt/QtCommercialSdk/src/qt/480/tools/qdoc3/doc/files/qt.qdocconf) | |||
|
4 | ||||
|
5 | project = QtCommercialCharts | |||
|
6 | description = Library for creating charts | |||
|
7 | ||||
|
8 | sourcedirs = ../src \ | |||
|
9 | ../example | |||
|
10 | headerdirs = ../src \ | |||
|
11 | ../example | |||
|
12 | exampledirs = ../src \ | |||
|
13 | ../example | |||
|
14 | ||||
|
15 | HTML.templatedir = . | |||
|
16 | HTML.stylesheets = style/offline.css | |||
|
17 | HTML.headerstyles = \ | |||
|
18 | " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n" | |||
|
19 | sources.fileextensions = *.cpp *.qdoc *.mm *.qml | |||
|
20 | headers.fileextensions = *.h *.ch *.h++ *.hh *.hpp *.hxx | |||
|
21 | examples.fileextensions = *.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml | |||
|
22 | examples.imageextensions = *.png *.jpeg *.jpg *.gif *.mng | |||
|
23 | imagedirs = ./images | |||
|
24 | outputdir = ./html | |||
|
25 | ||||
|
26 | Cpp.ignoretokens = QTCOMMERCIALCHART_EXPORT \ | |||
|
27 | QTCOMMERCIALCHART_END_NAMESPACE \ | |||
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | Cpp.ignoredirectives = Q_DECLARE_HANDLE \ | |||
|
30 | Q_DECLARE_INTERFACE \ | |||
|
31 | Q_DECLARE_METATYPE \ | |||
|
32 | Q_DECLARE_OPERATORS_FOR_FLAGS \ | |||
|
33 | Q_DECLARE_PRIVATE \ | |||
|
34 | Q_DECLARE_PUBLIC \ | |||
|
35 | Q_DECLARE_SHARED \ | |||
|
36 | Q_DECLARE_TR_FUNCTIONS \ | |||
|
37 | Q_DECLARE_TYPEINFO \ | |||
|
38 | Q_DISABLE_COPY \ | |||
|
39 | QT_FORWARD_DECLARE_CLASS \ | |||
|
40 | Q_DUMMY_COMPARISON_OPERATOR \ | |||
|
41 | Q_ENUMS \ | |||
|
42 | Q_FLAGS \ | |||
|
43 | Q_INTERFACES \ | |||
|
44 | __attribute__ No newline at end of file |
This diff has been collapsed as it changes many lines, (673 lines changed) Show them Hide them | |||||
@@ -0,0 +1,673 | |||||
|
1 | @media screen | |||
|
2 | { | |||
|
3 | ||||
|
4 | /* basic elements */ | |||
|
5 | html | |||
|
6 | { | |||
|
7 | color: #000000; | |||
|
8 | background: #FFFFFF; | |||
|
9 | } | |||
|
10 | table | |||
|
11 | { | |||
|
12 | border-collapse: collapse; | |||
|
13 | border-spacing: 0; | |||
|
14 | } | |||
|
15 | fieldset, img | |||
|
16 | { | |||
|
17 | border: 0; | |||
|
18 | max-width:100%; | |||
|
19 | } | |||
|
20 | address, caption, cite, code, dfn, em, strong, th, var, optgroup | |||
|
21 | { | |||
|
22 | font-style: inherit; | |||
|
23 | font-weight: inherit; | |||
|
24 | } | |||
|
25 | del, ins | |||
|
26 | { | |||
|
27 | text-decoration: none; | |||
|
28 | } | |||
|
29 | li | |||
|
30 | { | |||
|
31 | list-style: none; | |||
|
32 | } | |||
|
33 | ol li | |||
|
34 | { | |||
|
35 | list-style: decimal; | |||
|
36 | } | |||
|
37 | caption, th | |||
|
38 | { | |||
|
39 | text-align: left; | |||
|
40 | } | |||
|
41 | h1, h2, h3, h4, h5, h6 | |||
|
42 | { | |||
|
43 | font-size: 100%; | |||
|
44 | } | |||
|
45 | q:before, q:after | |||
|
46 | { | |||
|
47 | content: ''; | |||
|
48 | } | |||
|
49 | abbr, acronym | |||
|
50 | { | |||
|
51 | border: 0; | |||
|
52 | font-variant: normal; | |||
|
53 | } | |||
|
54 | sup, sub | |||
|
55 | { | |||
|
56 | vertical-align: baseline; | |||
|
57 | } | |||
|
58 | tt, .qmlreadonly span, .qmldefault span | |||
|
59 | { | |||
|
60 | word-spacing:0.5em; | |||
|
61 | } | |||
|
62 | legend | |||
|
63 | { | |||
|
64 | color: #000000; | |||
|
65 | } | |||
|
66 | strong | |||
|
67 | { | |||
|
68 | font-weight: bold; | |||
|
69 | } | |||
|
70 | em | |||
|
71 | { | |||
|
72 | font-style: italic; | |||
|
73 | } | |||
|
74 | ||||
|
75 | body | |||
|
76 | { | |||
|
77 | margin-left: 0.5em; | |||
|
78 | margin-right: 0.5em; | |||
|
79 | } | |||
|
80 | a | |||
|
81 | { | |||
|
82 | color: #00732F; | |||
|
83 | text-decoration: none; | |||
|
84 | } | |||
|
85 | hr | |||
|
86 | { | |||
|
87 | background-color: #E6E6E6; | |||
|
88 | border: 1px solid #E6E6E6; | |||
|
89 | height: 1px; | |||
|
90 | width: 100%; | |||
|
91 | text-align: left; | |||
|
92 | margin: 1.5em 0 1.5em 0; | |||
|
93 | } | |||
|
94 | ||||
|
95 | pre | |||
|
96 | { | |||
|
97 | border: 1px solid #DDDDDD; | |||
|
98 | -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
99 | -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
100 | border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
101 | margin: 0 1.5em 1em 1em; | |||
|
102 | padding: 1em 1em 1em 1em; | |||
|
103 | overflow-x: auto; | |||
|
104 | } | |||
|
105 | table, pre | |||
|
106 | { | |||
|
107 | -moz-border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
108 | -webkit-border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
109 | border-radius: 0.7em 0.7em 0.7em 0.7em; | |||
|
110 | background-color: #F6F6F6; | |||
|
111 | border: 1px solid #E6E6E6; | |||
|
112 | border-collapse: separate; | |||
|
113 | margin-bottom: 2.5em; | |||
|
114 | } | |||
|
115 | pre { | |||
|
116 | font-size: 90%; | |||
|
117 | display: block; | |||
|
118 | overflow:hidden; | |||
|
119 | } | |||
|
120 | thead | |||
|
121 | { | |||
|
122 | margin-top: 0.5em; | |||
|
123 | font-weight: bold | |||
|
124 | } | |||
|
125 | th | |||
|
126 | { | |||
|
127 | padding: 0.5em 1.5em 0.5em 1.5em; | |||
|
128 | background-color: #E1E1E1; | |||
|
129 | border-left: 1px solid #E6E6E6; | |||
|
130 | } | |||
|
131 | td | |||
|
132 | { | |||
|
133 | padding: 0.25em 1.5em 0.25em 2em; | |||
|
134 | } | |||
|
135 | ||||
|
136 | td.rightAlign | |||
|
137 | { | |||
|
138 | padding: 0.25em 0.5em 0.25em 1em; | |||
|
139 | } | |||
|
140 | table tr.odd | |||
|
141 | { | |||
|
142 | border-left: 1px solid #E6E6E6; | |||
|
143 | background-color: #F6F6F6; | |||
|
144 | color: #66666E; | |||
|
145 | } | |||
|
146 | table tr.even | |||
|
147 | { | |||
|
148 | border-left: 1px solid #E6E6E6; | |||
|
149 | background-color: #ffffff; | |||
|
150 | color: #66666E; | |||
|
151 | } | |||
|
152 | ||||
|
153 | div.float-left | |||
|
154 | { | |||
|
155 | float: left; margin-right: 2em | |||
|
156 | } | |||
|
157 | div.float-right | |||
|
158 | { | |||
|
159 | float: right; margin-left: 2em | |||
|
160 | } | |||
|
161 | ||||
|
162 | span.comment | |||
|
163 | { | |||
|
164 | color: #008B00; | |||
|
165 | font-style: italic | |||
|
166 | } | |||
|
167 | span.string, span.char | |||
|
168 | { | |||
|
169 | color: #000084; | |||
|
170 | } | |||
|
171 | span.number | |||
|
172 | { | |||
|
173 | color: #a46200; | |||
|
174 | } | |||
|
175 | span.operator | |||
|
176 | { | |||
|
177 | color: #202020; | |||
|
178 | } | |||
|
179 | span.keyword | |||
|
180 | { | |||
|
181 | color: #840000; | |||
|
182 | } | |||
|
183 | span.name | |||
|
184 | { | |||
|
185 | color: black | |||
|
186 | } | |||
|
187 | span.type | |||
|
188 | { | |||
|
189 | font-weight: bold | |||
|
190 | } | |||
|
191 | span.type a:visited | |||
|
192 | { | |||
|
193 | color: #0F5300; | |||
|
194 | } | |||
|
195 | span.preprocessor | |||
|
196 | { | |||
|
197 | color: #404040 | |||
|
198 | } | |||
|
199 | /* end basic elements */ | |||
|
200 | ||||
|
201 | /* font style elements */ | |||
|
202 | .heading | |||
|
203 | { | |||
|
204 | font-weight: bold; | |||
|
205 | font-size: 125%; | |||
|
206 | } | |||
|
207 | .subtitle | |||
|
208 | { | |||
|
209 | font-size: 110% | |||
|
210 | } | |||
|
211 | .small-subtitle | |||
|
212 | { | |||
|
213 | font-size: 100% | |||
|
214 | } | |||
|
215 | .red | |||
|
216 | { | |||
|
217 | color:red; | |||
|
218 | } | |||
|
219 | /* end font style elements */ | |||
|
220 | ||||
|
221 | /* global settings*/ | |||
|
222 | .header, .footer | |||
|
223 | { | |||
|
224 | display: block; | |||
|
225 | clear: both; | |||
|
226 | overflow: hidden; | |||
|
227 | } | |||
|
228 | /* end global settings*/ | |||
|
229 | ||||
|
230 | /* header elements */ | |||
|
231 | .header .qtref | |||
|
232 | { | |||
|
233 | color: #00732F; | |||
|
234 | font-weight: bold; | |||
|
235 | font-size: 130%; | |||
|
236 | } | |||
|
237 | ||||
|
238 | .header .content | |||
|
239 | { | |||
|
240 | margin-bottom: 0.5em | |||
|
241 | } | |||
|
242 | ||||
|
243 | .naviNextPrevious | |||
|
244 | { | |||
|
245 | display: none | |||
|
246 | } | |||
|
247 | .header .breadcrumb | |||
|
248 | { | |||
|
249 | font-size: 90%; | |||
|
250 | padding: 0.5em 0 0.5em 1em; | |||
|
251 | margin: 0; | |||
|
252 | background-color: #fafafa; | |||
|
253 | height: 1.35em; | |||
|
254 | border-bottom: 1px solid #d1d1d1; | |||
|
255 | } | |||
|
256 | ||||
|
257 | .header .breadcrumb ul | |||
|
258 | { | |||
|
259 | margin: 0; | |||
|
260 | padding: 0; | |||
|
261 | } | |||
|
262 | ||||
|
263 | .header .content | |||
|
264 | { | |||
|
265 | word-wrap: break-word; | |||
|
266 | } | |||
|
267 | ||||
|
268 | .header .breadcrumb ul li | |||
|
269 | { | |||
|
270 | float: left; | |||
|
271 | background: url(../images/breadcrumb.png) no-repeat 0 3px; | |||
|
272 | padding-left: 1.5em; | |||
|
273 | margin-left: 1.5em; | |||
|
274 | } | |||
|
275 | ||||
|
276 | .header .breadcrumb ul li.last | |||
|
277 | { | |||
|
278 | font-weight: normal; | |||
|
279 | } | |||
|
280 | ||||
|
281 | .header .breadcrumb ul li a | |||
|
282 | { | |||
|
283 | color: #00732F; | |||
|
284 | } | |||
|
285 | ||||
|
286 | .header .breadcrumb ul li.first | |||
|
287 | { | |||
|
288 | background-image: none; | |||
|
289 | padding-left: 0; | |||
|
290 | margin-left: 0; | |||
|
291 | } | |||
|
292 | ||||
|
293 | .header .content ol li { | |||
|
294 | background: none; | |||
|
295 | margin-bottom: 1.0em; | |||
|
296 | margin-left: 1.2em; | |||
|
297 | padding-left: 0 | |||
|
298 | } | |||
|
299 | ||||
|
300 | .header .content li | |||
|
301 | { | |||
|
302 | background: url(../images/bullet_sq.png) no-repeat 0 5px; | |||
|
303 | margin-bottom: 1em; | |||
|
304 | padding-left: 1.2em; | |||
|
305 | } | |||
|
306 | ||||
|
307 | /* end header elements */ | |||
|
308 | ||||
|
309 | /* content elements */ | |||
|
310 | .content h1 | |||
|
311 | { | |||
|
312 | font-weight: bold; | |||
|
313 | font-size: 150% | |||
|
314 | } | |||
|
315 | ||||
|
316 | .content h2 | |||
|
317 | { | |||
|
318 | font-weight: bold; | |||
|
319 | font-size: 135%; | |||
|
320 | width: 100%; | |||
|
321 | } | |||
|
322 | .content h3 | |||
|
323 | { | |||
|
324 | font-weight: bold; | |||
|
325 | font-size: 120%; | |||
|
326 | width: 100%; | |||
|
327 | } | |||
|
328 | .content table p | |||
|
329 | { | |||
|
330 | margin: 0 | |||
|
331 | } | |||
|
332 | .content ul | |||
|
333 | { | |||
|
334 | padding-left: 2.5em; | |||
|
335 | } | |||
|
336 | .content li | |||
|
337 | { | |||
|
338 | padding-top: 0.25em; | |||
|
339 | padding-bottom: 0.25em; | |||
|
340 | } | |||
|
341 | .content ul img { | |||
|
342 | vertical-align: middle; | |||
|
343 | } | |||
|
344 | ||||
|
345 | .content a:visited | |||
|
346 | { | |||
|
347 | color: #4c0033; | |||
|
348 | text-decoration: none; | |||
|
349 | } | |||
|
350 | ||||
|
351 | .content a:visited:hover | |||
|
352 | { | |||
|
353 | color: #4c0033; | |||
|
354 | text-decoration: underline; | |||
|
355 | } | |||
|
356 | ||||
|
357 | a:hover | |||
|
358 | { | |||
|
359 | color: #4c0033; | |||
|
360 | text-decoration: underline; | |||
|
361 | } | |||
|
362 | descr p a | |||
|
363 | { | |||
|
364 | text-decoration: underline; | |||
|
365 | } | |||
|
366 | ||||
|
367 | .descr p a:visited | |||
|
368 | { | |||
|
369 | text-decoration: underline; | |||
|
370 | } | |||
|
371 | ||||
|
372 | .alphaChar{ | |||
|
373 | width:95%; | |||
|
374 | background-color:#F6F6F6; | |||
|
375 | border:1px solid #E6E6E6; | |||
|
376 | -moz-border-radius: 7px 7px 7px 7px; | |||
|
377 | border-radius: 7px 7px 7px 7px; | |||
|
378 | -webkit-border-radius: 7px 7px 7px 7px; | |||
|
379 | font-size:12pt; | |||
|
380 | padding-left:10px; | |||
|
381 | margin-top:10px; | |||
|
382 | margin-bottom:10px; | |||
|
383 | } | |||
|
384 | .flowList{ | |||
|
385 | /*vertical-align:top;*/ | |||
|
386 | /*margin:20px auto;*/ | |||
|
387 | ||||
|
388 | column-count:3; | |||
|
389 | -webkit-column-count:3; | |||
|
390 | -moz-column-count:3; | |||
|
391 | /* | |||
|
392 | column-width:100%; | |||
|
393 | -webkit-column-width:200px; | |||
|
394 | -col-column-width:200px; | |||
|
395 | */ | |||
|
396 | column-gap:41px; | |||
|
397 | -webkit-column-gap:41px; | |||
|
398 | -moz-column-gap:41px; | |||
|
399 | ||||
|
400 | column-rule: 1px dashed #ccc; | |||
|
401 | -webkit-column-rule: 1px dashed #ccc; | |||
|
402 | -moz-column-rule: 1px dashed #ccc; | |||
|
403 | } | |||
|
404 | ||||
|
405 | .flowList dl{ | |||
|
406 | } | |||
|
407 | .flowList dd{ | |||
|
408 | /*display:inline-block;*/ | |||
|
409 | margin-left:10px; | |||
|
410 | min-width:250px; | |||
|
411 | line-height: 1.5; | |||
|
412 | min-width:100%; | |||
|
413 | min-height:15px; | |||
|
414 | } | |||
|
415 | ||||
|
416 | .flowList dd a{ | |||
|
417 | } | |||
|
418 | ||||
|
419 | .content .flowList p{ | |||
|
420 | padding:0px; | |||
|
421 | } | |||
|
422 | ||||
|
423 | .content .alignedsummary | |||
|
424 | { | |||
|
425 | margin: 15px; | |||
|
426 | } | |||
|
427 | ||||
|
428 | ||||
|
429 | .qmltype | |||
|
430 | { | |||
|
431 | text-align: center; | |||
|
432 | font-size: 120%; | |||
|
433 | } | |||
|
434 | .qmlreadonly | |||
|
435 | { | |||
|
436 | padding-left: 5px; | |||
|
437 | float: right; | |||
|
438 | color: #254117; | |||
|
439 | } | |||
|
440 | ||||
|
441 | .qmldefault | |||
|
442 | { | |||
|
443 | padding-left: 5px; | |||
|
444 | float: right; | |||
|
445 | color: red; | |||
|
446 | } | |||
|
447 | ||||
|
448 | .qmldoc | |||
|
449 | { | |||
|
450 | } | |||
|
451 | ||||
|
452 | .generic .alphaChar{ | |||
|
453 | margin-top:5px; | |||
|
454 | } | |||
|
455 | ||||
|
456 | .generic .odd .alphaChar{ | |||
|
457 | background-color: #F6F6F6; | |||
|
458 | } | |||
|
459 | ||||
|
460 | .generic .even .alphaChar{ | |||
|
461 | background-color: #FFFFFF; | |||
|
462 | } | |||
|
463 | ||||
|
464 | .memItemRight{ | |||
|
465 | padding: 0.25em 1.5em 0.25em 0; | |||
|
466 | } | |||
|
467 | .highlightedCode | |||
|
468 | { | |||
|
469 | margin: 1.0em; | |||
|
470 | } | |||
|
471 | .annotated td { | |||
|
472 | padding: 0.25em 0.5em 0.25em 0.5em; | |||
|
473 | } | |||
|
474 | ||||
|
475 | .header .content .toc ul | |||
|
476 | { | |||
|
477 | padding-left: 0px; | |||
|
478 | } | |||
|
479 | ||||
|
480 | .content .toc h3 { | |||
|
481 | border-bottom: 0px; | |||
|
482 | margin-top: 0px; | |||
|
483 | } | |||
|
484 | ||||
|
485 | .content .toc h3 a:hover { | |||
|
486 | color: #00732F; | |||
|
487 | text-decoration: none; | |||
|
488 | } | |||
|
489 | ||||
|
490 | .content .toc .level2 | |||
|
491 | { | |||
|
492 | margin-left: 1.5em; | |||
|
493 | } | |||
|
494 | ||||
|
495 | .content .toc .level3 | |||
|
496 | { | |||
|
497 | margin-left: 3.0em; | |||
|
498 | } | |||
|
499 | ||||
|
500 | .content ul li | |||
|
501 | { | |||
|
502 | background: url(../images/bullet_sq.png) no-repeat 0 0.7em; | |||
|
503 | padding-left: 1em | |||
|
504 | } | |||
|
505 | ||||
|
506 | .content .toc li | |||
|
507 | { | |||
|
508 | background: url(../images/bullet_dn.png) no-repeat 0 5px; | |||
|
509 | padding-left: 1em | |||
|
510 | } | |||
|
511 | ||||
|
512 | .relpage | |||
|
513 | { | |||
|
514 | -moz-border-radius: 7px 7px 7px 7px; | |||
|
515 | -webkit-border-radius: 7px 7px 7px 7px; | |||
|
516 | border-radius: 7px 7px 7px 7px; | |||
|
517 | border: 1px solid #DDDDDD; | |||
|
518 | padding: 25px 25px; | |||
|
519 | clear: both; | |||
|
520 | } | |||
|
521 | .relpage ul | |||
|
522 | { | |||
|
523 | float: none; | |||
|
524 | padding: 1.5em; | |||
|
525 | } | |||
|
526 | ||||
|
527 | h3.fn, span.fn | |||
|
528 | { | |||
|
529 | -moz-border-radius:7px 7px 7px 7px; | |||
|
530 | -webkit-border-radius:7px 7px 7px 7px; | |||
|
531 | border-radius:7px 7px 7px 7px; | |||
|
532 | background-color: #F6F6F6; | |||
|
533 | border-width: 1px; | |||
|
534 | border-style: solid; | |||
|
535 | border-color: #E6E6E6; | |||
|
536 | font-weight: bold; | |||
|
537 | word-spacing:3px; | |||
|
538 | padding:3px 5px; | |||
|
539 | } | |||
|
540 | ||||
|
541 | .functionIndex { | |||
|
542 | font-size:12pt; | |||
|
543 | word-spacing:10px; | |||
|
544 | margin-bottom:10px; | |||
|
545 | background-color: #F6F6F6; | |||
|
546 | border-width: 1px; | |||
|
547 | border-style: solid; | |||
|
548 | border-color: #E6E6E6; | |||
|
549 | -moz-border-radius: 7px 7px 7px 7px; | |||
|
550 | -webkit-border-radius: 7px 7px 7px 7px; | |||
|
551 | border-radius: 7px 7px 7px 7px; | |||
|
552 | width:100%; | |||
|
553 | } | |||
|
554 | ||||
|
555 | .centerAlign | |||
|
556 | { | |||
|
557 | text-align:center; | |||
|
558 | } | |||
|
559 | ||||
|
560 | .rightAlign | |||
|
561 | { | |||
|
562 | text-align:right; | |||
|
563 | } | |||
|
564 | ||||
|
565 | .leftAlign | |||
|
566 | { | |||
|
567 | text-align:left; | |||
|
568 | } | |||
|
569 | ||||
|
570 | .topAlign{ | |||
|
571 | vertical-align:top | |||
|
572 | } | |||
|
573 | ||||
|
574 | .functionIndex a{ | |||
|
575 | display:inline-block; | |||
|
576 | } | |||
|
577 | ||||
|
578 | /* end content elements */ | |||
|
579 | /* footer elements */ | |||
|
580 | ||||
|
581 | .footer | |||
|
582 | { | |||
|
583 | color: #393735; | |||
|
584 | font-size: 0.75em; | |||
|
585 | text-align: center; | |||
|
586 | padding-top: 1.5em; | |||
|
587 | padding-bottom: 1em; | |||
|
588 | background-color: #E6E7E8; | |||
|
589 | margin: 0; | |||
|
590 | } | |||
|
591 | .footer p | |||
|
592 | { | |||
|
593 | margin: 0.25em | |||
|
594 | } | |||
|
595 | .small | |||
|
596 | { | |||
|
597 | font-size: 0.5em; | |||
|
598 | } | |||
|
599 | /* end footer elements */ | |||
|
600 | ||||
|
601 | .item { | |||
|
602 | float: left; | |||
|
603 | position: relative; | |||
|
604 | width: 100%; | |||
|
605 | overflow: hidden; | |||
|
606 | } | |||
|
607 | ||||
|
608 | ||||
|
609 | .item .primary { | |||
|
610 | margin-right: 220px; | |||
|
611 | position: relative; | |||
|
612 | } | |||
|
613 | ||||
|
614 | .item hr { | |||
|
615 | margin-left: -220px; | |||
|
616 | } | |||
|
617 | ||||
|
618 | .item .secondary { | |||
|
619 | float: right; | |||
|
620 | width: 200px; | |||
|
621 | position: relative; | |||
|
622 | } | |||
|
623 | ||||
|
624 | .item .cols { | |||
|
625 | clear: both; | |||
|
626 | display: block; | |||
|
627 | } | |||
|
628 | ||||
|
629 | .item .cols .col { | |||
|
630 | float: left; | |||
|
631 | margin-left: 1.5%; | |||
|
632 | } | |||
|
633 | ||||
|
634 | .item .cols .col.first { | |||
|
635 | margin-left: 0; | |||
|
636 | } | |||
|
637 | ||||
|
638 | .item .cols.two .col { | |||
|
639 | width: 45%; | |||
|
640 | } | |||
|
641 | ||||
|
642 | .item .box { | |||
|
643 | margin: 0 0 10px 0; | |||
|
644 | } | |||
|
645 | ||||
|
646 | .item .box h3 { | |||
|
647 | margin: 0 0 10px 0; | |||
|
648 | } | |||
|
649 | ||||
|
650 | .cols.unclear { | |||
|
651 | clear:none; | |||
|
652 | } | |||
|
653 | } | |||
|
654 | ||||
|
655 | /* end of screen media */ | |||
|
656 | ||||
|
657 | /* start of print media */ | |||
|
658 | ||||
|
659 | @media print | |||
|
660 | { | |||
|
661 | input, textarea, .header, .footer, .toolbar, .feedback, .wrapper .hd, .wrapper .bd .sidebar, .wrapper .ft, #feedbackBox, #blurpage, .toc, .breadcrumb, .toolbar, .floatingResult | |||
|
662 | { | |||
|
663 | display: none; | |||
|
664 | background: none; | |||
|
665 | } | |||
|
666 | .content | |||
|
667 | { | |||
|
668 | background: none; | |||
|
669 | display: block; | |||
|
670 | width: 100%; margin: 0; float: none; | |||
|
671 | } | |||
|
672 | } | |||
|
673 | /* end of print media */ |
@@ -0,0 +1,64 | |||||
|
1 | #include "barvalue_p.h" | |||
|
2 | #include <QPainter> | |||
|
3 | #include <QPen> | |||
|
4 | ||||
|
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
6 | ||||
|
7 | BarValue::BarValue(QBarSet &set, QGraphicsItem *parent) | |||
|
8 | : QGraphicsItem(parent) | |||
|
9 | ,mBarSet(set) | |||
|
10 | { | |||
|
11 | // setVisible(false); | |||
|
12 | } | |||
|
13 | ||||
|
14 | void BarValue::setValueString(QString str) | |||
|
15 | { | |||
|
16 | mValueString = str; | |||
|
17 | } | |||
|
18 | ||||
|
19 | QString BarValue::valueString() | |||
|
20 | { | |||
|
21 | return mValueString; | |||
|
22 | } | |||
|
23 | ||||
|
24 | void BarValue::setPen(const QPen& pen) | |||
|
25 | { | |||
|
26 | mPen = pen; | |||
|
27 | } | |||
|
28 | ||||
|
29 | const QPen& BarValue::pen() | |||
|
30 | { | |||
|
31 | return mPen; | |||
|
32 | } | |||
|
33 | ||||
|
34 | void BarValue::resize(qreal w, qreal h) | |||
|
35 | { | |||
|
36 | mWidth = w; | |||
|
37 | mHeight = h; | |||
|
38 | } | |||
|
39 | ||||
|
40 | void BarValue::setPos(qreal x, qreal y) | |||
|
41 | { | |||
|
42 | mXpos = x; | |||
|
43 | mYpos = y; | |||
|
44 | } | |||
|
45 | ||||
|
46 | bool BarValue::belongsToSet(QBarSet *set) | |||
|
47 | { | |||
|
48 | return (&mBarSet == set); | |||
|
49 | } | |||
|
50 | ||||
|
51 | void BarValue::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |||
|
52 | { | |||
|
53 | painter->setPen(mPen); | |||
|
54 | painter->drawText(boundingRect(),mValueString); | |||
|
55 | } | |||
|
56 | ||||
|
57 | QRectF BarValue::boundingRect() const | |||
|
58 | { | |||
|
59 | QRectF r(mXpos, mYpos, mXpos + mWidth, mYpos + mHeight); | |||
|
60 | return r; | |||
|
61 | } | |||
|
62 | ||||
|
63 | ||||
|
64 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,49 | |||||
|
1 | #ifndef BARVALUE_P_H | |||
|
2 | #define BARVALUE_P_H | |||
|
3 | ||||
|
4 | #include "qchartglobal.h" | |||
|
5 | #include <QGraphicsItem> | |||
|
6 | #include <QPen> | |||
|
7 | ||||
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
9 | ||||
|
10 | class QBarSet; | |||
|
11 | ||||
|
12 | // Visual class for floating bar values | |||
|
13 | // TODO: fonts, colors etc. | |||
|
14 | // By default these are not visible. | |||
|
15 | class BarValue : public QGraphicsItem // TODO: public QGraphicsObject for signals? | |||
|
16 | { | |||
|
17 | public: | |||
|
18 | BarValue(QBarSet &set, QGraphicsItem *parent = 0); | |||
|
19 | ||||
|
20 | void setValueString(QString str); | |||
|
21 | QString valueString(); | |||
|
22 | ||||
|
23 | void setPen(const QPen& pen); | |||
|
24 | const QPen& pen(); | |||
|
25 | ||||
|
26 | void resize(qreal w, qreal h); | |||
|
27 | void setPos(qreal x, qreal y); | |||
|
28 | ||||
|
29 | bool belongsToSet(QBarSet *set); | |||
|
30 | ||||
|
31 | // From QGraphicsItem | |||
|
32 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | |||
|
33 | QRectF boundingRect() const; | |||
|
34 | ||||
|
35 | private: | |||
|
36 | ||||
|
37 | QBarSet& mBarSet; | |||
|
38 | QPen mPen; | |||
|
39 | QString mValueString; | |||
|
40 | ||||
|
41 | qreal mXpos; | |||
|
42 | qreal mYpos; | |||
|
43 | qreal mWidth; | |||
|
44 | qreal mHeight; | |||
|
45 | }; | |||
|
46 | ||||
|
47 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
48 | ||||
|
49 | #endif // BARVALUE_P_H |
@@ -0,0 +1,17 | |||||
|
1 | import QtQuick 1.0 | |||
|
2 | ||||
|
3 | Item { | |||
|
4 | id: container | |||
|
5 | width: 400 | |||
|
6 | height: 500 | |||
|
7 | Component.onCompleted: { | |||
|
8 | var co = Qt.createComponent("main.qml") | |||
|
9 | if (co.status == Component.Ready) { | |||
|
10 | var o = co.createObject(container) | |||
|
11 | } else { | |||
|
12 | console.log(co.errorString()) | |||
|
13 | console.log("QtCommercial.Chart 1.1 not available") | |||
|
14 | console.log("Please use correct QML_IMPORT_PATH export") | |||
|
15 | } | |||
|
16 | } | |||
|
17 | } No newline at end of file |
@@ -0,0 +1,6 | |||||
|
1 | <RCC> | |||
|
2 | <qresource prefix="/"> | |||
|
3 | <file>qml/qmlchart/loader.qml</file> | |||
|
4 | <file>qml/qmlchart/main.qml</file> | |||
|
5 | </qresource> | |||
|
6 | </RCC> |
@@ -5,6 +5,7 CHART_BUILD_PRIVATE_HEADER_DIR = $$CHART_BUILD_PUBLIC_HEADER_DIR/private | |||||
5 | CHART_BUILD_LIB_DIR = $$PWD/lib |
|
5 | CHART_BUILD_LIB_DIR = $$PWD/lib | |
6 | CHART_BUILD_DIR = $$PWD/build |
|
6 | CHART_BUILD_DIR = $$PWD/build | |
7 | CHART_BUILD_BIN_DIR = $$PWD/bin |
|
7 | CHART_BUILD_BIN_DIR = $$PWD/bin | |
|
8 | CHART_BUILD_PLUGIN_DIR = $$CHART_BUILD_LIB_DIR/QtCommercial/Chart | |||
8 |
|
9 | |||
9 | # hack to fix windows builds |
|
10 | # hack to fix windows builds | |
10 | win32:{ |
|
11 | win32:{ | |
@@ -13,6 +14,7 win32:{ | |||||
13 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") |
|
14 | CHART_BUILD_LIB_DIR = $$replace(CHART_BUILD_LIB_DIR, "/","\\") | |
14 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") |
|
15 | CHART_BUILD_BUILD_DIR = $$replace(CHART_BUILD_BUILD_DIR, "/","\\") | |
15 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") |
|
16 | CHART_BUILD_BIN_DIR = $$replace(CHART_BUILD_BIN_DIR, "/","\\") | |
|
17 | CHART_BUILD_PLUGIN_DIR = $$replace(CHART_BUILD_PLUGIN_DIR, "/","\\") | |||
16 | } |
|
18 | } | |
17 |
|
19 | |||
18 | mac: { |
|
20 | mac: { |
@@ -1,6 +1,7 | |||||
1 | /*! |
|
1 | /*! | |
2 | \class Widget |
|
2 | \class Widget | |
3 | \brief Ui for the application. |
|
3 | \brief Ui for the application. | |
|
4 | \internal | |||
4 | */ |
|
5 | */ | |
5 |
|
6 | |||
6 | #include "widget.h" |
|
7 | #include "widget.h" |
@@ -43,7 +43,9 m_index(0) | |||||
43 |
|
43 | |||
44 | ChartView::~ChartView() |
|
44 | ChartView::~ChartView() | |
45 | { |
|
45 | { | |
46 |
|
46 | if(m_series.size()==0) return; | ||
|
47 | removeSeries(m_series.at(m_index)); | |||
|
48 | qDeleteAll(m_series); | |||
47 | } |
|
49 | } | |
48 |
|
50 | |||
49 | void ChartView::handleTimeout() |
|
51 | void ChartView::handleTimeout() |
@@ -1,6 +1,5 | |||||
1 | #include <QtGui/QApplication> |
|
1 | #include <QtGui/QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <cmath> |
|
|||
4 | #include <qchartglobal.h> |
|
3 | #include <qchartglobal.h> | |
5 | #include <qchartview.h> |
|
4 | #include <qchartview.h> | |
6 | #include <qscatterseries.h> |
|
5 | #include <qscatterseries.h> | |
@@ -12,7 +11,7 int main(int argc, char *argv[]) | |||||
12 | QApplication a(argc, argv); |
|
11 | QApplication a(argc, argv); | |
13 |
|
12 | |||
14 | // Create chart widget |
|
13 | // Create chart widget | |
15 |
QChartView *chart |
|
14 | QChartView *chartView = new QChartView(); | |
16 |
|
15 | |||
17 | // Add scatter series with simple test data |
|
16 | // Add scatter series with simple test data | |
18 | QScatterSeries *scatter = new QScatterSeries(); |
|
17 | QScatterSeries *scatter = new QScatterSeries(); | |
@@ -23,34 +22,27 int main(int argc, char *argv[]) | |||||
23 | << QPointF(2.0, 4.5) |
|
22 | << QPointF(2.0, 4.5) | |
24 | << QPointF(2.0, 5.5) |
|
23 | << QPointF(2.0, 5.5) | |
25 | << QPointF(2.5, 5.0); |
|
24 | << QPointF(2.5, 5.0); | |
26 | chartWidget->addSeries(scatter); |
|
25 | // Chart takes ownership | |
|
26 | chartView->addSeries(scatter); | |||
27 |
|
27 | |||
28 | // Add another scatter series |
|
28 | // Add another scatter series | |
29 | // - more data with random component |
|
29 | // - more data with random component | |
30 | QScatterSeries *scatter2 = new QScatterSeries(); |
|
30 | QScatterSeries *scatter2 = new QScatterSeries(); | |
31 |
for (qreal i(0.0); i < 20; i += 0. |
|
31 | for (qreal i(0.0); i < 20; i += 0.15) { | |
32 | (*scatter2) << QPointF(i + (qreal)(rand() % 100) / 100.0, |
|
32 | (*scatter2) << QPointF(i + (qreal)(rand() % 100) / 100.0, | |
33 | i + (qreal)(rand() % 100) / 100.0); |
|
33 | i + (qreal)(rand() % 100) / 100.0); | |
34 | } |
|
34 | } | |
35 | chartWidget->addSeries(scatter2); |
|
35 | QBrush brush(QColor(255, 0, 0, 100), Qt::SolidPattern); | |
36 | // Custom pen and brush (not those defined by the chart theme) |
|
|||
37 | // - uses opaque color |
|
|||
38 | QColor color("#2685BF"); |
|
|||
39 | color.setAlpha(80); |
|
|||
40 | QBrush brush(Qt::SolidPattern); |
|
|||
41 | brush.setColor(color); |
|
|||
42 | scatter2->setMarkerBrush(brush); |
|
36 | scatter2->setMarkerBrush(brush); | |
43 | QPen pen; |
|
37 | QPen pen(QColor(0, 255, 0, 80), 3); | |
44 | pen.setColor(color); |
|
|||
45 | pen.setWidth(2); |
|
|||
46 | scatter2->setMarkerPen(pen); |
|
38 | scatter2->setMarkerPen(pen); | |
47 | // use a rectangle as the marker shape |
|
|||
48 | scatter2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); |
|
39 | scatter2->setMarkerShape(QScatterSeries::MarkerShapeRectangle); | |
|
40 | chartView->addSeries(scatter2); | |||
49 |
|
41 | |||
50 | // Use the chart widget as the central widget |
|
42 | // Use the chart widget as the central widget | |
51 | QMainWindow w; |
|
43 | QMainWindow w; | |
52 | w.resize(640, 480); |
|
44 | w.resize(640, 480); | |
53 |
w.setCentralWidget(chart |
|
45 | w.setCentralWidget(chartView); | |
54 | w.show(); |
|
46 | w.show(); | |
55 |
|
47 | |||
56 | return a.exec(); |
|
48 | return a.exec(); |
@@ -7,7 +7,7 | |||||
7 |
|
7 | |||
8 | TEMPLATE = lib |
|
8 | TEMPLATE = lib | |
9 | TARGET = qtcommercialchartqml |
|
9 | TARGET = qtcommercialchartqml | |
10 |
|
10 | DESTDIR = $$CHART_BUILD_PLUGIN_DIR | ||
11 | CONFIG += qt plugin |
|
11 | CONFIG += qt plugin | |
12 | QT += declarative |
|
12 | QT += declarative | |
13 |
|
13 | |||
@@ -16,10 +16,10 contains(QT_MAJOR_VERSION, 5) { | |||||
16 | DEFINES += QTQUICK2 |
|
16 | DEFINES += QTQUICK2 | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 |
OBJECTS_DIR = $$CHART_BUILD_DIR/ |
|
19 | OBJECTS_DIR = $$CHART_BUILD_DIR/plugin | |
20 |
MOC_DIR = $$CHART_BUILD_DIR/ |
|
20 | MOC_DIR = $$CHART_BUILD_DIR/plugin | |
21 |
UI_DIR = $$CHART_BUILD_DIR/ |
|
21 | UI_DIR = $$CHART_BUILD_DIR/plugin | |
22 |
RCC_DIR = $$CHART_BUILD_DIR/ |
|
22 | RCC_DIR = $$CHART_BUILD_DIR/plugin | |
23 |
|
23 | |||
24 | SOURCES += \ |
|
24 | SOURCES += \ | |
25 | plugin.cpp \ |
|
25 | plugin.cpp \ | |
@@ -37,6 +37,8 HEADERS += \ | |||||
37 | declarativepieseries.h \ |
|
37 | declarativepieseries.h \ | |
38 | declarativelineseries.h |
|
38 | declarativelineseries.h | |
39 |
|
39 | |||
|
40 | QMAKE_POST_LINK = $$QMAKE_COPY qmldir $$CHART_BUILD_PLUGIN_DIR | |||
|
41 | ||||
40 | TARGETPATH = QtCommercial/Chart |
|
42 | TARGETPATH = QtCommercial/Chart | |
41 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH |
|
43 | target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH | |
42 | qmldir.files += $$PWD/qmldir |
|
44 | qmldir.files += $$PWD/qmldir |
@@ -1,5 +1,6 | |||||
1 | #include "axisitem_p.h" |
|
1 | #include "axisitem_p.h" | |
2 | #include "qchartaxis.h" |
|
2 | #include "qchartaxis.h" | |
|
3 | #include "chartpresenter_p.h" | |||
3 | #include <QPainter> |
|
4 | #include <QPainter> | |
4 | #include <QDebug> |
|
5 | #include <QDebug> | |
5 |
|
6 | |||
@@ -14,11 +15,12 m_labelsAngle(0), | |||||
14 | m_shadesEnabled(true), |
|
15 | m_shadesEnabled(true), | |
15 | m_grid(parent), |
|
16 | m_grid(parent), | |
16 | m_shades(parent), |
|
17 | m_shades(parent), | |
17 | m_labels(parent) |
|
18 | m_labels(parent), | |
|
19 | m_origin(0,0) | |||
18 | { |
|
20 | { | |
19 | //initial initialization |
|
21 | //initial initialization | |
20 |
m_shades.setZValue( |
|
22 | m_shades.setZValue(ChartPresenter::ShadesZValue); | |
21 |
m_grid.setZValue( |
|
23 | m_grid.setZValue(ChartPresenter::GridZValue); | |
22 | } |
|
24 | } | |
23 |
|
25 | |||
24 | AxisItem::~AxisItem() |
|
26 | AxisItem::~AxisItem() | |
@@ -172,6 +174,7 void AxisItem::handleLabelsChanged(QChartAxis* axis,const QStringList& labels) | |||||
172 | clear(); |
|
174 | clear(); | |
173 | m_thicksList=labels; |
|
175 | m_thicksList=labels; | |
174 | createItems(m_thicksList.size()); |
|
176 | createItems(m_thicksList.size()); | |
|
177 | updateItem(m_thicksList.size()); | |||
175 | items = m_labels.childItems(); |
|
178 | items = m_labels.childItems(); | |
176 | handleAxisUpdate(axis); |
|
179 | handleAxisUpdate(axis); | |
177 | } |
|
180 | } | |
@@ -208,7 +211,6 void AxisItem::setGridOpacity(qreal opacity) | |||||
208 | m_grid.setOpacity(opacity); |
|
211 | m_grid.setOpacity(opacity); | |
209 | } |
|
212 | } | |
210 |
|
213 | |||
211 |
|
||||
212 | qreal AxisItem::gridOpacity() const |
|
214 | qreal AxisItem::gridOpacity() const | |
213 | { |
|
215 | { | |
214 | return m_grid.opacity(); |
|
216 | return m_grid.opacity(); |
@@ -50,9 +50,9 public: | |||||
50 | void setLabelsFont(const QFont& font); |
|
50 | void setLabelsFont(const QFont& font); | |
51 |
|
51 | |||
52 | public slots: |
|
52 | public slots: | |
53 | void handleAxisUpdate(QChartAxis* axis); |
|
53 | void handleAxisUpdate(QChartAxis* axis); //look and feel | |
54 | void handleLabelsChanged(QChartAxis* axis,const QStringList& labels); |
|
54 | void handleLabelsChanged(QChartAxis* axis,const QStringList& labels); //labels from dataset | |
55 | void handleGeometryChanged(const QRectF& size); |
|
55 | void handleGeometryChanged(const QRectF& size); // geometry from presenter | |
56 | protected: |
|
56 | protected: | |
57 | void updateItem(int count); |
|
57 | void updateItem(int count); | |
58 | private: |
|
58 | private: | |
@@ -68,6 +68,7 private: | |||||
68 | QGraphicsItemGroup m_labels; |
|
68 | QGraphicsItemGroup m_labels; | |
69 | QGraphicsLineItem m_axis; |
|
69 | QGraphicsLineItem m_axis; | |
70 | QStringList m_thicksList; |
|
70 | QStringList m_thicksList; | |
|
71 | QPointF m_origin; | |||
71 |
|
72 | |||
72 | }; |
|
73 | }; | |
73 |
|
74 |
@@ -5,8 +5,9 | |||||
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
6 |
|
6 | |||
7 | Bar::Bar(QGraphicsItem *parent) |
|
7 | Bar::Bar(QGraphicsItem *parent) | |
8 |
: |
|
8 | : QGraphicsObject(parent) | |
9 | { |
|
9 | { | |
|
10 | setAcceptedMouseButtons(Qt::LeftButton); | |||
10 | } |
|
11 | } | |
11 |
|
12 | |||
12 | void Bar::setSize(const QSizeF& size) |
|
13 | void Bar::setSize(const QSizeF& size) | |
@@ -18,7 +19,6 void Bar::setSize(const QSizeF& size) | |||||
18 |
|
19 | |||
19 | void Bar::resize( qreal w, qreal h ) |
|
20 | void Bar::resize( qreal w, qreal h ) | |
20 | { |
|
21 | { | |
21 | // qDebug() << "bar::resize" << w << h; |
|
|||
22 | mWidth = w; |
|
22 | mWidth = w; | |
23 | mHeight = h; |
|
23 | mHeight = h; | |
24 | } |
|
24 | } | |
@@ -30,7 +30,6 void Bar::setColor( QColor col ) | |||||
30 |
|
30 | |||
31 | void Bar::setPos(qreal x, qreal y) |
|
31 | void Bar::setPos(qreal x, qreal y) | |
32 | { |
|
32 | { | |
33 | // qDebug() << "Bar::setpos" << x << y; |
|
|||
34 | mXpos = x; |
|
33 | mXpos = x; | |
35 | mYpos = y; |
|
34 | mYpos = y; | |
36 | } |
|
35 | } | |
@@ -50,10 +49,7 void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidg | |||||
50 | if (0 == mHeight) { |
|
49 | if (0 == mHeight) { | |
51 | return; |
|
50 | return; | |
52 | } |
|
51 | } | |
53 | // TODO: accept brush instead of color |
|
|||
54 | painter->setBrush(mBrush); |
|
52 | painter->setBrush(mBrush); | |
55 | // QBrush brush(mColor); |
|
|||
56 | // painter->setBrush(brush); |
|
|||
57 |
|
53 | |||
58 | // This compensates for rounding errors. drawRect takes ints and cumulative error of pos + size may be over 1. |
|
54 | // This compensates for rounding errors. drawRect takes ints and cumulative error of pos + size may be over 1. | |
59 | int x0 = mXpos; |
|
55 | int x0 = mXpos; | |
@@ -71,6 +67,11 QRectF Bar::boundingRect() const | |||||
71 | return r; |
|
67 | return r; | |
72 | } |
|
68 | } | |
73 |
|
69 | |||
74 | //#include "moc_bar_p.cpp" |
|
70 | void Bar::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) | |
|
71 | { | |||
|
72 | emit clicked(); | |||
|
73 | } | |||
|
74 | ||||
|
75 | #include "moc_bar_p.cpp" | |||
75 |
|
76 | |||
76 | QTCOMMERCIALCHART_END_NAMESPACE |
|
77 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,17 +1,17 | |||||
1 | #ifndef BAR_H |
|
1 | #ifndef BAR_H | |
2 | #define BAR_H |
|
2 | #define BAR_H | |
3 |
|
3 | |||
4 | #include "chartitem_p.h" |
|
|||
5 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
6 |
#include <QGraphics |
|
5 | #include <QGraphicsObject> | |
7 | #include <QPen> |
|
6 | #include <QPen> | |
8 | #include <QBrush> |
|
7 | #include <QBrush> | |
9 |
|
8 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
10 | |||
12 | // Single bar item of chart |
|
11 | // Single bar item of chart | |
13 |
class Bar : public |
|
12 | class Bar : public QGraphicsObject | |
14 | { |
|
13 | { | |
|
14 | Q_OBJECT | |||
15 | public: |
|
15 | public: | |
16 | Bar(QGraphicsItem *parent=0); |
|
16 | Bar(QGraphicsItem *parent=0); | |
17 |
|
17 | |||
@@ -30,6 +30,10 public: | |||||
30 |
|
30 | |||
31 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
31 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | |
32 | QRectF boundingRect() const; |
|
32 | QRectF boundingRect() const; | |
|
33 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | |||
|
34 | ||||
|
35 | Q_SIGNALS: | |||
|
36 | void clicked(); | |||
33 |
|
37 | |||
34 | private: |
|
38 | private: | |
35 |
|
39 |
@@ -14,7 +14,8 SOURCES += \ | |||||
14 | $$PWD/qpercentbarchartseries.cpp \ |
|
14 | $$PWD/qpercentbarchartseries.cpp \ | |
15 | $$PWD/qstackedbarchartseries.cpp \ |
|
15 | $$PWD/qstackedbarchartseries.cpp \ | |
16 | $$PWD/separator.cpp \ |
|
16 | $$PWD/separator.cpp \ | |
17 | $$PWD/stackedbarpresenter.cpp |
|
17 | $$PWD/stackedbarpresenter.cpp \ | |
|
18 | $$PWD/barvalue.cpp | |||
18 |
|
19 | |||
19 | PRIVATE_HEADERS += \ |
|
20 | PRIVATE_HEADERS += \ | |
20 | $$PWD/bar_p.h \ |
|
21 | $$PWD/bar_p.h \ | |
@@ -24,12 +25,14 PRIVATE_HEADERS += \ | |||||
24 | $$PWD/barpresenterbase.h \ |
|
25 | $$PWD/barpresenterbase.h \ | |
25 | $$PWD/percentbarpresenter.h \ |
|
26 | $$PWD/percentbarpresenter.h \ | |
26 | $$PWD/separator_p.h \ |
|
27 | $$PWD/separator_p.h \ | |
27 | $$PWD/stackedbarpresenter.h |
|
28 | $$PWD/stackedbarpresenter.h \ | |
28 |
|
29 | $$PWD/barvalue_p.h | ||
|
30 | ||||
29 | PUBLIC_HEADERS += \ |
|
31 | PUBLIC_HEADERS += \ | |
30 | $$PWD/qbarcategory.h \ |
|
32 | $$PWD/qbarcategory.h \ | |
31 | $$PWD/qbarchartseries.h \ |
|
33 | $$PWD/qbarchartseries.h \ | |
32 | $$PWD/qbarset.h \ |
|
34 | $$PWD/qbarset.h \ | |
33 | $$PWD/qpercentbarchartseries.h \ |
|
35 | $$PWD/qpercentbarchartseries.h \ | |
34 | $$PWD/qstackedbarchartseries.h |
|
36 | $$PWD/qstackedbarchartseries.h | |
35 | No newline at end of file |
|
37 | ||
|
38 |
@@ -134,14 +134,34 qreal BarChartModel::valueAt(int set, int category) | |||||
134 | return mDataModel.at(set)->valueAt(category); |
|
134 | return mDataModel.at(set)->valueAt(category); | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 |
qreal BarChartModel::cat |
|
137 | qreal BarChartModel::percentageAt(int set, int category) | |
|
138 | { | |||
|
139 | if ((set < 0) || (set >= mDataModel.count())) { | |||
|
140 | // No set, no value. | |||
|
141 | return 0; | |||
|
142 | } else if ((category < 0) || (category >= mDataModel.at(set)->count())) { | |||
|
143 | // No category, no value. | |||
|
144 | return 0; | |||
|
145 | } | |||
|
146 | ||||
|
147 | qreal value = mDataModel.at(set)->valueAt(category); | |||
|
148 | qreal total = categorySum(category); | |||
|
149 | if (0 == total) { | |||
|
150 | return 100.0; | |||
|
151 | } | |||
|
152 | ||||
|
153 | return value / total; | |||
|
154 | } | |||
|
155 | ||||
|
156 | ||||
|
157 | qreal BarChartModel::categorySum(int category) | |||
138 | { |
|
158 | { | |
139 | qreal sum(0); |
|
159 | qreal sum(0); | |
140 |
int count = mDataModel.count(); // Count |
|
160 | int count = mDataModel.count(); // Count sets | |
141 |
|
161 | |||
142 |
for (int |
|
162 | for (int set = 0; set < count; set++) { | |
143 |
if (c |
|
163 | if (category < mDataModel.at(set)->count()) { | |
144 |
sum += mDataModel.at( |
|
164 | sum += mDataModel.at(set)->valueAt(category); | |
145 | } |
|
165 | } | |
146 | } |
|
166 | } | |
147 | return sum; |
|
167 | return sum; |
@@ -33,8 +33,9 public: | |||||
33 | qreal max(); // Maximum value of all sets |
|
33 | qreal max(); // Maximum value of all sets | |
34 | qreal min(); // Minimum value of all sets |
|
34 | qreal min(); // Minimum value of all sets | |
35 | qreal valueAt(int set, int category); |
|
35 | qreal valueAt(int set, int category); | |
|
36 | qreal percentageAt(int set, int category); | |||
36 |
|
37 | |||
37 |
qreal categorySum(int c |
|
38 | qreal categorySum(int category); | |
38 | qreal maxCategorySum(); // returns maximum sum of sets in all categories. |
|
39 | qreal maxCategorySum(); // returns maximum sum of sets in all categories. | |
39 |
|
40 | |||
40 | QString label(int category); |
|
41 | QString label(int category); |
@@ -1,6 +1,7 | |||||
1 | #include "barpresenter.h" |
|
1 | #include "barpresenter.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
3 | #include "barlabel_p.h" |
|
3 | #include "barlabel_p.h" | |
|
4 | #include "barvalue_p.h" | |||
4 | #include "qbarset.h" |
|
5 | #include "qbarset.h" | |
5 | #include <QDebug> |
|
6 | #include <QDebug> | |
6 |
|
7 | |||
@@ -9,12 +10,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
9 | BarPresenter::BarPresenter(BarChartModel& model, QGraphicsItem *parent) : |
|
10 | BarPresenter::BarPresenter(BarChartModel& model, QGraphicsItem *parent) : | |
10 | BarPresenterBase(model,parent) |
|
11 | BarPresenterBase(model,parent) | |
11 | { |
|
12 | { | |
12 | mBarDefaultWidth = 5; |
|
13 | mBarDefaultWidth = 15; | |
13 | } |
|
14 | } | |
14 |
|
15 | |||
15 | void BarPresenter::layoutChanged() |
|
16 | void BarPresenter::layoutChanged() | |
16 | { |
|
17 | { | |
17 | // qDebug() << "BarGroup::layoutChanged"; |
|
|||
18 | // Scale bars to new layout |
|
18 | // Scale bars to new layout | |
19 | // Layout for bars: |
|
19 | // Layout for bars: | |
20 | if (mModel.countSets() <= 0) { |
|
20 | if (mModel.countSets() <= 0) { | |
@@ -23,32 +23,32 void BarPresenter::layoutChanged() | |||||
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | if (childItems().count() == 0) { |
|
25 | if (childItems().count() == 0) { | |
26 |
qDebug() << "WARNING: Bar |
|
26 | qDebug() << "WARNING: BarPresenter::layoutChanged called before graphics items are created!"; | |
27 | return; |
|
27 | return; | |
28 | } |
|
28 | } | |
29 |
|
29 | |||
30 | // TODO: better way to auto-layout? |
|
30 | // TODO: better way to auto-layout? | |
31 | // Use reals for accurancy (we might get some compiler warnings... :) |
|
31 | // Use reals for accurancy (we might get some compiler warnings... :) | |
32 |
int |
|
32 | int categoryCount = mModel.countCategories(); | |
33 | int setCount = mModel.countSets(); |
|
33 | int setCount = mModel.countSets(); | |
34 |
|
34 | |||
35 | qreal tW = mWidth; |
|
35 | qreal tW = mWidth; | |
36 | qreal tH = mHeight; |
|
36 | qreal tH = mHeight; | |
37 | qreal tM = mModel.max(); |
|
37 | qreal tM = mModel.max(); | |
38 | qreal scale = (tH/tM); |
|
38 | qreal scale = (tH/tM); | |
39 |
qreal tC = |
|
39 | qreal tC = categoryCount+1; | |
40 | qreal xStepPerSet = (tW/tC); |
|
40 | qreal xStepPerSet = (tW/tC); | |
41 |
|
41 | |||
42 | // Scaling. |
|
42 | // Scaling. | |
43 | int itemIndex(0); |
|
43 | int itemIndex(0); | |
44 | int labelIndex = itemCount * setCount; |
|
44 | int labelIndex(0); | |
45 |
|
45 | |||
46 |
for (int |
|
46 | for (int category=0; category < categoryCount; category++) { | |
47 |
qreal xPos = xStepPerSet * |
|
47 | qreal xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2)); | |
48 | qreal yPos = mHeight; |
|
48 | qreal yPos = mHeight; | |
49 | for (int set = 0; set < setCount; set++) { |
|
49 | for (int set = 0; set < setCount; set++) { | |
50 |
qreal barHeight = mModel.valueAt(set, |
|
50 | qreal barHeight = mModel.valueAt(set, category) * scale; | |
51 |
Bar* bar = |
|
51 | Bar* bar = mBars.at(itemIndex); | |
52 |
|
52 | |||
53 | // TODO: width settable per bar? |
|
53 | // TODO: width settable per bar? | |
54 | bar->resize(mBarDefaultWidth, barHeight); |
|
54 | bar->resize(mBarDefaultWidth, barHeight); | |
@@ -59,12 +59,33 void BarPresenter::layoutChanged() | |||||
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | // TODO: Layout for labels, remove magic number |
|
61 | // TODO: Layout for labels, remove magic number | |
62 |
xPos = xStepPerSet * |
|
62 | xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2)); | |
63 |
BarLabel* label = |
|
63 | BarLabel* label = mLabels.at(labelIndex); | |
64 | label->setPos(xPos, mHeight + 20); |
|
64 | label->setPos(xPos, mHeight + 20); | |
65 | labelIndex++; |
|
65 | labelIndex++; | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
|
68 | // Position floating values | |||
|
69 | itemIndex = 0; | |||
|
70 | for (int category=0; category < mModel.countCategories(); category++) { | |||
|
71 | qreal xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2)); | |||
|
72 | qreal yPos = mHeight; | |||
|
73 | for (int set=0; set < mModel.countSets(); set++) { | |||
|
74 | qreal barHeight = mModel.valueAt(set,category) * scale; | |||
|
75 | BarValue* value = mFloatingValues.at(itemIndex); | |||
|
76 | ||||
|
77 | // TODO: remove hard coding, apply layout | |||
|
78 | value->resize(100,50); | |||
|
79 | value->setPos(xPos + mBarDefaultWidth/2, yPos-barHeight/2); | |||
|
80 | value->setPen(QPen(QColor(255,255,255,255))); | |||
|
81 | ||||
|
82 | QString vString(QString::number(mModel.valueAt(set,category))); | |||
|
83 | value->setValueString(vString); | |||
|
84 | ||||
|
85 | itemIndex++; | |||
|
86 | xPos += mBarDefaultWidth; | |||
|
87 | } | |||
|
88 | } | |||
68 | mLayoutDirty = true; |
|
89 | mLayoutDirty = true; | |
69 | } |
|
90 | } | |
70 |
|
91 |
@@ -7,8 +7,7 | |||||
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | // Base class for bar groups |
|
10 | // Presenter for parallel bars. Grouping of bars is done on category basis. | |
11 |
|
||||
12 | class BarPresenter : public BarPresenterBase |
|
11 | class BarPresenter : public BarPresenterBase | |
13 | { |
|
12 | { | |
14 | public: |
|
13 | public: |
@@ -1,5 +1,6 | |||||
1 | #include "barpresenterbase.h" |
|
1 | #include "barpresenterbase.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
|
3 | #include "barvalue_p.h" | |||
3 | #include "barlabel_p.h" |
|
4 | #include "barlabel_p.h" | |
4 | #include "separator_p.h" |
|
5 | #include "separator_p.h" | |
5 | #include "qbarset.h" |
|
6 | #include "qbarset.h" | |
@@ -12,7 +13,7 BarPresenterBase::BarPresenterBase(BarChartModel& model, QGraphicsItem *parent) | |||||
12 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready |
|
13 | ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready | |
13 | ,mLayoutSet(false) |
|
14 | ,mLayoutSet(false) | |
14 | ,mLayoutDirty(true) |
|
15 | ,mLayoutDirty(true) | |
15 |
,mSeparatorsVisible( |
|
16 | ,mSeparatorsVisible(false) | |
16 | ,mModel(model) |
|
17 | ,mModel(model) | |
17 | { |
|
18 | { | |
18 | dataChanged(); |
|
19 | dataChanged(); | |
@@ -25,9 +26,8 void BarPresenterBase::setSeparatorsVisible(bool visible) | |||||
25 |
|
26 | |||
26 | void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
27 | void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
27 | { |
|
28 | { | |
28 | // qDebug() << "BarGroupBase::paint" << childItems().count(); |
|
|||
29 | if (!mLayoutSet) { |
|
29 | if (!mLayoutSet) { | |
30 |
qDebug() << "Bar |
|
30 | qDebug() << "BarPresenterBase::paint called without layout set. Aborting."; | |
31 | return; |
|
31 | return; | |
32 | } |
|
32 | } | |
33 | // if (mLayoutDirty) { |
|
33 | // if (mLayoutDirty) { | |
@@ -51,51 +51,83 void BarPresenterBase::setBarWidth( int w ) | |||||
51 | void BarPresenterBase::dataChanged() |
|
51 | void BarPresenterBase::dataChanged() | |
52 | { |
|
52 | { | |
53 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? |
|
53 | // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? | |
54 |
|
54 | qDebug() << "datachanged"; | ||
55 | // Delete old bars |
|
55 | // Delete old bars | |
56 | foreach (QGraphicsItem* item, childItems()) { |
|
56 | foreach (QGraphicsItem* item, childItems()) { | |
57 | delete item; |
|
57 | delete item; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
|
60 | mBars.clear(); | |||
|
61 | mLabels.clear(); | |||
|
62 | mSeparators.clear(); | |||
|
63 | mFloatingValues.clear(); | |||
|
64 | ||||
60 | // Create new graphic items for bars |
|
65 | // Create new graphic items for bars | |
61 | for (int s=0; s<mModel.countSets(); s++) { |
|
66 | for (int s=0; s<mModel.countSets(); s++) { | |
62 | QBarSet *set = mModel.nextSet(0==s); |
|
67 | QBarSet *set = mModel.nextSet(0==s); | |
63 | for (int c=0; c<mModel.countCategories(); c++) { |
|
68 | for (int c=0; c<mModel.countCategories(); c++) { | |
64 | Bar *bar = new Bar(this); |
|
69 | Bar *bar = new Bar(this); | |
65 | childItems().append(bar); |
|
70 | childItems().append(bar); | |
66 | //connect(bar,SIGNAL(clicked()),set,SLOT(barClicked())); |
|
71 | mBars.append(bar); | |
|
72 | connect(bar,SIGNAL(clicked()),set,SLOT(toggleFloatingValuesVisible())); | |||
67 | } |
|
73 | } | |
68 | } |
|
74 | } | |
69 |
|
75 | |||
|
76 | // Create labels | |||
70 | int count = mModel.countCategories(); |
|
77 | int count = mModel.countCategories(); | |
71 | for (int i=0; i<count; i++) { |
|
78 | for (int i=0; i<count; i++) { | |
72 | BarLabel* label = new BarLabel(this); |
|
79 | BarLabel* label = new BarLabel(this); | |
73 | label->set(mModel.label(i)); |
|
80 | label->set(mModel.label(i)); | |
74 | childItems().append(label); |
|
81 | childItems().append(label); | |
|
82 | mLabels.append(label); | |||
75 | } |
|
83 | } | |
76 |
|
84 | |||
|
85 | // Create separators | |||
77 | count = mModel.countCategories() - 1; // There is one less separator than columns |
|
86 | count = mModel.countCategories() - 1; // There is one less separator than columns | |
78 | for (int i=0; i<count; i++) { |
|
87 | for (int i=0; i<count; i++) { | |
79 | Separator* sep = new Separator(this); |
|
88 | Separator* sep = new Separator(this); | |
80 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme |
|
89 | sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme | |
81 | childItems().append(sep); |
|
90 | childItems().append(sep); | |
|
91 | mSeparators.append(sep); | |||
|
92 | } | |||
|
93 | ||||
|
94 | // Create floating values | |||
|
95 | for (int s=0; s<mModel.countSets(); s++) { | |||
|
96 | QBarSet *set = mModel.nextSet(0==s); | |||
|
97 | for (int category=0; category<mModel.countCategories(); category++) { | |||
|
98 | BarValue *value = new BarValue(*set, this); | |||
|
99 | childItems().append(value); | |||
|
100 | mFloatingValues.append(value); | |||
|
101 | } | |||
|
102 | connect(set,SIGNAL(setFloatingValuesVisible(QBarSet*)),this,SLOT(setFloatingValues(QBarSet*))); | |||
82 | } |
|
103 | } | |
83 |
|
104 | |||
84 | // TODO: if (autolayout) { layoutChanged() } or something |
|
105 | // TODO: if (autolayout) { layoutChanged() } or something | |
85 | mLayoutDirty = true; |
|
106 | mLayoutDirty = true; | |
86 | } |
|
107 | } | |
87 |
|
108 | |||
|
109 | void BarPresenterBase::setFloatingValues(QBarSet *set) | |||
|
110 | { | |||
|
111 | qDebug() << "BarPresenterBase::setFloatingValues"; | |||
|
112 | // TODO: better way to map set to BarValues? | |||
|
113 | for (int i=0; i<mFloatingValues.count(); i++) { | |||
|
114 | if (mFloatingValues.at(i)->belongsToSet(set)) { | |||
|
115 | mFloatingValues.at(i)->setVisible(set->isFloatingValuesVisible()); | |||
|
116 | } | |||
|
117 | } | |||
|
118 | } | |||
|
119 | ||||
88 | //handlers |
|
120 | //handlers | |
89 |
|
121 | |||
90 | void BarPresenterBase::handleModelChanged(int index) |
|
122 | void BarPresenterBase::handleModelChanged(int index) | |
91 | { |
|
123 | { | |
92 |
// qDebug() << "Bar |
|
124 | // qDebug() << "BarPresenterBase::handleModelChanged" << index; | |
93 | dataChanged(); |
|
125 | dataChanged(); | |
94 | } |
|
126 | } | |
95 |
|
127 | |||
96 | void BarPresenterBase::handleDomainChanged(const Domain& domain) |
|
128 | void BarPresenterBase::handleDomainChanged(const Domain& domain) | |
97 | { |
|
129 | { | |
98 |
// qDebug() << "Bar |
|
130 | // qDebug() << "BarPresenterBase::handleDomainChanged"; | |
99 | // TODO: Figure out the use case for this. |
|
131 | // TODO: Figure out the use case for this. | |
100 | // Affects the size of visible item, so layout is changed. |
|
132 | // Affects the size of visible item, so layout is changed. | |
101 | // layoutChanged(); |
|
133 | // layoutChanged(); |
@@ -9,7 +9,12 | |||||
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | // Base Class for bar groups. Common implemantation of different groups. Not to be instantiated. |
|
12 | class Bar; | |
|
13 | class BarLabel; | |||
|
14 | class Separator; | |||
|
15 | class BarValue; | |||
|
16 | ||||
|
17 | // Common implemantation of different presenters. Not to be instantiated. | |||
13 | class BarPresenterBase : public QObject, public ChartItem |
|
18 | class BarPresenterBase : public QObject, public ChartItem | |
14 | { |
|
19 | { | |
15 | Q_OBJECT |
|
20 | Q_OBJECT | |
@@ -36,6 +41,9 public: | |||||
36 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes |
|
41 | virtual void dataChanged(); // data of series has changed -> need to recalculate bar sizes | |
37 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes |
|
42 | virtual void layoutChanged() = 0; // layout has changed -> need to recalculate bar sizes | |
38 |
|
43 | |||
|
44 | public Q_SLOTS: | |||
|
45 | void setFloatingValues(QBarSet *set); | |||
|
46 | ||||
39 | protected slots: |
|
47 | protected slots: | |
40 | void handleModelChanged(int index); |
|
48 | void handleModelChanged(int index); | |
41 | void handleDomainChanged(const Domain& domain); |
|
49 | void handleDomainChanged(const Domain& domain); | |
@@ -51,10 +59,15 protected: | |||||
51 | bool mLayoutSet; // True, if component has been laid out. |
|
59 | bool mLayoutSet; // True, if component has been laid out. | |
52 | bool mLayoutDirty; |
|
60 | bool mLayoutDirty; | |
53 |
|
61 | |||
54 | QList<QColor> mColors; // List of colors for series for now |
|
|||
55 | bool mSeparatorsVisible; |
|
62 | bool mSeparatorsVisible; | |
56 | BarChartModel& mModel; |
|
63 | BarChartModel& mModel; | |
57 |
|
64 | |||
|
65 | // Not owned. | |||
|
66 | QList<Bar*> mBars; | |||
|
67 | QList<BarLabel*> mLabels; | |||
|
68 | QList<Separator*> mSeparators; | |||
|
69 | QList<BarValue*> mFloatingValues; | |||
|
70 | ||||
58 | QPen mPen; |
|
71 | QPen mPen; | |
59 | }; |
|
72 | }; | |
60 |
|
73 |
@@ -1,6 +1,7 | |||||
1 | #include "percentbarpresenter.h" |
|
1 | #include "percentbarpresenter.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
3 | #include "barlabel_p.h" |
|
3 | #include "barlabel_p.h" | |
|
4 | #include "barvalue_p.h" | |||
4 | #include "separator_p.h" |
|
5 | #include "separator_p.h" | |
5 | #include "qbarset.h" |
|
6 | #include "qbarset.h" | |
6 | #include <QDebug> |
|
7 | #include <QDebug> | |
@@ -15,7 +16,6 PercentBarPresenter::PercentBarPresenter(BarChartModel& model, QGraphicsItem *pa | |||||
15 |
|
16 | |||
16 | void PercentBarPresenter::layoutChanged() |
|
17 | void PercentBarPresenter::layoutChanged() | |
17 | { |
|
18 | { | |
18 | // qDebug() << "PercentBarGroup::layoutChanged"; |
|
|||
19 | // Scale bars to new layout |
|
19 | // Scale bars to new layout | |
20 | // Layout for bars: |
|
20 | // Layout for bars: | |
21 | if (mModel.countSets() <= 0) { |
|
21 | if (mModel.countSets() <= 0) { | |
@@ -25,7 +25,7 void PercentBarPresenter::layoutChanged() | |||||
25 | } |
|
25 | } | |
26 |
|
26 | |||
27 | if (childItems().count() == 0) { |
|
27 | if (childItems().count() == 0) { | |
28 |
qDebug() << "WARNING: PercentBar |
|
28 | qDebug() << "WARNING: PercentBarPresenter::layoutChanged called before graphics items are created!"; | |
29 | return; |
|
29 | return; | |
30 | } |
|
30 | } | |
31 |
|
31 | |||
@@ -33,20 +33,20 void PercentBarPresenter::layoutChanged() | |||||
33 | // Use reals for accurancy (we might get some compiler warnings... :) |
|
33 | // Use reals for accurancy (we might get some compiler warnings... :) | |
34 | int count = mModel.countCategories(); |
|
34 | int count = mModel.countCategories(); | |
35 | int itemIndex(0); |
|
35 | int itemIndex(0); | |
|
36 | int labelIndex(0); | |||
36 | qreal tW = mWidth; |
|
37 | qreal tW = mWidth; | |
37 | qreal tC = count+1; |
|
38 | qreal tC = count+1; | |
38 | qreal xStep = (tW/tC); |
|
39 | qreal xStep = (tW/tC); | |
39 | qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); |
|
40 | qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); | |
40 | int labelIndex = mModel.countCategories() * mModel.countSets(); |
|
41 | qreal h = mHeight; | |
41 |
|
42 | |||
42 | for (int category = 0; category < mModel.countCategories(); category++) { |
|
43 | for (int category = 0; category < mModel.countCategories(); category++) { | |
43 | qreal colSum = mModel.categorySum(category); |
|
44 | qreal colSum = mModel.categorySum(category); | |
44 | qreal h = mHeight; |
|
|||
45 | qreal scale = (h / colSum); |
|
45 | qreal scale = (h / colSum); | |
46 | qreal yPos = h; |
|
46 | qreal yPos = h; | |
47 | for (int set=0; set < mModel.countSets(); set++) { |
|
47 | for (int set=0; set < mModel.countSets(); set++) { | |
48 | qreal barHeight = mModel.valueAt(set, category) * scale; |
|
48 | qreal barHeight = mModel.valueAt(set, category) * scale; | |
49 |
Bar* bar = |
|
49 | Bar* bar = mBars.at(itemIndex); | |
50 |
|
50 | |||
51 | // TODO: width settable per bar? |
|
51 | // TODO: width settable per bar? | |
52 | bar->resize(mBarDefaultWidth, barHeight); |
|
52 | bar->resize(mBarDefaultWidth, barHeight); | |
@@ -57,21 +57,44 void PercentBarPresenter::layoutChanged() | |||||
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | // TODO: Layout for labels, remove magic number |
|
59 | // TODO: Layout for labels, remove magic number | |
60 |
BarLabel* label = |
|
60 | BarLabel* label = mLabels.at(labelIndex); | |
61 | label->setPos(xPos, mHeight + 20); |
|
61 | label->setPos(xPos, mHeight + 20); | |
62 | labelIndex++; |
|
62 | labelIndex++; | |
63 | xPos += xStep; |
|
63 | xPos += xStep; | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | // Position separators |
|
66 | // Position separators | |
67 | int separatorIndex = labelIndex; // Separators are after labels in childItems(). TODO: better way to store these? |
|
67 | xPos = xStep + xStep/2; | |
68 | xPos = xStep + xStep/2; // Initial position is between first and second group. ie one and half steps from left. |
|
|||
69 | for (int s=0; s < mModel.countCategories() - 1; s++) { |
|
68 | for (int s=0; s < mModel.countCategories() - 1; s++) { | |
70 |
Separator* sep = |
|
69 | Separator* sep = mSeparators.at(s); | |
71 | sep->setPos(xPos,0); |
|
70 | sep->setPos(xPos,0); | |
72 | sep->setSize(QSizeF(1,mHeight)); |
|
71 | sep->setSize(QSizeF(1,mHeight)); | |
73 | xPos += xStep; |
|
72 | xPos += xStep; | |
74 | separatorIndex++; |
|
73 | } | |
|
74 | ||||
|
75 | // Position floating values | |||
|
76 | itemIndex = 0; | |||
|
77 | xPos = ((tW/tC) - mBarDefaultWidth / 2); | |||
|
78 | for (int category=0; category < mModel.countCategories(); category++) { | |||
|
79 | qreal yPos = h; | |||
|
80 | qreal colSum = mModel.categorySum(category); | |||
|
81 | qreal scale = (h / colSum); | |||
|
82 | for (int set=0; set < mModel.countSets(); set++) { | |||
|
83 | qreal barHeight = mModel.valueAt(set,category) * scale; | |||
|
84 | BarValue* value = mFloatingValues.at(itemIndex); | |||
|
85 | ||||
|
86 | // TODO: remove hard coding, apply layout | |||
|
87 | value->setPos(xPos + mBarDefaultWidth/2, yPos-barHeight/2); | |||
|
88 | value->setPen(QPen(QColor(255,255,255,255))); | |||
|
89 | ||||
|
90 | QString vString(QString::number(mModel.percentageAt(set,category) * 100)); | |||
|
91 | vString.append("%"); | |||
|
92 | value->setValueString(vString); | |||
|
93 | ||||
|
94 | itemIndex++; | |||
|
95 | yPos -= barHeight; | |||
|
96 | } | |||
|
97 | xPos += xStep; | |||
75 | } |
|
98 | } | |
76 |
|
99 | |||
77 | mLayoutDirty = true; |
|
100 | mLayoutDirty = true; |
@@ -5,6 +5,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
5 |
|
5 | |||
6 | QBarSet::QBarSet() |
|
6 | QBarSet::QBarSet() | |
7 | { |
|
7 | { | |
|
8 | mFloatingValuesVisible = false; | |||
8 | } |
|
9 | } | |
9 |
|
10 | |||
10 | void QBarSet::setName(QString name) |
|
11 | void QBarSet::setName(QString name) | |
@@ -57,11 +58,29 const QBrush& QBarSet::brush() const | |||||
57 | return mBrush; |
|
58 | return mBrush; | |
58 | } |
|
59 | } | |
59 |
|
60 | |||
|
61 | bool QBarSet::isFloatingValuesVisible() | |||
|
62 | { | |||
|
63 | return mFloatingValuesVisible; | |||
|
64 | } | |||
|
65 | ||||
60 | void QBarSet::barClicked() |
|
66 | void QBarSet::barClicked() | |
61 | { |
|
67 | { | |
|
68 | qDebug() << "QBarset::barClicked"; | |||
62 | // Some bar of this set has been clicked |
|
69 | // Some bar of this set has been clicked | |
63 | // TODO: What happens then? |
|
70 | // TODO: What happens then? | |
64 | qDebug() << "bar Clicked"; |
|
71 | emit clicked(); // Notify that set has been clicked | |
|
72 | } | |||
|
73 | ||||
|
74 | void QBarSet::toggleFloatingValuesVisible() | |||
|
75 | { | |||
|
76 | qDebug() << "QBarset::toggleFloatingValuesVisible"; | |||
|
77 | // TODO: toggle vs explicit set? | |||
|
78 | if (mFloatingValuesVisible) { | |||
|
79 | mFloatingValuesVisible=false; | |||
|
80 | } else { | |||
|
81 | mFloatingValuesVisible=true; | |||
|
82 | } | |||
|
83 | emit setFloatingValuesVisible(this); | |||
65 | } |
|
84 | } | |
66 |
|
85 | |||
67 |
|
86 |
@@ -27,7 +27,11 public: | |||||
27 | void setBrush(const QBrush& brush); |
|
27 | void setBrush(const QBrush& brush); | |
28 | const QBrush& brush() const; |
|
28 | const QBrush& brush() const; | |
29 |
|
29 | |||
30 | // void clicked(); |
|
30 | bool isFloatingValuesVisible(); | |
|
31 | ||||
|
32 | Q_SIGNALS: | |||
|
33 | void clicked(); | |||
|
34 | void setFloatingValuesVisible(QBarSet* set); | |||
31 | /* |
|
35 | /* | |
32 | void hoverEnter(); |
|
36 | void hoverEnter(); | |
33 | void hoverLeave(); |
|
37 | void hoverLeave(); | |
@@ -35,6 +39,7 public: | |||||
35 |
|
39 | |||
36 | public Q_SLOTS: |
|
40 | public Q_SLOTS: | |
37 | void barClicked(); |
|
41 | void barClicked(); | |
|
42 | void toggleFloatingValuesVisible(); | |||
38 |
|
43 | |||
39 | private: |
|
44 | private: | |
40 |
|
45 | |||
@@ -43,6 +48,7 private: | |||||
43 | QPen mPen; |
|
48 | QPen mPen; | |
44 | QBrush mBrush; |
|
49 | QBrush mBrush; | |
45 |
|
50 | |||
|
51 | bool mFloatingValuesVisible; | |||
46 | }; |
|
52 | }; | |
47 |
|
53 | |||
48 | QTCOMMERCIALCHART_END_NAMESPACE |
|
54 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,6 +1,7 | |||||
1 | #include "stackedbarpresenter.h" |
|
1 | #include "stackedbarpresenter.h" | |
2 | #include "bar_p.h" |
|
2 | #include "bar_p.h" | |
3 | #include "barlabel_p.h" |
|
3 | #include "barlabel_p.h" | |
|
4 | #include "barvalue_p.h" | |||
4 | #include "separator_p.h" |
|
5 | #include "separator_p.h" | |
5 | #include "qbarset.h" |
|
6 | #include "qbarset.h" | |
6 | #include <QDebug> |
|
7 | #include <QDebug> | |
@@ -14,7 +15,6 StackedBarPresenter::StackedBarPresenter(BarChartModel& model, QGraphicsItem *pa | |||||
14 |
|
15 | |||
15 | void StackedBarPresenter::layoutChanged() |
|
16 | void StackedBarPresenter::layoutChanged() | |
16 | { |
|
17 | { | |
17 | // qDebug() << "StackedBarGroup::layoutChanged"; |
|
|||
18 | // Scale bars to new layout |
|
18 | // Scale bars to new layout | |
19 | // Layout for bars: |
|
19 | // Layout for bars: | |
20 | if (mModel.countSets() <= 0) { |
|
20 | if (mModel.countSets() <= 0) { | |
@@ -30,7 +30,7 void StackedBarPresenter::layoutChanged() | |||||
30 | } |
|
30 | } | |
31 |
|
31 | |||
32 | if (childItems().count() == 0) { |
|
32 | if (childItems().count() == 0) { | |
33 |
qDebug() << "WARNING: StackedBar |
|
33 | qDebug() << "WARNING: StackedBarPresenter::layoutChanged called before graphics items are created!"; | |
34 | return; |
|
34 | return; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
@@ -42,17 +42,17 void StackedBarPresenter::layoutChanged() | |||||
42 | qreal scale = (h / maxSum); |
|
42 | qreal scale = (h / maxSum); | |
43 |
|
43 | |||
44 | int itemIndex(0); |
|
44 | int itemIndex(0); | |
|
45 | int labelIndex(0); | |||
45 | qreal tW = mWidth; |
|
46 | qreal tW = mWidth; | |
46 | qreal tC = mModel.countCategories() + 1; |
|
47 | qreal tC = mModel.countCategories() + 1; | |
47 | qreal xStep = (tW/tC); |
|
48 | qreal xStep = (tW/tC); | |
48 | qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); |
|
49 | qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); | |
49 | int labelIndex = mModel.countSets() * mModel.countCategories(); |
|
|||
50 |
|
50 | |||
51 | for (int category = 0; category < mModel.countCategories(); category++) { |
|
51 | for (int category = 0; category < mModel.countCategories(); category++) { | |
52 | qreal yPos = h; |
|
52 | qreal yPos = h; | |
53 | for (int set=0; set < mModel.countSets(); set++) { |
|
53 | for (int set=0; set < mModel.countSets(); set++) { | |
54 | qreal barHeight = mModel.valueAt(set, category) * scale; |
|
54 | qreal barHeight = mModel.valueAt(set, category) * scale; | |
55 |
Bar* bar = |
|
55 | Bar* bar = mBars.at(itemIndex); | |
56 |
|
56 | |||
57 | bar->resize(mBarDefaultWidth, barHeight); |
|
57 | bar->resize(mBarDefaultWidth, barHeight); | |
58 | bar->setBrush(mModel.setAt(set).brush()); |
|
58 | bar->setBrush(mModel.setAt(set).brush()); | |
@@ -62,21 +62,42 void StackedBarPresenter::layoutChanged() | |||||
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // TODO: Layout for labels, remove magic number |
|
64 | // TODO: Layout for labels, remove magic number | |
65 |
BarLabel* label = |
|
65 | BarLabel* label = mLabels.at(labelIndex); | |
66 | label->setPos(xPos, mHeight + 20); |
|
66 | label->setPos(xPos, mHeight + 20); | |
67 | labelIndex++; |
|
67 | labelIndex++; | |
68 | xPos += xStep; |
|
68 | xPos += xStep; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | // Position separators |
|
71 | // Position separators | |
72 | int separatorIndex = labelIndex; // Separators are after labels in childItems(). TODO: better way to store these? |
|
72 | xPos = xStep + xStep/2; | |
73 | xPos = xStep + xStep/2; // Initial position is between first and second group. ie one and half steps from left. |
|
|||
74 | for (int s=0; s < mModel.countCategories() - 1; s++) { |
|
73 | for (int s=0; s < mModel.countCategories() - 1; s++) { | |
75 |
Separator* sep = |
|
74 | Separator* sep = mSeparators.at(s); | |
76 | sep->setPos(xPos,0); |
|
75 | sep->setPos(xPos,0); | |
77 | sep->setSize(QSizeF(1,mHeight)); |
|
76 | sep->setSize(QSizeF(1,mHeight)); | |
78 | xPos += xStep; |
|
77 | xPos += xStep; | |
79 | separatorIndex++; |
|
78 | } | |
|
79 | ||||
|
80 | // Position floating values | |||
|
81 | itemIndex = 0; | |||
|
82 | xPos = ((tW/tC) - mBarDefaultWidth / 2); | |||
|
83 | for (int category=0; category < mModel.countCategories(); category++) { | |||
|
84 | qreal yPos = h; | |||
|
85 | for (int set=0; set < mModel.countSets(); set++) { | |||
|
86 | qreal barHeight = mModel.valueAt(set,category) * scale; | |||
|
87 | BarValue* value = mFloatingValues.at(itemIndex); | |||
|
88 | ||||
|
89 | // TODO: remove hard coding, apply layout | |||
|
90 | value->resize(100,50); | |||
|
91 | value->setPos(xPos + mBarDefaultWidth/2, yPos-barHeight/2); | |||
|
92 | value->setPen(QPen(QColor(255,255,255,255))); | |||
|
93 | ||||
|
94 | QString vString(QString::number(mModel.valueAt(set,category))); | |||
|
95 | value->setValueString(vString); | |||
|
96 | ||||
|
97 | itemIndex++; | |||
|
98 | yPos -= barHeight; | |||
|
99 | } | |||
|
100 | xPos += xStep; | |||
80 | } |
|
101 | } | |
81 |
|
102 | |||
82 | mLayoutDirty = true; |
|
103 | mLayoutDirty = true; |
@@ -1,5 +1,5 | |||||
1 |
#ifndef STACKEDBAR |
|
1 | #ifndef STACKEDBARPRESENTER_H | |
2 |
#define STACKEDBAR |
|
2 | #define STACKEDBARPRESENTER_H | |
3 |
|
3 | |||
4 | #include "barpresenterbase.h" |
|
4 | #include "barpresenterbase.h" | |
5 | #include "qstackedbarchartseries.h" |
|
5 | #include "qstackedbarchartseries.h" | |
@@ -13,7 +13,7 public: | |||||
13 | StackedBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); |
|
13 | StackedBarPresenter(BarChartModel& model, QGraphicsItem *parent = 0); | |
14 |
|
14 | |||
15 | private: |
|
15 | private: | |
16 |
// From Bar |
|
16 | // From BarPresenterBase | |
17 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes |
|
17 | void layoutChanged(); // layout has changed -> need to recalculate bar sizes | |
18 |
|
18 | |||
19 | private: |
|
19 | private: | |
@@ -23,4 +23,4 private: | |||||
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_END_NAMESPACE |
|
24 | QTCOMMERCIALCHART_END_NAMESPACE | |
25 |
|
25 | |||
26 |
#endif // STACKEDBAR |
|
26 | #endif // STACKEDBARPRESENTER_H |
@@ -168,16 +168,36 void ChartDataSet::removeSeries(QChartSeries* series) | |||||
168 | emit seriesRemoved(series); |
|
168 | emit seriesRemoved(series); | |
169 | m_seriesMap.remove(axis,series); |
|
169 | m_seriesMap.remove(axis,series); | |
170 | //remove axis if no longer there |
|
170 | //remove axis if no longer there | |
171 |
if(!m_seriesMap.contains(axis) |
|
171 | if(!m_seriesMap.contains(axis)){ | |
172 | emit axisRemoved(axis); |
|
172 | emit axisRemoved(axis); | |
173 | m_domainMap.remove(axis); |
|
173 | m_domainMap.remove(axis); | |
|
174 | if(axis != m_axisY) | |||
174 | delete axis; |
|
175 | delete axis; | |
175 | } |
|
176 | } | |
|
177 | series->setParent(0); | |||
176 | break; |
|
178 | break; | |
177 | } |
|
179 | } | |
178 | } |
|
180 | } | |
179 | } |
|
181 | } | |
180 |
|
182 | |||
|
183 | void ChartDataSet::removeAllSeries() | |||
|
184 | { | |||
|
185 | QList<QChartAxis*> keys = m_seriesMap.uniqueKeys(); | |||
|
186 | foreach(QChartAxis* axis , keys) { | |||
|
187 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); | |||
|
188 | for(int i =0 ; i < seriesList.size();i++ ) | |||
|
189 | { | |||
|
190 | emit seriesRemoved(seriesList.at(i)); | |||
|
191 | delete(seriesList.at(i)); | |||
|
192 | } | |||
|
193 | m_seriesMap.remove(axis); | |||
|
194 | m_domainMap.remove(axis); | |||
|
195 | emit axisRemoved(axis); | |||
|
196 | if(axis != m_axisY) delete axis; | |||
|
197 | } | |||
|
198 | m_domainIndex=0; | |||
|
199 | } | |||
|
200 | ||||
181 | bool ChartDataSet::nextDomain() |
|
201 | bool ChartDataSet::nextDomain() | |
182 | { |
|
202 | { | |
183 | int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1; |
|
203 | int limit = (m_domainMap.values().size()/m_domainMap.uniqueKeys().size())-1; | |
@@ -207,10 +227,13 bool ChartDataSet::previousDomain() | |||||
207 | void ChartDataSet::setDomain(int index) |
|
227 | void ChartDataSet::setDomain(int index) | |
208 | { |
|
228 | { | |
209 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); |
|
229 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); | |
|
230 | ||||
|
231 | Domain domain; | |||
|
232 | ||||
210 | foreach (QChartAxis* axis , domainList) { |
|
233 | foreach (QChartAxis* axis , domainList) { | |
211 | int i = m_domainMap.count(axis) - index -1; |
|
234 | int i = m_domainMap.count(axis) - index -1; | |
212 | Q_ASSERT(i>=0); |
|
235 | Q_ASSERT(i>=0); | |
213 |
|
|
236 | domain = m_domainMap.values(axis).at(i); | |
214 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); |
|
237 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); | |
215 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); |
|
238 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); | |
216 | foreach(QChartSeries* series, seriesList) { |
|
239 | foreach(QChartSeries* series, seriesList) { | |
@@ -219,7 +242,6 void ChartDataSet::setDomain(int index) | |||||
219 | emit axisLabelsChanged(axis,labels); |
|
242 | emit axisLabelsChanged(axis,labels); | |
220 | } |
|
243 | } | |
221 |
|
244 | |||
222 | Domain domain = m_domainMap.value(axisY()); |
|
|||
223 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); |
|
245 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); | |
224 | emit axisLabelsChanged(axisX(),labels); |
|
246 | emit axisLabelsChanged(axisX(),labels); | |
225 | } |
|
247 | } | |
@@ -254,8 +276,10 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport) | |||||
254 |
|
276 | |||
255 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); |
|
277 | QList<QChartAxis*> domainList = m_domainMap.uniqueKeys(); | |
256 |
|
278 | |||
|
279 | Domain domain; | |||
|
280 | ||||
257 | foreach (QChartAxis* axis , domainList){ |
|
281 | foreach (QChartAxis* axis , domainList){ | |
258 |
|
|
282 | domain = m_domainMap.value(axis).subDomain(rect,viewport.width(),viewport.height()); | |
259 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); |
|
283 | QStringList labels = createLabels(axis,domain.m_minY,domain.m_maxY); | |
260 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); |
|
284 | QList<QChartSeries*> seriesList = m_seriesMap.values(axis); | |
261 | foreach(QChartSeries* series, seriesList){ |
|
285 | foreach(QChartSeries* series, seriesList){ | |
@@ -265,7 +289,6 void ChartDataSet::addDomain(const QRectF& rect, const QRectF& viewport) | |||||
265 | m_domainMap.insert(axis,domain); |
|
289 | m_domainMap.insert(axis,domain); | |
266 | } |
|
290 | } | |
267 |
|
291 | |||
268 | Domain domain = m_domainMap.value(axisY()); |
|
|||
269 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); |
|
292 | QStringList labels = createLabels(axisX(),domain.m_minX,domain.m_maxX); | |
270 | emit axisLabelsChanged(axisX(),labels); |
|
293 | emit axisLabelsChanged(axisX(),labels); | |
271 |
|
294 |
@@ -18,6 +18,7 public: | |||||
18 |
|
18 | |||
19 | void addSeries(QChartSeries* series,QChartAxis *axisY = 0); |
|
19 | void addSeries(QChartSeries* series,QChartAxis *axisY = 0); | |
20 | void removeSeries(QChartSeries* series); |
|
20 | void removeSeries(QChartSeries* series); | |
|
21 | void removeAllSeries(); | |||
21 | void addDomain(const QRectF& rect, const QRectF& viewport); |
|
22 | void addDomain(const QRectF& rect, const QRectF& viewport); | |
22 | bool nextDomain(); |
|
23 | bool nextDomain(); | |
23 | bool previousDomain(); |
|
24 | bool previousDomain(); |
@@ -84,6 +84,9 void ChartPresenter::handleAxisAdded(QChartAxis* axis) | |||||
84 | } |
|
84 | } | |
85 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
85 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); | |
86 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); |
|
86 | QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*))); | |
|
87 | ||||
|
88 | item->handleAxisUpdate(axis); | |||
|
89 | item->handleGeometryChanged(m_rect); | |||
87 | m_chartTheme->decorate(axis,item); |
|
90 | m_chartTheme->decorate(axis,item); | |
88 | m_axisItems.insert(axis,item); |
|
91 | m_axisItems.insert(axis,item); | |
89 | } |
|
92 | } |
@@ -20,6 +20,8 class ChartPresenter: public QObject | |||||
20 | { |
|
20 | { | |
21 | Q_OBJECT |
|
21 | Q_OBJECT | |
22 | public: |
|
22 | public: | |
|
23 | enum ZValues { BackgroundZValue = -1 , ShadesZValue, GridZValue, AxisZValue , LineChartZValue }; | |||
|
24 | ||||
23 | ChartPresenter(QChart* chart,ChartDataSet *dataset); |
|
25 | ChartPresenter(QChart* chart,ChartDataSet *dataset); | |
24 | virtual ~ChartPresenter(); |
|
26 | virtual ~ChartPresenter(); | |
25 |
|
27 |
@@ -15,7 +15,7 m_dirtyData(false), | |||||
15 | m_dirtyGeometry(false), |
|
15 | m_dirtyGeometry(false), | |
16 | m_dirtyDomain(false) |
|
16 | m_dirtyDomain(false) | |
17 | { |
|
17 | { | |
18 |
|
18 | setZValue(ChartPresenter::LineChartZValue); | ||
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | QRectF LineChartItem::boundingRect() const |
|
21 | QRectF LineChartItem::boundingRect() const |
@@ -6,21 +6,44 | |||||
6 | #include <QGraphicsSceneResizeEvent> |
|
6 | #include <QGraphicsSceneResizeEvent> | |
7 | #include <QDebug> |
|
7 | #include <QDebug> | |
8 |
|
8 | |||
|
9 | /*! | |||
|
10 | \class QChart | |||
|
11 | \brief QtCommercial chart API. | |||
|
12 | ||||
|
13 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |||
|
14 | representation of different types of QChartSeries and other chart related objects like | |||
|
15 | QChartAxis and QChartLegend. If you simply want to show a chart in a layout, you can use the | |||
|
16 | convenience class QChartView instead of QChart. | |||
|
17 | */ | |||
|
18 | ||||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
19 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 |
|
20 | |||
|
21 | /*! | |||
|
22 | Constructs a chart object which is a child of parent. | |||
|
23 | */ | |||
11 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
24 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
12 | m_backgroundItem(0), |
|
25 | m_backgroundItem(0), | |
13 | m_titleItem(0), |
|
26 | m_titleItem(0), | |
14 | m_dataset(new ChartDataSet(this)), |
|
27 | m_dataset(new ChartDataSet(this)), | |
15 | m_presenter(new ChartPresenter(this,m_dataset)) |
|
28 | m_presenter(new ChartPresenter(this,m_dataset)) | |
16 | { |
|
29 | { | |
17 | } |
|
30 | } | |
18 |
|
31 | |||
19 | QChart::~QChart() {} |
|
32 | /*! | |
|
33 | Destroys the object and it's children, like QChartSeries and QChartAxis object added to it. | |||
|
34 | */ | |||
|
35 | QChart::~QChart() | |||
|
36 | { | |||
|
37 | } | |||
20 |
|
38 | |||
21 | void QChart::addSeries(QChartSeries* series,QChartAxis* axisY) |
|
39 | /*! | |
|
40 | Adds the series and optional y axis onto the chart and takes the ownership of the objects. | |||
|
41 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |||
|
42 | the y axis). | |||
|
43 | */ | |||
|
44 | void QChart::addSeries(QChartSeries* series, QChartAxis* axisY) | |||
22 | { |
|
45 | { | |
23 | m_dataset->addSeries(series,axisY); |
|
46 | m_dataset->addSeries(series, axisY); | |
24 | } |
|
47 | } | |
25 |
|
48 | |||
26 | void QChart::removeSeries(QChartSeries* series) |
|
49 | void QChart::removeSeries(QChartSeries* series) | |
@@ -28,6 +51,11 void QChart::removeSeries(QChartSeries* series) | |||||
28 | m_dataset->removeSeries(series); |
|
51 | m_dataset->removeSeries(series); | |
29 | } |
|
52 | } | |
30 |
|
53 | |||
|
54 | void QChart::removeAllSeries() | |||
|
55 | { | |||
|
56 | m_dataset->removeAllSeries(); | |||
|
57 | } | |||
|
58 | ||||
31 | void QChart::setChartBackgroundBrush(const QBrush& brush) |
|
59 | void QChart::setChartBackgroundBrush(const QBrush& brush) | |
32 | { |
|
60 | { | |
33 | createChartBackgroundItem(); |
|
61 | createChartBackgroundItem(); | |
@@ -58,13 +86,16 void QChart::createChartBackgroundItem() | |||||
58 | { |
|
86 | { | |
59 | if(!m_backgroundItem) { |
|
87 | if(!m_backgroundItem) { | |
60 | m_backgroundItem = new QGraphicsRectItem(this); |
|
88 | m_backgroundItem = new QGraphicsRectItem(this); | |
61 |
m_backgroundItem->setZValue( |
|
89 | m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue); | |
62 | } |
|
90 | } | |
63 | } |
|
91 | } | |
64 |
|
92 | |||
65 | void QChart::createChartTitleItem() |
|
93 | void QChart::createChartTitleItem() | |
66 | { |
|
94 | { | |
67 | if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this); |
|
95 | if(!m_titleItem) { | |
|
96 | m_titleItem = new QGraphicsTextItem(this); | |||
|
97 | m_titleItem->setZValue(ChartPresenter::BackgroundZValue); | |||
|
98 | } | |||
68 | } |
|
99 | } | |
69 |
|
100 | |||
70 | int QChart::margin() const |
|
101 | int QChart::margin() const |
@@ -1,5 +1,5 | |||||
1 | #ifndef CHART_H |
|
1 | #ifndef QCHART_H | |
2 | #define CHART_H |
|
2 | #define QCHART_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qchartseries.h> |
|
5 | #include <qchartseries.h> | |
@@ -21,9 +21,6 class ChartItem; | |||||
21 | class ChartDataSet; |
|
21 | class ChartDataSet; | |
22 | class ChartPresenter; |
|
22 | class ChartPresenter; | |
23 |
|
23 | |||
24 | /*! |
|
|||
25 | * TODO: define the responsibilities |
|
|||
26 | */ |
|
|||
27 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget |
|
24 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget | |
28 | { |
|
25 | { | |
29 | Q_OBJECT |
|
26 | Q_OBJECT | |
@@ -34,7 +31,7 public: | |||||
34 | ChartThemeVanilla, |
|
31 | ChartThemeVanilla, | |
35 | ChartThemeIcy, |
|
32 | ChartThemeIcy, | |
36 | ChartThemeGrayscale, |
|
33 | ChartThemeGrayscale, | |
37 |
ChartThemeScientific |
|
34 | ChartThemeScientific | |
38 | //ChartThemeUnnamed1 |
|
35 | //ChartThemeUnnamed1 | |
39 | }; |
|
36 | }; | |
40 |
|
37 | |||
@@ -42,8 +39,9 public: | |||||
42 | QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); |
|
39 | QChart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); | |
43 | ~QChart(); |
|
40 | ~QChart(); | |
44 |
|
41 | |||
45 |
void addSeries(QChartSeries* series,QChartAxis |
|
42 | void addSeries(QChartSeries* series, QChartAxis* axisY = 0); | |
46 | void removeSeries(QChartSeries* series); |
|
43 | void removeSeries(QChartSeries* series); //returns ownership , deletes axis if no series attached | |
|
44 | void removeAllSeries(); // deletes series and axis | |||
47 |
|
45 | |||
48 | void setMargin(int margin); |
|
46 | void setMargin(int margin); | |
49 | int margin() const; |
|
47 | int margin() const; |
@@ -51,6 +51,11 void QChartView::removeSeries(QChartSeries* series) | |||||
51 | m_chart->removeSeries(series); |
|
51 | m_chart->removeSeries(series); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
|
54 | void QChartView::removeAllSeries() | |||
|
55 | { | |||
|
56 | m_chart->removeAllSeries(); | |||
|
57 | } | |||
|
58 | ||||
54 | void QChartView::zoomIn() |
|
59 | void QChartView::zoomIn() | |
55 | { |
|
60 | { | |
56 | m_chart->zoomIn(); |
|
61 | m_chart->zoomIn(); |
@@ -24,8 +24,9 public: | |||||
24 | //implement from QWidget |
|
24 | //implement from QWidget | |
25 | void resizeEvent(QResizeEvent *event); |
|
25 | void resizeEvent(QResizeEvent *event); | |
26 |
|
26 | |||
27 | void addSeries(QChartSeries* series,QChartAxis* axisY=0);// takes ownership |
|
27 | void addSeries(QChartSeries* series,QChartAxis* axisY=0);// takes series ownership , takes axis ownership | |
28 | void removeSeries(QChartSeries* series); |
|
28 | void removeSeries(QChartSeries* series); //returns ownership , deletes axis if no series attached | |
|
29 | void removeAllSeries(); // deletes series and axis | |||
29 | int margin() const; |
|
30 | int margin() const; | |
30 |
|
31 | |||
31 | void setChartTitle(const QString& title); |
|
32 | void setChartTitle(const QString& title); |
@@ -15,23 +15,86 QScatterSeriesPrivate::QScatterSeriesPrivate() : | |||||
15 | m_markerBrush.setColor(QColor::Invalid); |
|
15 | m_markerBrush.setColor(QColor::Invalid); | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
|
18 | /*! | |||
|
19 | \enum QScatterSeries::MarkerShape | |||
|
20 | ||||
|
21 | This enum describes the shape used when rendering marker items. | |||
|
22 | ||||
|
23 | \value MarkerShapeDefault | |||
|
24 | \value MarkerShapePoint | |||
|
25 | \value MarkerShapeX | |||
|
26 | \value MarkerShapeRectangle | |||
|
27 | \value MarkerShapeTiltedRectangle | |||
|
28 | \value MarkerShapeTriangle | |||
|
29 | \value MarkerShapeCircle | |||
|
30 | */ | |||
|
31 | ||||
|
32 | /*! | |||
|
33 | \class QScatterSeries | |||
|
34 | \brief QtCommercial Chart series API for showing scatter series. | |||
|
35 | ||||
|
36 | Example on how to create a chart with scatter series: | |||
|
37 | \code | |||
|
38 | #include <qchartglobal.h> | |||
|
39 | #include <qchartview.h> | |||
|
40 | #include <qscatterseries.h> | |||
|
41 | ... | |||
|
42 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
43 | ||||
|
44 | // Create chart widget | |||
|
45 | QChartView *chartView = new QChartView(); | |||
|
46 | QScatterSeries *scatter = new QScatterSeries(); | |||
|
47 | *scatter << QPointF(0.5, 5.0) << QPointF(1.0, 4.5) << QPointF(1.0, 5.5) << QPointF(1.5, 5.0); | |||
|
48 | chartView->addSeries(scatter); | |||
|
49 | // Then add the QChartView into a layout... | |||
|
50 | \endcode | |||
|
51 | ||||
|
52 | The example code would result the following: | |||
|
53 | ||||
|
54 | \image scatter_example1.jpg | |||
|
55 | */ | |||
|
56 | ||||
|
57 | /*! | |||
|
58 | Constructs a series object which is a child of \a parent. | |||
|
59 | */ | |||
18 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
60 | QScatterSeries::QScatterSeries(QObject *parent) : | |
19 | QChartSeries(parent), |
|
61 | QChartSeries(parent), | |
20 | d(new QScatterSeriesPrivate()) |
|
62 | d(new QScatterSeriesPrivate()) | |
21 | { |
|
63 | { | |
22 | } |
|
64 | } | |
23 |
|
65 | |||
|
66 | /*! | |||
|
67 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. | |||
|
68 | */ | |||
24 | QScatterSeries::~QScatterSeries() |
|
69 | QScatterSeries::~QScatterSeries() | |
25 | { |
|
70 | { | |
26 | delete d; |
|
71 | delete d; | |
27 | } |
|
72 | } | |
28 |
|
73 | |||
|
74 | /*! | |||
|
75 | Add single data point to the series. | |||
|
76 | For example: | |||
|
77 | \code | |||
|
78 | mySeries.addData(QPointF(0.5, 5.0)); | |||
|
79 | \endcode | |||
|
80 | */ | |||
29 | void QScatterSeries::addData(QPointF value) |
|
81 | void QScatterSeries::addData(QPointF value) | |
30 | { |
|
82 | { | |
31 | d->m_data.append(value); |
|
83 | d->m_data.append(value); | |
32 | emit changed(); |
|
84 | emit changed(); | |
33 | } |
|
85 | } | |
34 |
|
86 | |||
|
87 | /*! | |||
|
88 | Stream operator for adding a data point to the series. | |||
|
89 | \sa addData(), QScatterSeries::addData(QPointF value) | |||
|
90 | ||||
|
91 | For example: | |||
|
92 | \code | |||
|
93 | mySeries << QPointF(0.5, 5.0) | |||
|
94 | << QPointF(1.0, 4.5); | |||
|
95 | \endcode | |||
|
96 | ||||
|
97 | */ | |||
35 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) |
|
98 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |
36 | { |
|
99 | { | |
37 | d->m_data.append(value); |
|
100 | d->m_data.append(value); | |
@@ -39,42 +102,101 QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |||||
39 | return *this; |
|
102 | return *this; | |
40 | } |
|
103 | } | |
41 |
|
104 | |||
|
105 | /*! | |||
|
106 | Replaces the data of the series with the given list of data points. | |||
|
107 | */ | |||
42 | void QScatterSeries::setData(QList<QPointF> data) |
|
108 | void QScatterSeries::setData(QList<QPointF> data) | |
43 | { |
|
109 | { | |
44 | d->m_data = data; |
|
110 | d->m_data = data; | |
45 | emit changed(); |
|
111 | emit changed(); | |
46 | } |
|
112 | } | |
47 |
|
113 | |||
|
114 | /*! | |||
|
115 | Returns the current list of data points of the series. | |||
|
116 | */ | |||
48 | QList<QPointF> QScatterSeries::data() |
|
117 | QList<QPointF> QScatterSeries::data() | |
49 | { |
|
118 | { | |
50 | return d->m_data; |
|
119 | return d->m_data; | |
51 | } |
|
120 | } | |
52 |
|
121 | |||
|
122 | /*! | |||
|
123 | Overrides the default pen used for drawing a marker item with a user defined pen. The default | |||
|
124 | pen is defined by chart theme setting. | |||
|
125 | ||||
|
126 | For example: | |||
|
127 | \code | |||
|
128 | QPen pen(QColor(0, 255, 0, 80), 3); | |||
|
129 | myScatter->setMarkerPen(pen); | |||
|
130 | \endcode | |||
|
131 | ||||
|
132 | Would present your scatter markers with an opaque, uglyish green outlines: | |||
|
133 | \image scatter_example_pen.jpg | |||
|
134 | ||||
|
135 | \sa setMarkerBrush() | |||
|
136 | \sa QChart::setTheme() | |||
|
137 | */ | |||
53 | void QScatterSeries::setMarkerPen(QPen pen) |
|
138 | void QScatterSeries::setMarkerPen(QPen pen) | |
54 | { |
|
139 | { | |
55 | d->m_markerPen = pen; |
|
140 | d->m_markerPen = pen; | |
56 | } |
|
141 | } | |
57 |
|
142 | |||
|
143 | /*! | |||
|
144 | Returns the pen used for drawing markers. | |||
|
145 | */ | |||
58 | QPen QScatterSeries::markerPen() |
|
146 | QPen QScatterSeries::markerPen() | |
59 | { |
|
147 | { | |
60 | return d->m_markerPen; |
|
148 | return d->m_markerPen; | |
61 | } |
|
149 | } | |
62 |
|
150 | |||
|
151 | /*! | |||
|
152 | Overrides the default brush of the marker items with a user defined brush. The default | |||
|
153 | brush is defined by chart theme setting. | |||
|
154 | ||||
|
155 | For example: | |||
|
156 | \code | |||
|
157 | QBrush brush(QColor(255, 0, 0, 100), Qt::SolidPattern); | |||
|
158 | myRandomScatter->setMarkerBrush(brush); | |||
|
159 | \endcode | |||
|
160 | ||||
|
161 | Would fill your scatter markers with an opaque red color: | |||
|
162 | \image scatter_example_brush.jpg | |||
|
163 | ||||
|
164 | \sa setMarkerPen() | |||
|
165 | \sa QChart::setTheme() | |||
|
166 | */ | |||
63 | void QScatterSeries::setMarkerBrush(QBrush brush) |
|
167 | void QScatterSeries::setMarkerBrush(QBrush brush) | |
64 | { |
|
168 | { | |
65 | d->m_markerBrush = brush; |
|
169 | d->m_markerBrush = brush; | |
66 | } |
|
170 | } | |
67 |
|
171 | |||
|
172 | /*! | |||
|
173 | Returns the brush used for drawing markers. | |||
|
174 | */ | |||
68 | QBrush QScatterSeries::markerBrush() |
|
175 | QBrush QScatterSeries::markerBrush() | |
69 | { |
|
176 | { | |
70 | return d->m_markerBrush; |
|
177 | return d->m_markerBrush; | |
71 | } |
|
178 | } | |
72 |
|
179 | |||
|
180 | /*! | |||
|
181 | Overrides the default shape of the marker items with a user defined shape. The default | |||
|
182 | shape is defined by chart theme setting. | |||
|
183 | ||||
|
184 | For example: | |||
|
185 | \code | |||
|
186 | myScatter->setMarkerShape(QScatterSeries::MarkerShapeRectangle); | |||
|
187 | \endcode | |||
|
188 | ||||
|
189 | Would make your scatter marker items rectangle: | |||
|
190 | \image scatter_example_shape.jpg | |||
|
191 | */ | |||
73 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
192 | void QScatterSeries::setMarkerShape(MarkerShape shape) | |
74 | { |
|
193 | { | |
75 | d->m_markerShape = shape; |
|
194 | d->m_markerShape = shape; | |
76 | } |
|
195 | } | |
77 |
|
196 | |||
|
197 | /*! | |||
|
198 | Returns the shape used for drawing markers. | |||
|
199 | */ | |||
78 | QScatterSeries::MarkerShape QScatterSeries::markerShape() |
|
200 | QScatterSeries::MarkerShape QScatterSeries::markerShape() | |
79 | { |
|
201 | { | |
80 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
|
202 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
@@ -45,13 +45,15 void ScatterPresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem * | |||||
45 | { |
|
45 | { | |
46 | // TODO: Optimization: avoid setting on every paint method call? |
|
46 | // TODO: Optimization: avoid setting on every paint method call? | |
47 | // The custom settings in series override those defined by the theme |
|
47 | // The custom settings in series override those defined by the theme | |
48 |
if (m_series->markerPen().color().isValid()) |
|
48 | if (m_series->markerPen().color().isValid()) | |
49 | painter->setPen(m_series->markerPen()); |
|
49 | painter->setPen(m_series->markerPen()); | |
50 | painter->setBrush(m_series->markerBrush()); |
|
50 | else | |
51 | } else { |
|
|||
52 | painter->setPen(m_markerPen); |
|
51 | painter->setPen(m_markerPen); | |
|
52 | ||||
|
53 | if (m_series->markerBrush().color().isValid()) | |||
|
54 | painter->setBrush(m_series->markerBrush()); | |||
|
55 | else | |||
53 | painter->setBrush(m_markerBrush); |
|
56 | painter->setBrush(m_markerBrush); | |
54 | } |
|
|||
55 |
|
57 | |||
56 | int shape = m_series->markerShape(); |
|
58 | int shape = m_series->markerShape(); | |
57 |
|
59 |
@@ -39,6 +39,8 private slots: | |||||
39 | void nextpreviousDomain(); |
|
39 | void nextpreviousDomain(); | |
40 | void removeSeries_data(); |
|
40 | void removeSeries_data(); | |
41 | void removeSeries(); |
|
41 | void removeSeries(); | |
|
42 | void removeAllSeries_data(); | |||
|
43 | void removeAllSeries(); | |||
42 | }; |
|
44 | }; | |
43 |
|
45 | |||
44 | void tst_ChartDataSet::initTestCase() |
|
46 | void tst_ChartDataSet::initTestCase() | |
@@ -189,8 +191,6 void tst_ChartDataSet::addSeries() | |||||
189 | else |
|
191 | else | |
190 | axisYCount++; |
|
192 | axisYCount++; | |
191 |
|
193 | |||
192 |
|
||||
193 |
|
||||
194 | QCOMPARE(spy0.count(), axisYCount); |
|
194 | QCOMPARE(spy0.count(), axisYCount); | |
195 | QCOMPARE(spy1.count(), seriesCount*2); |
|
195 | QCOMPARE(spy1.count(), seriesCount*2); | |
196 | QCOMPARE(spy2.count(), 0); |
|
196 | QCOMPARE(spy2.count(), 0); | |
@@ -513,6 +513,10 void tst_ChartDataSet::removeSeries() | |||||
513 | dataSet.removeSeries(seriesList.at(i)); |
|
513 | dataSet.removeSeries(seriesList.at(i)); | |
514 | } |
|
514 | } | |
515 |
|
515 | |||
|
516 | //default axis | |||
|
517 | if (axisYCount == 0) | |||
|
518 | axisYCount++; | |||
|
519 | ||||
516 | QCOMPARE(spy0.count(), 0); |
|
520 | QCOMPARE(spy0.count(), 0); | |
517 | QCOMPARE(spy1.count(), 0); |
|
521 | QCOMPARE(spy1.count(), 0); | |
518 | QCOMPARE(spy2.count(), axisYCount); |
|
522 | QCOMPARE(spy2.count(), axisYCount); | |
@@ -521,8 +525,75 void tst_ChartDataSet::removeSeries() | |||||
521 | QCOMPARE(spy5.count(), seriesCount); |
|
525 | QCOMPARE(spy5.count(), seriesCount); | |
522 |
|
526 | |||
523 | QCOMPARE(dataSet.domainIndex(), 0); |
|
527 | QCOMPARE(dataSet.domainIndex(), 0); | |
|
528 | ||||
|
529 | qDeleteAll(seriesList); | |||
524 | } |
|
530 | } | |
525 |
|
531 | |||
|
532 | void tst_ChartDataSet::removeAllSeries_data() | |||
|
533 | { | |||
|
534 | QTest::addColumn<int>("seriesCount"); | |||
|
535 | QTest::addColumn<int>("axisYCount"); | |||
|
536 | QTest::newRow("2 series, default axis") << 2 << 0; | |||
|
537 | QTest::newRow("2 series, 2 new axis") << 2 << 2; | |||
|
538 | QTest::newRow("2 series, 1 new axis") << 2 << 2; | |||
|
539 | QTest::newRow("3 series, 3 new axis") << 3 << 3; | |||
|
540 | QTest::newRow("3 series, 2 new axis") << 3 << 2; | |||
|
541 | QTest::newRow("3 series, 1 new axis") << 3 << 1; | |||
|
542 | } | |||
|
543 | ||||
|
544 | void tst_ChartDataSet::removeAllSeries() | |||
|
545 | { | |||
|
546 | QFETCH(int, seriesCount); | |||
|
547 | QFETCH(int, axisYCount); | |||
|
548 | ||||
|
549 | ChartDataSet dataSet; | |||
|
550 | ||||
|
551 | QList<QChartAxis*> axisList; | |||
|
552 | ||||
|
553 | for (int i = 0; i < axisYCount; i++) { | |||
|
554 | QChartAxis* axis = new QChartAxis(); | |||
|
555 | axisList << axis; | |||
|
556 | } | |||
|
557 | ||||
|
558 | QList<QChartAxis*>::iterator iterator = axisList.begin(); | |||
|
559 | ||||
|
560 | for (int i = 0; i < seriesCount; i++) { | |||
|
561 | QChartAxis* axisY = 0; | |||
|
562 | QLineChartSeries* series = new QLineChartSeries(); | |||
|
563 | if (iterator != axisList.end()) { | |||
|
564 | axisY = *iterator; | |||
|
565 | iterator++; | |||
|
566 | } else if (axisList.count() > 0) { | |||
|
567 | iterator--; | |||
|
568 | axisY = *iterator; | |||
|
569 | iterator++; | |||
|
570 | } | |||
|
571 | dataSet.addSeries(series, axisY); | |||
|
572 | } | |||
|
573 | ||||
|
574 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*))); | |||
|
575 | QSignalSpy spy1(&dataSet, SIGNAL(axisLabelsChanged(QChartAxis*, QStringList const&))); | |||
|
576 | QSignalSpy spy2(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); | |||
|
577 | QSignalSpy spy3(&dataSet, SIGNAL(seriesAdded(QChartSeries*))); | |||
|
578 | QSignalSpy spy4(&dataSet, SIGNAL(seriesDomainChanged(QChartSeries*, Domain const&))); | |||
|
579 | QSignalSpy spy5(&dataSet, SIGNAL(seriesRemoved(QChartSeries*))); | |||
|
580 | ||||
|
581 | dataSet.removeAllSeries(); | |||
|
582 | //default axis | |||
|
583 | if (axisYCount == 0) | |||
|
584 | axisYCount++; | |||
|
585 | ||||
|
586 | QCOMPARE(spy0.count(), 0); | |||
|
587 | QCOMPARE(spy1.count(), 0); | |||
|
588 | QCOMPARE(spy2.count(), axisYCount); | |||
|
589 | QCOMPARE(spy3.count(), 0); | |||
|
590 | QCOMPARE(spy4.count(), 0); | |||
|
591 | QCOMPARE(spy5.count(), seriesCount); | |||
|
592 | ||||
|
593 | QCOMPARE(dataSet.domainIndex(), 0); | |||
|
594 | } | |||
|
595 | ||||
|
596 | ||||
526 | QTEST_MAIN(tst_ChartDataSet) |
|
597 | QTEST_MAIN(tst_ChartDataSet) | |
527 | #include "tst_chartdataset.moc" |
|
598 | #include "tst_chartdataset.moc" | |
528 |
|
599 |
@@ -8,7 +8,7 Q_DECL_EXPORT int main(int argc, char *argv[]) | |||||
8 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); |
|
8 | QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); | |
9 |
|
9 | |||
10 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); |
|
10 | viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); | |
11 |
viewer->set |
|
11 | viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); | |
12 | viewer->showExpanded(); |
|
12 | viewer->showExpanded(); | |
13 |
|
13 | |||
14 | return app->exec(); |
|
14 | return app->exec(); |
@@ -2,8 +2,8 import QtQuick 1.0 | |||||
2 | import QtCommercial.Chart 1.0 |
|
2 | import QtCommercial.Chart 1.0 | |
3 |
|
3 | |||
4 | Rectangle { |
|
4 | Rectangle { | |
5 | width: 360 |
|
5 | width: parent.width | |
6 |
height: |
|
6 | height: parent.height | |
7 |
|
7 | |||
8 | // Another option for QML data api: |
|
8 | // Another option for QML data api: | |
9 | // ListModel { |
|
9 | // ListModel { |
@@ -1,18 +1,21 | |||||
1 | !include( ../../common.pri ) { |
|
1 | !include( ../../common.pri ) { | |
2 | error( "Couldn't find the common.pri file!" ) |
|
2 | error( "Couldn't find the common.pri file!" ) | |
3 | } |
|
3 | } | |
4 | !include( ../../integrated.pri ) { |
|
|||
5 | error( "Couldn't find the integrated.pri file !") |
|
|||
6 | } |
|
|||
7 |
|
4 | |||
8 | integrated_build: { |
|
5 | DESTDIR = $$CHART_BUILD_BIN_DIR | |
9 | # cannot use integrated build for now; we would need the qml files copied to |
|
6 | ||
10 | # charts/bin folder also to make this work. And even in that case I'm not sure if |
|
7 | OBJECTS_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
11 | # the chart qml plugin can be found or if it needs to be installed to the qt's plugin |
|
8 | MOC_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
12 | # folder always. |
|
9 | UI_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
13 | warning("TODO: Charts qml test app does not work with integrated builds") |
|
10 | RCC_DIR = $$CHART_BUILD_DIR/bin/$$TARGET | |
|
11 | ||||
|
12 | integrated_build:{ | |||
|
13 | message(Please export QML_IMPORT_PATH=$$CHART_BUILD_LIB_DIR) | |||
14 | } |
|
14 | } | |
15 |
|
15 | |||
|
16 | RESOURCES += \ | |||
|
17 | resources.qrc | |||
|
18 | ||||
16 | # Add more folders to ship with the application, here |
|
19 | # Add more folders to ship with the application, here | |
17 | folder_01.source = qml/qmlchart |
|
20 | folder_01.source = qml/qmlchart | |
18 | folder_01.target = qml |
|
21 | folder_01.target = qml |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now